Configuring a Pipeline Pre-Processing and Post-Processing of Files

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 Oracle JCA Adapter for FilesFTP 4-13 message to the SCA container. In the case of a zipped file, this method gets called repeatedly, once for each entry in the zip file. This should be used by the Valve to do additional tasks such as delete the staging file that has been processed in a reentrant scenario. param in The original InputStreamContext returned from codeexecutecode public void finalizeInputStreamContext in; Cleans up intermediate staging files, input streams throws PipelineException, IOException public void cleanup throws PipelineException, IOException; } The StagedValve stores intermediate content in staging files. Example 4–2 shows the StagedValve interface extending the Valve interface. Example 4–2 The StagedValve Interface Extending the Valve Interface package oracle.tip.pc.services.pipeline; import java.io.File; A special valve that stages the modified input stream in a staging file. If such a codeValvecode exists, then it must return the staging file containing the intermediate data. public interface StagedValve extends Valve { return staging file where the valve stores its intermediate results public File getStagingFile; } Example 4–3 is a sample of an AbstractValve class implementing the Valve interface. Example 4–3 The AbstractValve Class Implementing the Valve Interface package oracle.tip.pc.services.pipeline; import java.io.IOException; A bare bone implementation of Valve. The user should extend from AbstractValve rather than implementing a Valve from scratch public abstract class AbstractValve implements Valve { The pipeline instance is stored as a member private Pipeline pipeline = null; 4-14 Oracle Fusion Middleware Users Guide for Technology Adapters If reentrant is set to true, then the Valve must adhere to the following: i It must the first valve in the pipeline ii Must implement hasNext method and return true if more input streams are available A reentrant valve will be called by the pipeline more than once and each time the valve must return a different input stream e.g. Zipped entries within a zip file private boolean reentrant = false; Save the pipeline instance. see oracle.tip.pc.services.pipeline.ValvesetPipelineoracle.tip.pc.services.pipeline. Pipeline public void setPipelinePipeline pipeline { this.pipeline = pipeline; } Return the pipeline instance non-Javadoc see oracle.tip.pc.services.pipeline.ValvegetPipeline public Pipeline getPipeline { return this.pipeline; } Return true if the valve is reentrant non-Javadoc see oracle.tip.pc.services.pipeline.ValveisReentrant public boolean isReentrant { return this.reentrant; } If set to true, the valve is reentrant non-Javadoc see oracle.tip.pc.services.pipeline.ValvesetReentrantboolean public void setReentrantboolean reentrant { this.reentrant = reentrant; } By default, set to false For valves that can return more than one inputstreams to callers, this parameter must return truefalse depending on the availability of input streams non-Javadoc see oracle.tip.pc.services.pipeline.ValvehasNext public boolean hasNext { return false; } Oracle JCA Adapter for FilesFTP 4-15 Implemented by concrete valve non-Javadoc see oracle.tip.pc.services.pipeline.ValveexecuteInputStreamContext public abstract InputStreamContext executeInputStreamContext in throws PipelineException, IOException; Implemented by concrete valve non-Javadoc see oracle.tip.pc.services.pipeline.Valvefinalizeoracle.tip.pc.services.pipeline.Inp utStreamContext public abstract void finalizeInputStreamContext in; Implemented by concrete valve non-Javadoc see oracle.tip.pc.services.pipeline.Valvecleanup public abstract void cleanup throws PipelineException, IOException; } Example 4–4 shows the AbstractStagedValve class extending the AbstractValve class. Example 4–4 The AbstractStagedValve Class Extending the AbstractValve Class package oracle.tip.pc.services.pipeline; import java.io.File; import java.io.IOException; public abstract class AbstractStagedValve extends AbstractValve implements StagedValve { public abstract File getStagingFile; public abstract void cleanup throws IOException, PipelineException; public abstract InputStreamContext executeInputStreamContext in throws IOException, PipelineException; } For more information on valves, see Appendix B, Oracle JCA Adapter Valves. Step 2 Compiling the Valves You must use the bpm-infra.jar file to compile the valves. The bpm-infra.jar file is located at MW_HOMEAS11gR1SOAsoamodulesoracle.soa.fabric_ 11.1.1bpm-infra.jar. 1. Reference the SOA project to the bpm-infra.jar file, by using the following procedure: a. In the Application Navigator, right-click the SOA project. 4-16 Oracle Fusion Middleware Users Guide for Technology Adapters

b. Select Project Properties. The Project Properties dialog is displayed.

c. Click Libraries and Classpath. The Libraries and Classpath pane is displayed

as shown in Figure 4–5 . Figure 4–5 The Project Properties Dialog d. Click Add JarDirectory. The Add Archive or Directory dialog is displayed. e. Browse to select the bpm-infra.jar file. The Bpm-infra.jar file is located at MW_HOMEAS11gR1SOAsoamodulesoracle.soa.fabric_ 11.1.1bpm-infra.jar.

f. Click OK. The bpm-infra.jar file is listed under Classpath Entries.

2. Compile the valves using the bpm-infra.jar file.

3. Make the JAR file containing the compiled valves available to the Oracle

WebLogic Server classpath by adding the jar file to the soainfra domain classpath. For example, MW_HOMEuser_ projectsdomainssoainfralib. Step 3 Creating a Pipeline To configure a pipeline, you must create an XML file that conforms to the following schema: ?xml version=1.0 encoding=UTF-8 ? xs:schema xmlns:xs=http:www.w3.org2001XMLSchema targetNamespace=http:www.oracle.comadapterpipeline xs:element name=pipeline xs:complexType xs:sequence Note: Ensure that you compile bpm-infra.jar with JDK 6.0 to avoid compilation error such as class file has wrong version 50.0, should be 49.0. Oracle JCA Adapter for FilesFTP 4-17 xs:element ref=valves xs:complexType xs:sequence xs:element ref=valve maxOccurs=unbounded xs:complexType mixed=true xs:attribute name=reentrant type=xs:NMTOKEN use=optional xs:complexType xs:element xs:sequence xs:complexType xs:element xs:sequence xs:complexType xs:attribute name=useStaging type=xs:NMTOKEN use=optional xs:attribute name=batchNotificationHandler type=xs:NMTOKEN use= optional xs:element xs:schema The following is a sample XML file configured for a pipeline with two valves, SimpleUnzipValve and SimpleDecryptValve: ?xml version=1.0? pipeline xmlns=http:www.oracle.comadapterpipeline valves valvevalves.SimpleUnzipValvevalve valve valves.SimpleDecryptValve valve valves pipeline Step 4 Adding the Pipeline to the SOA Project Directory You must add the pipeline.xml file to the SOA project directory. This step is required to integrate the pipeline with the Oracle File or FTP Adapter. Figure 4–6 shows a sample pipeline.xml file unzippipeline.xml added to the InboundUnzipAndOutboundZip project. Figure 4–6 Project with unzippipeline.xml File Step 5 Registering the Pipeline The pipeline that is a part of the SOA project must be registered by modifying the inbound JCA file, by adding the following property: