Wednesday, November 27, 2013

Using Spring Context in SOA


Use case : Use spring in Bpel to read,write huge files. Since default File Adapter works in Bpel memory this would be good for heavy lifting. I know we have options of java embedd and EJB, but since springs are considered as best java option I would like to explore this option.

Steps:
1. Create a SOA Project , Composite.
2. Create a java interface that has method for reading/writing files : IFileUtils.java
   method readWriteFile(String filename)
3. Create a java class that implements the  IFileUtils interface for reading/writing files : FileUtils.java
4. Now if you dont see spring option in composite , update the Jdeveloper with "Spring & Oracle WebLogic SCA" using help->updates.

5. Create a Bpel process that will invoke the spring.
6. Drop a Spring context in composite :
Name : FileUtilsSpring
Create a new context : FileUtilitySpring.

7. Open FileUtilitySpring.xml and add below lines of code inside the bean tag aftre the below comment
<!--Spring Bean definitions go here-->
  <bean class="pc.com.fileutils.FileUtils" id="Fileimpl" />
  <sca:service name="test" target="Fileimpl" type="pc.com.fileutils.IFileUtils" />

The file should look like :


8. Now you should be able to wire the Bpel and spring component. It will generate the WSDL and load java classes, Composite should look like :


9. Add invoke to Bpel to add the spring context, assign required values
10. Deploy the code and Test in EM

This works great !!