Oracle® Fusion Middleware User's Guide for the Oracle Java CAPS Migration Tool 11g Release 1 (11.1.1.6.0) Part Number E24884-01 |
|
|
PDF · Mobi · ePub |
This appendix provides code samples that illustrate how a stand-alone Java Collaboration Definition (JCD) is converted to SOA Suite and how a JCD called from a business process is converted.
This appendix includes the following topics:
For more information about migrating JCDs, see Section 1.2.2.1, "Support for Java Collaboration Definition Migration."
The following example illustrates how a JCD with a File inbound connection and both File and JMS outbound connections is converted to a SOA Suite Spring Bean class.
Sample Source JCD Code for Stand-Alone JCD
package CAPSProject1; public class Collaboration_1 { public com.stc.codegen.logger.Logger logger; public com.stc.codegen.alerter.Alerter alerter; public com.stc.codegen.util.CollaborationContext collabContext; public com.stc.codegen.util.TypeConverter typeConverter; public void receive( com.stc.connector.appconn.file.FileTextMessage input, com.stc.connector.appconn.file.FileApplication FileClient_1, com.stc.connectors.jms.JMS JMS_1,employees.EmployeesOTD Employees_1 ) throws Throwable { logger.info( "inside receive." ); com.stc.connectors.jms.Message msg = JMS_1.createTextMessage( input.getText() ); employees.EMPLOYEES emp = Employees_1.getEMPLOYEES(); logger.info( emp.getLAST_NAME() ); JMS_1.send( msg ); FileClient_1.setText( input.getText() ); FileClient_1.write(); } }
Sample Output Generated for SOA Suite for a Stand-Alone JCD
package CAPSProject1; public class Collaboration_1 implements FILEIN_Collaboration_1_input.capsproject1.file.adapter.pcbpel.com.oracle.xmlns.Read_ptt { private JMSOUT_Collaboration_1_JMS_ 1.capsproject1.jms.adapter.pcbpel.com.oracle.xmlns.Produce_Message_ptt JMSOUT_Collaboration_1_JMS_1; private FILEOUT_Collaboration_1_FileClient_ 1.capsproject1.file.adapter.pcbpel.com.oracle.xmlns.Write_ptt FILEOUT_Collaboration_1_FileClient_1; public void read(byte opaque[]) { com.stc.connector.appconn.file.FileTextMessage input = new com.stc.connector.appconn.file.FileTextMessageImpl(); input.setByteArray(opaque); com.stc.connector.appconn.file.FileApplication FileClient_1 = new com.stc.connector.appconn.file.FileApplication(); com.stc.connectors.jms.JMS JMS_1 = new com.stc.connectors.jms.JMS(); employees.EmployeesOTD Employees_1 = new employees.EmployeesOTD(); try { this.receive(input, FileClient_1, JMS_1, Employees_1); } catch (Throwable exp_0) { throw new java.lang.RuntimeException(exp_0); } finally { } //JMSOUT_Collaboration_1_JMS_1.produceMessage(opaque); //FILEOUT_Collaboration_1_FileClient_1.write(opaque); } public com.stc.codegen.logger.Logger logger; public com.stc.codegen.alerter.Alerter alerter; public com.stc.codegen.util.CollaborationContext collabContext; public com.stc.codegen.util.TypeConverter typeConverter; public void receive(com.stc.connector.appconn.file.FileTextMessage input, com.stc.connector.appconn.file.FileApplication FileClient_1, com.stc.connectors.jms.JMS JMS_1, employees.EmployeesOTD Employees_1) throws Throwable { logger.info("inside receive."); com.stc.connectors.jms.Message msg = JMS_1.createTextMessage(input.getText()); employees.EMPLOYEES emp = Employees_1.getEMPLOYEES(); logger.info(emp.getLAST_NAME()); JMS_1.send(msg); FileClient_1.setText(input.getText()); FileClient_1.write(); } public final void setJMSOUT_Collaboration_1_JMS_1(JMSOUT_Collaboration_1_JMS_ 1.capsproject1.jms.adapter.pcbpel.com.oracle.xmlns.Produce_Message_ptt JMSOUT_Collaboration_1_JMS_1) { this.JMSOUT_Collaboration_1_JMS_1 = JMSOUT_Collaboration_1_JMS_1; } public final JMSOUT_Collaboration_1_JMS_1.capsproject1.jms.adapter.pcbpel.com. oracle.xmlns.Produce_Message_ptt getJMSOUT_Collaboration_1_JMS_1() { return this.JMSOUT_Collaboration_1_JMS_1; } public final void setFILEOUT_Collaboration_1_FileClient_1(FILEOUT_Collaboration_ 1_FileClient_1.capsproject1.file.adapter.pcbpel.com. oracle.xmlns.Write_ptt FILEOUT_Collaboration_1_FileClient_1) { this.FILEOUT_Collaboration_1_FileClient_1 = FILEOUT_Collaboration_1_ FileClient_1; } public final FILEOUT_Collaboration_1_FileClient_1.capsproject1.file.adapter. pcbpel.com.oracle.xmlns.Write_ptt getFILEOUT_Collaboration_1_FileClient_1() { return this.FILEOUT_Collaboration_1_FileClient_1; } public final void setLogger(com.stc.codegen.logger.Logger logger) { this.logger = logger; } public final com.stc.codegen.logger.Logger getLogger() { return this.logger; } public final void setAlerter(com.stc.codegen.alerter.Alerter alerter) { this.alerter = alerter; } public final com.stc.codegen.alerter.Alerter getAlerter() { return this.alerter; } public final void setCollabContext(com.stc.codegen.util.CollaborationContext collabContext) { this.collabContext = collabContext; } public final com.stc.codegen.util.CollaborationContext getCollabContext() { return this.collabContext; } public final void setTypeConverter(com.stc.codegen.util.TypeConverter typeConverter) { this.typeConverter = typeConverter; } public final com.stc.codegen.util.TypeConverter getTypeConverter() { return this.typeConverter; } }
You can see in the above samples that the migrated JCD class now implements the SOA Suite File Adapter interface, and the implemented interface method public void read(byte opaque[])
replaces the following method from the original JCD:
public void receive(com.stc.connector.appconn.file.FileTextMessage input, com.stc.connector.appconn.file.FileApplication FileClient_1, com.stc.connectors.jms.JMS JMS_1, employees.EmployeesOTD Employees_1)
This is the triggering method when an input file is present in the input directory. The configuration of the SOA Suite File Adapter is defined in a JCA file generated by the migration tool. You can modify the configuration in Oracle JDeveloper.
The interface method invokes the original JCD method. The following two class fields represent the outbound SOA Suite File and JMS adapters:
private JMSOUT_Collaboration_1_JMS_1.capsproject1.jms.adapter.pcbpel.com.oracle.xmlns.Produce_Message_ptt JMSOUT_Collaboration_1_JMS_1; private FILEOUT_Collaboration_1_FileClient_1.capsproject1.file.adapter.pcbpel.com.oracle.xmlns.Write_ptt FILEOUT_Collaboration_1_FileClient_1;
The above two class fields, as well as the following class fields in the original JCD, are not instantiated, but getter and setter methods are generated for them. This allows them to be instantiated using SOA Suite's context injection.
public com.stc.codegen.logger.Logger logger; public com.stc.codegen.alerter.Alerter alerter; public com.stc.codegen.util.CollaborationContext collabContext; public com.stc.codegen.util.TypeConverter typeConverter;
The following example illustrates how a JCD that is invoked from a business process is converted to a SOA Suite Spring Bean class.
Sample JCD Source Code for a JCD Invoked from a Business Process
package Jcd_Bpel_Project; public class Collaboration_3 { public com.stc.codegen.logger.Logger logger; public com.stc.codegen.alerter.Alerter alerter; public com.stc.codegen.util.CollaborationContext collabContext; public com.stc.codegen.util.TypeConverter typeConverter; public void op1_vikas( dtd.otdInputDTD_2111422138.DBemployee input, dtd.otdOutputDTD_1854792262.DBemployee output ) throws Throwable { output.setEmpNo( input.getEmpNo() ); output.setLastname( input.getLastname() ); output.setFirstname( input.getFirstname() ); output.setRate( input.getRate() ); output.setLastDate( input.getLastDate() ); Thread.sleep( 120000 ); } }
Sample Output Code Generated for a JCD Invoked from a Business Process
package Jcd_Bpel_Project; import oracle.migrationtool.migration.caps.runtime.OTDUtil; public class Collaboration_3 implements urn_stc_egate_jce_collaboration_1wsdl.ExecutePortType { private stc.egate.otd.dtd.otdoutputdtd_1854792262.DBemployee output; public stc.egate.otd.dtd.otdoutputdtd_1854792262.DBemployee op1Vikas(stc.egate.otd.dtd.otdinputdtd_2111422138.DBemployee DBemployee) throws urn_stc_egate_jce_collaboration_1wsdl.JavaExceptionMessage { this.output = new stc.egate.otd.dtd.otdoutputdtd_1854792262.DBemployee(); try { this.op1_vikas(DBemployee, this.output); } catch (Throwable exp_0) { throw new urn_stc_egate_jce_collaboration_1wsdl.JavaExceptionMessage (exp_0.getMessage(), null, exp_0); } finally { } return this.output; } public com.stc.codegen.logger.Logger logger; public com.stc.codegen.alerter.Alerter alerter; public com.stc.codegen.util.CollaborationContext collabContext; public com.stc.codegen.util.TypeConverter typeConverter; public void op1_vikas(stc.egate.otd.dtd.otdinputdtd_2111422138.DBemployee input, stc.egate.otd.dtd.otdoutputdtd_1854792262.DBemployee output) throws Throwable { output.setEmpNo(input.getEmpNo()); output.setLastname(input.getLastname()); output.setFirstname(input.getFirstname()); output.setRate(input.getRate()); output.setLastDate(input.getLastDate()); Thread.sleep(120000); } public final void setOutput(stc.egate.otd.dtd.otdoutputdtd_1854792262.DBemployee output) { this.output = output; } public final stc.egate.otd.dtd.otdoutputdtd_1854792262.DBemployee getOutput() { return this.output; } public final void setLogger(com.stc.codegen.logger.Logger logger) { this.logger = logger; } public final com.stc.codegen.logger.Logger getLogger() { return this.logger; } public final void setAlerter(com.stc.codegen.alerter.Alerter alerter) { this.alerter = alerter; } public final com.stc.codegen.alerter.Alerter getAlerter() { return this.alerter; } public final void setCollabContext(com.stc.codegen.util.CollaborationContext collabContext) { this.collabContext = collabContext; } public final com.stc.codegen.util.CollaborationContext getCollabContext() { return this.collabContext; } public final void setTypeConverter(com.stc.codegen.util.TypeConverter typeConverter) { this.typeConverter = typeConverter; } public final com.stc.codegen.util.TypeConverter getTypeConverter() { return this.typeConverter; } }
The converted class implements a JAXB proxy interface and the original OTD classes of the JCD are replaced by JAXB objects.Getters and setters are generated for the Spring context injection.
Most comments in the original JCD are preserved in the migrated SOA Spring Bean class. Comments without a following Java statement are not preserved during the migration. To ensure comments are preserved, add a semicolon (;) after comments without a following Java statement in the original JCD so that the comment can be preserved.