Monday, October 25, 2010

Spring & BPEL extension functions in SOA Suite 11g PS2

Last December I uploaded a doc detailing a simple Spring lab - here now is an example based on Patchset 2.

To begin with you may need to download the JDev Spring extension (Menu --> Help --> Check for Updates).

An excellent intro to Spring is the official doc at http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/pdf/spring-framework-reference.pdf

Ok, so now back to our simple example -

In this example we will have a Java class that does some simple SOA Composite logging for us. We will leverage the BPEL XPath extension functions as detailed in Appendix B of the SOA Suite Developers Guide - available at http://download.oracle.com/docs/cd/E14571_01/integration.1111/e10224/bp_appx_functs.htm#CHDECDHG

This is based on an excellent example from Clemens Utschig - so vielen Dank!

I'm going to use the following -

ora:getDomainId()
ora:getECID()

ora:getCompositeName()
ora:getCompositeInstanceId()

ora:getComponentName()
ora:getComponentInstanceId()

ora:getElement()

Steps -

1. Create the Java Interface for the logger
2. Create the Java class that implements the interface
3. Spring-enable
4. Expose the Spring component as an SCA Service
5. Create a SOA Composite with a BPEL process
6. Invoke the Spring component from BPEL
7. Deploy and Test
1. Create the Java Interface for the logger
1.1. Create a new generic application in JDev - LoggingWithSpringApp
1.2. Name the project - LoggingWithSpring
1.3. Create the Java interface - ILogger - package name my.company.com




1.4. Add a log() method.


public void log(String domainID, String ecid, String compositeName,
String compositeInstanceID,String componentName,
String componentInstanceID, String elem );
}

2. Create the Java class that implements the interface




2.1. Implement the log() method.

public void log(String domainID, String ecid, String compositeName,
String compositeInstanceID, String componentName,
String componentInstanceID, String elem) {

StringBuffer msg = new StringBuffer();
msg.append("[Domain ID] ").append(domainID).append("[ECID]").append(ecid).
append("[Composite Name]").append(compositeName).append("[Composite Instance ID]").
append(componentInstanceID).append("[Component Name]").append(componentName).
append("[Component Instance ID]").append(componentInstanceID).append("[Input Element]").
append(elem);
System.out.println(msg.toString());
}

3. Spring-enable

3.1. Create a new Spring Bean configuration in the project



3.2. call it logger-context.xml

3.3. Select Spring 2.5 Core in the component palette




3.4. Drag a bean from the Spring 2.5 Core component palette

3.5. set name and class as below




4. Expose the Spring component as an SCA Service

4.1. Change the palette to Weblogic SCA and drag & drop a Service




4.2. Set as follows -




5. Create a SOA Composite with a BPEL process

5.1. File --> New --> SOA Composite --> Composite with BPEL process
5.2. call the composite - LoggingWithSpringComposite
5.3. Create the BPEL process




5.4. Go to the Composite Editor view and drop a Spring Context component.



5.5. Make the Java class and interface.



5.6. Wire together.





6. Invoke the Spring component from BPEL

6.1. add an Invoke activity to the BPEL process to call the logger




6.2. Add an Assign activity to set the call arguments
6.3. See below for the 7 assigns





6.4. add an Assign after the Invoke to set input to output



7. Deploy and Test

7.1. Deploy ot SOA Suite and test via EM.



View results in server log

No comments: