Mechanism For Pre-Processing and Post-Processing of Files

Oracle JCA Adapter for FilesFTP 4-11 Figure 4–4 A Sample Pre-Processing Pipeline

4.2.14.2 Configuring a Pipeline

Configuring the mechanism for pre-processing and post-processing of files requires defining a pipeline and configuring it in the corresponding JCA file. To configure a pipeline, you must perform the following steps: ■ Step 1, Implementing and Extending Valves ■ Step 2, Compiling the Valves ■ Step 3, Creating a Pipeline ■ Step 4, Adding the Pipeline to the SOA Project Directory ■ Step 5, Registering the Pipeline Step 1 Implementing and Extending Valves All valves must implement Valve or StagedValve interface. Example 4–1 is a sample valve interface. Example 4–1 The Valve Interface package oracle.tip.pc.services.pipeline; import java.io.IOException; p Valve component is resposible for processing the input stream and returning a modified input stream. The codeexecutecode method of the valve gets invoked by the caller on behalf of the pipeline. This method must return the input stream wrapped within an InputStreamContext. The Valve is also responsible for error handling specifically Tip: You can extend either the AbstractValve or the AbstractStagedValve class based on business requirement rather than implementing a valve from scratch. 4-12 Oracle Fusion Middleware Users Guide for Technology Adapters The Valve can be marked as reentrant in which case the caller must call the codeexecutecode multiple times and each invocation must return a new input stream. This is useful, if you are writing an UnzipValve since each iteration of the valve must return the input stream for a different zipped entry. b You must note that only the first Valve in the pipeline can be reentrant b The Valve has another flavor codeStagedValvecode and if the valve implements StagedValve, then the valve must store intermediate content in a staging file and return it whenever required. p public interface Valve { Set the Pipeline instance. This parameter can be used to get a reference to the PipelineContext instance. param pipeline public void setPipelinePipeline pipeline; Returns the Pipeline instance. return public Pipeline getPipeline; Returns true if the valve has more input streams to return For example, if the input stream is from a zipped file, then each invocation of codeexecutecode returns a different input stream once for each zipped entry. The caller calls codehasNextcode to check if more entries are available return truefalse public boolean hasNext; Set to true if the caller can call the valve multiple times e.g. in case of ZippedInputStreams param reentrant public void setReentrantboolean reentrant; Returns true if the valve is reentrant. return public boolean isReentrant; The method is called by pipeline to return the modified input stream param in return InputStreamContext that wraps the input stream along with required metadata throws PipelineException public InputStreamContext executeInputStreamContext in throws PipelineException, IOException; This method is called by the pipeline after the caller publishes the