55 Integrating the Spring Framework in SOA Composite Applications
This chapter includes the following sections:
-
Integration of Java and WSDL-Based Components in the Same SOA Composite Application
-
Defining Custom Spring Beans Through a Global Spring Context
-
Configuring Groovy and Aspectj Classes with the Spring Service Component
For more information about the WebLogic SCA functionality used by Oracle SOA Suite, see Developing WebLogic SCA Applications for Oracle WebLogic Server.
For samples about how to use the spring framework, see the Oracle SOA Suite samples site.
55.1 Introduction to the Spring Service Component
The spring framework is a lightweight container that makes it easy to use different types of services. Lightweight containers can accept any JavaBean, instead of specific types of components.
WebLogic SCA enables you to use the spring framework to create Java applications using plain old Java objects (POJOs) and expose components as SCA services and references. In SCA terms, a WebLogic spring framework SCA application is a collection of POJOs plus a spring SCA context file that wires the classes with SCA services and references.
You can use the spring framework to create service components and wire them within a SOA composite application using its dependency injection capabilities. SCA can extend spring framework capabilities as follows:
-
Publish spring beans as SCA component services that can be accessed by other SCA components or by remote clients
-
Provide spring beans for service references wired to services of other components
As with all service components, spring components are defined in the composite.xml
file. The spring component defined in the composite.xml
file has service and reference elements with binding.java
.
Services are implemented by beans and are targeted in the spring context file. References are supplied by the runtime as implicit (or virtual) beans in the spring context file.
You can also integrate Enterprise JavaBeans (EJB) with SOA composite applications through use of Java interfaces (with no requirement for SDO parameters). For information, see Integrating Enterprise JavaBeans with Composite Applications .
55.2 Integration of Java and WSDL-Based Components in the Same SOA Composite Application
You can integrate components using Java interfaces and WSDL files in a SOA composite application in the SOA Composite Editor. As an example, this integration enables a spring service component to invoke an Oracle BPEL Process Manager or an Oracle Mediator service component to invoke an EJB, and so on.
The following types of component integrations are supported:
-
Java components to WSDL components
If you drag a wire from a Java interface (for example, EJB service or spring service component) to a component that does not support Java interfaces (for example, Oracle Mediator, Oracle BPEL Process Manager, or others), a compatible WSDL is generated for the component interfaces.
-
WSDL components to Java components
If you drag a wire from a WSDL interface to a component that does not support WSDL files (for example, a spring service component), a compatible Java interface is automatically generated. It is also possible to wire an existing WSDL interface to an existing Java interface. In this case, there is no checking of the compatibility between the WSDL and Java interfaces. You must ensure that it is correct.
-
Java components to Java components
If you create a spring service component, you can automatically configure it with Java interface-based EJB service and reference binding components. No WSDL files are required.
55.2.1 Java and WSDL-Based Integration Example
When wiring any two service components (or a service component with a binding component), each end of the wire has an interface defined. With XML, those interfaces must have the same WSDL definition, and are defined with interface.wsdl
in the composite.xml
file.
From the JAX-WS point of view, when wiring a Java interface (which is defined by interface.java
) to a WSDL interface, it is assumed that the two interfaces are compatible. This is typically enforced and automated by Oracle JDeveloper.
Note:
Only use Oracle JDeveloper in Design view to create and modify the composite.xml
and spring context files described in this section. Do not directly edit these files in Source view. These examples are provided to show you how Java interfaces and WSDL files are integrated in a SOA composite application. Use of Oracle JDeveloper to achieve this functionality is described in subsequent sections of this chapter.
For example, assume you have a Java interface for a service, as shown in the following example:
public interface PortfolioService { public double getPorfolioValue(String portfolioId); }
Assume the implementation can use an additional StockQuote
service that is implemented by another component that may be an external web service, or an EJB. The following example provides details:
public interface StockQuote { public double getQuote (String symbol); }
The composite.xml
file for the spring framework lists the PortfolioService
service and the StockQuote
service with the interface.java
definitions. The following example provides details.
<component name="PortfolioComp"> <implementation.spring src="Spring/PortfolioComp.xml"/> <componentType> <service name="PortfolioService"> <interface.java interface="com.bigbank.PortfolioService"/> </service> <reference name="StockService"> <interface.java interface="com.bigbank.StockQuote"/> </reference> </componentType> </component>
The implementation class implements the service interface and provides a setter for the reference interface. The following example provides details:
public class PortfolioServiceImpl implements PortfolioService { StockQuote stockQuoteRef; public void setStockService (StockQuote ref) { stockQuoteRef = ref; } public double getPorfolioValue(String portfolioId) { //-- use stock service //-- return value } }
The spring context file calls out the services and references and binds them to the implementation. The following example provides details:
<beans ...> <sca:service name="PortfolioService" type="com.bigbank.PortfolioService" target="impl"> </sca:service> <sca:reference name="StockService" type="com.bigbank.StockQuote"> </sca:reference> <bean id ="impl" class ="com.bigbank.PortfolioServiceImpl"> <property name="stockService" ref="StockService"/> </bean> </beans>
55.2.2 Using Callbacks with the Spring Framework
Oracle SOA Suite uses callbacks for both interface.wsdl
and interface.java
. However, the concept of callbacks does not exist in the spring framework. For Oracle SOA Suite services and references, a callback is specified (in the metadata) as a second port type for interface.wsdl
or a second Java name for interface.java
. The spring metadata has only sca:services
and sca:references
and no way to specify a callback.
To design a callback with spring, you must provide sca:services
and sca:references
with a specific name. If you create both a sca:service
and sca:reference
using the naming conventions of some
Service
and some
ServiceCallback
, Oracle SOA Suite recognizes this convention and creates a single service or reference with a callback.
For example, assume you create the syntax shown in the following example in the spring context file with the spring editor in Oracle JDeveloper:
<sca:service name="StockService" type="oracle.integration.platform.blocks.java.callback.StockService" target="impl" /> <sca:reference name="StockServiceCallback" type="oracle.integration.platform.blocks.java.callback.StockServiceReply" />
Oracle SOA Suite automatically creates a single service as shown in the following example:
<service name="StockService">
<interface.java
interface="oracle.integration.platform.blocks.java.callback.StockService"
callbackInterface="oracle.integration.platform.blocks.java.callback.StockServiceRe
ply"/>
</service>
In the SOA Composite Editor, if a spring interface.java
with a callback interface is dragged to a WSDL component (for example, Oracle BPEL Process Manager, Oracle Mediator, or others), a WSDL with two port types is generated (technically, a wrapper WSDL, which is a WSDL that imports two other WSDLs, each having a single port type).
If you drag a WSDL or Java interface that has a callback to a spring service component, a single interface is displayed in the SOA Composite Editor. However, inside the spring editor, you find both a sca:service
and sca:reference
that have the same naming conventions (some
Service
and some
ServiceCallback
).
55.3 Creating a Spring Service Component in Oracle JDeveloper
This section describes how to create a spring service component and wire the component as follows in Oracle JDeveloper:
-
To Java interface-based EJB services and references (Java-to-Java integration)
-
To an Oracle Mediator service component (Java-to-WSDL integration)
55.3.1 How to Create a Spring Service Component in Oracle JDeveloper
To create a spring service component in Oracle JDeveloper:
-
From the Components window, drag a Spring service component into the SOA Composite Editor, as shown in Figure 55-1.
Figure 55-1 Spring Context Service Component
Description of "Figure 55-1 Spring Context Service Component"The Create Spring dialog is displayed.
-
In the Name field, enter a name for the spring service component. The name becomes both the component name and the spring context file name. Figure 55-2 provides details.
You can also select Use Existing Context and click Browse to select an existing spring file. For example, you may want to import a spring context that was created in Oracle JDeveloper, but outside of Oracle SOA Suite. If you browse and select a spring context from another project, it is copied to the SOA project.
Note:
A standalone spring version of WebLogic SCA is also available for use. This version is typically used outside of Oracle SOA Suite. This version is accessible by selecting Spring 2.5 JEE from the Components window while inside the spring editor.
-
Click OK.
A spring icon is displayed in the SOA Composite Editor.
-
If the contents are not automatically displayed, double-click the icon to display the contents of the spring context in the spring editor.
-
From the Components window, select Weblogic SCA from the dropdown list.
The list is refreshed to display the selections shown in Figure 55-3.
-
Drag a Service icon into the spring editor.
The Insert Service dialog appears.
-
Complete the fields shown in Table 55-1 to define the target bean and Java interface.
Table 55-1 Insert Service Dialog
Field Description name
Enter a name.
target
Enter the target bean. This action enables you to expose the bean as a service.
Note: Ensure that this target exists. There is no validation support that checks for the existence of this target.
type
Enter the Java interface.
When complete, the Insert Service dialog looks as shown in Figure 55-4.
-
Click OK.
The target bean becomes the service interface in the spring context.
<?xml version="1.0" encoding="UTF-8" ?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:util="http://www.springframework.org/schema/util" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:lang="http://www.springframework.org/schema/lang" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:sca="http://xmlns.oracle.com/weblogic/weblogic-sca" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms.xsd http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://xmlns.oracle.com/weblogic/weblogic-sca META-INF/weblogic-sca.xsd"> <!--Spring Bean definitions go here--> <sca:service name="scaserv1" target="cp" type="oracle.mypackage.myinterface"/> </beans>
If you close the spring editor and return to the SOA Composite Editor, you see that a handle has been added to the left side of the spring service component, as shown in Figure 55-5.
-
Return to the spring editor.
-
Drag a Reference icon from the list shown in Figure 55-3 into the spring editor.
The Insert Reference dialog is displayed.
-
Complete the dialog, as shown in Table 55-2, and click OK.
Table 55-2 Insert Reference Dialog
Field Description name
Enter a name.
type
Enter the Java interface.
When complete, the spring context displays the service and reference in the spring editor.
<?xml version="1.0" encoding="UTF-8" ?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:util="http://www.springframework.org/schema/util" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:lang="http://www.springframework.org/schema/lang" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:sca="http://xmlns.oracle.com/weblogic/weblogic-sca" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms.xsd http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://xmlns.oracle.com/weblogic/weblogic-sca META-INF/weblogic-sca.xsd"> <!--Spring Bean definitions go here--> <sca:service name="scaserv1" target="cp" type="oracle.mypackage.myinterface"/> <sca:reference name="scaref1" type="external.bean.myInterface"/> </beans>
-
Close the spring context file, as shown in Figure 55-6.
A handle is added to the right side of the spring service component, as shown in Figure 55-7.
-
Drag the left handle into the Exposed Services swimlane to create a service binding component, as shown in Figure 55-8.
You are prompted to select to expose the service as either a web service or as an EJB service, as shown in Figure 55-9.
-
EJB: This exposes the EJB service through a Java interface; this selection does not require the use of a WSDL file.
-
Web Service: This exposes the web service through a SOAP WSDL interface. If you select this option, a WSDL is generated from the Java Interface for compatibility with the spring service component.
-
-
Select to expose this service as either an EJB or web service. A service is automatically created in the Exposed Services swimlane and wired to the spring service component (for this example, EJB is selected). Figure 55-10 provides details.
Figure 55-10 EJB Service Binding Component Wired to the Spring Service Component
Description of "Figure 55-10 EJB Service Binding Component Wired to the Spring Service Component" -
Double-click the EJB service to display the automatically completed configuration, as shown in Figure 55-11. The configuration details were created from the values you entered in the Insert Service dialog in Step 7.
Figure 55-11 EJB Service Dialog in Exposed Services Swimlane
Description of "Figure 55-11 EJB Service Dialog in Exposed Services Swimlane" -
Replace the default JNDI name that was automatically generated with the name applicable to your environment.
-
Close the dialog.
-
Drag the right handle of the spring service component into the External References swimlane to create a reference binding component.
You are prompted with the same spring type option message as shown in Step 13.
-
Select an option to expose this reference. A reference is automatically created in the External References swimlane and wired to the spring service component (for this example, EJB is selected). Figure 55-12 provides details.
Figure 55-12 EJB Reference Binding Component Wired to the Spring Service Component
Description of "Figure 55-12 EJB Reference Binding Component Wired to the Spring Service Component" -
Double-click the EJB reference to display the automatically completed configuration, as shown in Figure 55-13. The configuration details were created from the values you entered in the Insert Reference dialog in Step 11.
Figure 55-13 EJB Reference Dialog in External References Swimlane
Description of "Figure 55-13 EJB Reference Dialog in External References Swimlane" -
Close the dialog and return to the SOA Composite Editor, as shown in Figure 55-14.
Figure 55-14 Java Interface-Based EJB Service and Reference Binding Components
Description of "Figure 55-14 Java Interface-Based EJB Service and Reference Binding Components" -
Place the cursor over both the right handle of the service (as shown in Figure 55-15) and the left handle of the spring service component (as shown in Figure 55-16). The Java interface is displayed.
Figure 55-16 Java Interface of Spring Service Component
Description of "Figure 55-16 Java Interface of Spring Service Component" -
Perform the same action on the right handle of the spring service component and the left handle of the reference binding component to display its Java interface.
-
Select Source view for the
composite.xml
file to display similar details.<?xml version="1.0" encoding="UTF-8" ?> <!-- Generated by Oracle SOA Modeler version 12.1.3.0.0 at [5/16/14 3:05 AM]. --> <composite name="Project1" . . . . . . <service name="scaserv1"> <interface.java interface="oracle.mypackage.myinterface"/> <binding.ejb uri="scaserv1_ejb_ep" ejb-version="EJB3"/> </service> <property name="productVersion" type="xs:string" many="false">12.1.3.0.0</property> <property name="compositeID" type="xs:string" many="false">4c07dbf0-5c01-450e-bde6-8c3866f45edc</property> <component name="MySpring"> <implementation.spring src="Spring/MySpring.xml"/> <componentType> <service name="scaserv1"> <interface.java interface="oracle.mypackage.myinterface"/> </service> <reference name="scaref1"> <interface.java interface="external.bean.myInterface"/> </reference> </componentType> </component> <reference name="scaref1"> <interface.java interface="external.bean.myInterface"/> <binding.ejb uri="scaref1_ejb_ep" ejb-version="EJB3"/> </reference> <wire> <source.uri>scaserv1</source.uri> <target.uri>MySpring/scaserv1</target.uri> </wire> <wire> <source.uri>MySpring/scaref1</source.uri> <target.uri>scaref1</target.uri> </wire> </composite>
-
If you wire the right handle of the spring service component to an XML-based component such as Oracle Mediator instead of the Java interface-based EJB reference, a Java interface is generated from the Oracle Mediator's existing WSDL interface. The following steps provide details.
-
Drag the right handle of the spring service component to the Oracle Mediator, as shown in Figure 55-17.
Figure 55-17 Integration of Spring Service Component and Oracle Mediator
Description of "Figure 55-17 Integration of Spring Service Component and Oracle Mediator" -
Click OK when prompted to acknowledge that a compatible interface was created from the Oracle Mediator WSDL file.
Figure 55-18 Java File Creation from the Oracle Mediator WSDL File
Description of "Figure 55-18 Java File Creation from the Oracle Mediator WSDL File"If you drag a wire between a Java interface and a WSDL-based component, and the WSDL file with the default name (based on the Java Interface name) already exists, you are prompted with four options. Click Cancel to cancel creation of the wire. Figure 55-19 provides details.
-
Place the cursor over both the right handle of the spring service component (as shown in Figure 55-20) and the left handle of the Oracle Mediator (as shown in Figure 55-21) to display the compatible interface.
Figure 55-20 Spring Service Component Interface
Description of "Figure 55-20 Spring Service Component Interface" -
Double-click the spring service component to display the contents of the spring context file in the spring editor.
<?xml version="1.0" encoding="windows-1252" ?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:util="http://www.springframework.org/schema/util" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:lang="http://www.springframework.org/schema/lang" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:sca="http://xmlns.oracle.com/weblogic/weblogic-sca" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool-2.5.xsd http://xmlns.oracle.com/weblogic/weblogic-sca META-INF/weblogic-sca.xsd"> <!--Spring Bean defintions go here--> <sca:service name="scaserv1" target="ep" type="oracle.mypackage.myinterface"/> <sca:reference type="mediator1.project1.application4.com.oracle.xmlns.Execute_ ptt" name="Mediator1.Mediator1"/> </beans>
-
Note:
-
When integrating a component that uses a Java interface with a component that uses a WSDL file in the SOA Composite Editor, if a specific interface class is not found in the classpath (including the JAR files in the
SCA-INF/lib
directory), but the source file does exist in the SOA project, you are prompted to automatically compile the source. -
You can also create BPEL process partner links with services that use Java interfaces. You select this type of service in the Service Explorer dialog when creating a partner link. For more information, see Introduction to Partner Links.
55.3.2 What You May Need to Know About Java Class Errors During Java-to-WSDL Conversions
When a Java-to-WSDL conversion fails because of a bad Java class and you modify the Java code to correct the problem, you must restart Oracle JDeveloper. Not doing so results in a Java-to-WSDL conversion failure because the new class is not reloaded.
55.4 Defining Custom Spring Beans Through a Global Spring Context
You can define custom spring beans through a global spring context definition. This configuration enables you to define these beans only once, at the global level.
55.4.1 How to Define Custom Spring Beans Through a Global Spring Context
To define custom spring beans through a global spring context:
For more information, see the readme.txt
file located in the following directory:
SOA_HOME/soa/modules/oracle.soa.ext_11.1.1
Note:
A server restart is required to pick up newly added spring beans.
55.5 Using the Predefined Spring Beans
Oracle SOA Suite provides the following predefined spring beans:
-
headerHelperBean
: For getting and setting header properties. -
instanceHelperBean
: For getting the following information:-
The instance ID of the flow instance currently running.
-
The instance ID of the component instance currently running.
-
The composite distinguished name (DN) containing the component.
-
The name of the spring service component.
-
-
loggerBean
: For providing context-aware logging messages.
The predefined spring beans are automatically injected into the spring service component. However, you must explicitly integrate the predefined spring beans into a SOA composite application by providing a reference to the bean in the spring context file.
For an example of how to reference loggerBean
and headerHelperBean
in a spring context file, see How to Reference Predefined Spring Beans in the Spring Context File.
55.5.1 IHeaderHelperBean.java Interface for headerHelperBean
The following example shows the IHeaderHelperBean.java
interface for the headerHelperBean
bean:
package oracle.soa.platform.component.spring.beans; /** * Interface for getting and setting header properties. * These properties will be set on the normalized message - and passed on * to the respective reference that the local reference is wired to on * composite level. * <br/> * To use this bean from within your context, declare property * with ref="headerHelperBean". E.g. * <property name="headerHelper" ref="<b>headerHelperBean</b>"/> */ public interface IHeaderHelperBean { /** * Get a property from the normalized message header. Note that these * properties are defined, and are the same ones, one can get/set via * mediator or bpel process * @param pKey the property key, case sensitive * @return the value, or null in case not found */ public String getHeaderProperty (String pKey); /** * Set a property on the normalized message header. Note that these * properties are defined, and are the same ones, one can get/set via * mediator or bpel process * @param pKey the property key, case sensitive * @param pValue the value to be set */ public void setHeaderProperty (String pKey, String pValue); }
55.5.2 IInstanceHelperBean.java Interface for instancerHelperBean
The following example shows the IInstanceHelperBean.java
interface for the instanceHelperBean
bean:
package oracle.soa.platform.component.spring.beans; import oracle.integration.platform.instance.engine.ComponentInstanceContext; /** * Instancehelper Bean, gives access to composite / component + instance information * <br/> * To use this bean from within your context, declare property * with ref="instanceHelperBean". E.g. * <property name="instanceHelper" ref="<b>instanceHelperBean</b>"/> */ public interface IInstanceHelperBean { /** * Returns the instance id of the composite instance currently running * @return the composite instance id */ public String getCompositeInstanceId (); /** * Returns the instance id of the component instance currently running * @return the component instance id */ public String getComponentInstanceId (); /** * Returns the composite dn containing this component * @return the composite dn */ public String getCompositeDN (); /** * Returns the name of this spring component * @return the component name */ public String getComponentName (); }
55.5.3 ILoggerBean.java Interface for loggerBean
The following example shows the ILoggerBean.java
interface for the loggerBean
bean:
package oracle.soa.platform.component.spring.beans; import java.util.logging.Level; /** * Logger bean interface, messages will be logged as * [<composite instance id>/<component instance id>] <message> * <br/> * To use this bean from within your context, declare property * with ref="loggerBean". E.g. * <property name="logger" ref="<b>loggerBean</b>"/> */ public interface ILoggerBean { /** * Log a message, with Level.INFO * @param message */ public void log (String message); /** * Log a message with desired level * @param pLevel the log level * @param message the message to log */ public void log (Level pLevel, String message); /** * Log a throwable with the desired level * @param level the level to log with * @param message the message * @param th the exception (throwable) to log */ public void log (Level level, String message, Throwable th); }
55.6 JAXB and OXM Support
Oracle Fusion Middleware provides support for using JAXB and EclipseLink OXM to map Java classes to XML data. You can store and retrieve data in memory in any XML format without implementing a specific set of XML routines for the program's class structure. This support enables you to perform the following:
-
Map Java objects to XML data
-
Map XML data back to Java objects
For design information about external metadata for JAXB mappings, visit the following URL:
http://wiki.eclipse.org/EclipseLink/DesignDocs/277920
For information about JAXB OXM and the OXM mapping file (eclipselink-oxm.xsd
), visit the following URLs:
http://wiki.eclipse.org/EclipseLink/FAQ/WhatIsMOXy
http://wiki.eclipse.org/EclipseLink/Examples/MOXy
http://wiki.eclipse.org/Category:XML
You can also map Java classes to XML data when integrating an EJB with SOA composite applications. For more information, see Integrating Enterprise JavaBeans with Composite Applications .
55.6.1 Extended Mapping Files
Oracle SOA Suite extends JAXB and OXM file support through use of an extended mapping (EXM) file. If an EXM file is present in the class path of the design time project, then it can be used for Java-to-WSDL conversions. The EXM file provides data binding metadata in the following situations:
-
When you cannot add the JAXB annotations into the Java source and must specify them separately
-
When scenarios are not covered by JAXB (for example, with top level elements like method return types or parameter types)
The external JAXB annotations can be specified either directly in the EXM file or included in the separate TopLink JAXB mapping OXM file that can be referred to from the EXM file.
The EXM file name must match the Java class name and reside in the same package location. For example, if the Java class is named pack1.pack2.myJavaInterface.class
, the EXM file must be named pack1/pack2/myJavaInterface.exm
.
Oracle SOA Suite design time supports placing the EXM file in either the source path (SCA-INF/src
) or the class path (SCA-INF/classes
or a JAR in SCA-INF/lib
).
Placing the EXM file in the source path (SCA-INF/src
) enables you to edit the EXM using Oracle JDeveloper (files in the class path do not appear in the Applications window in Oracle JDeveloper). When project compilation is complete, the EXM file (and any XML files that it imports) is copied to the class path (SCA-INF/classes
) for deployment. If the EXM file is in the source path, it must still be in the same corresponding directory structure.
If you place the EXM (and OXM) files in SCA-INF/src
, ensure that your Oracle JDeveloper project is configured so that SCA-INF/src
is the default source directory (right-click the project name, and select Project Properties > Java Source Paths). EXM files can also be found in JAR files that are in the project's class path.
When you drag and drop a Java interface (Enterprise JavaBeans) to a BPEL process, Oracle SOA Suite checks to see if the EXM file exists. If it does, it is passed to the web services java2wsdl
API.
After the WSDL file is generated, an informational message is displayed. If an EXM file was used, the message displayed takes the following format:
The WSDL file {0} was generated based on the JAVA class {1} using extended mapping file {2}
The following provides an example of an EXM file:
<java-wsdl-mapping name="com.hello.sei.MyServiceEndpointInterface" xmlns="http://xmlns.oracle.com/weblogic/weblogic-wsee-databinding" xmlns:oxm="http://www.eclipse.org/eclipselink/xsds/persistence/oxm" databinding="toplink.jaxb"> <xml-schema-mapping> <toplink-oxm-file java-package="com.hello.foo" file-path="./foo-oxm.xml"/> <toplink-oxm java-package="com.hello.coo"> <xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"> <xml-schema element-form-default="QUALIFIED" attribute-form-default="UNQUALIFIED" namespace="urn:customer"> <xml-ns prefix="ns1" namespace-uri="urn:customer" /> </xml-schema> <java-types> <java-type name="Person" xml-transient="true"> <java-attributes> <xml-transient java-attribute="id"/> </java-attributes> </java-type> <java-type name="Customer"> <xml-see-also>org.example.employee.Employee</xml-see-also> </java-type> </java-types> </xml-bindings> </toplink-oxm> </xml-schema-mapping> . . . </java-wsdl-mapping>
The EXM schema file for external mapping metadata for the data binding framework is available at the following URL:
http://www.oracle.com/technology/weblogic/weblogic-wsee-databinding/1.1/weblogic-wsee-databinding.xsd
The data defines the attributes of a particular Java web service endpoint. This schema defines three types of XML constructs:
-
Constructs that are analogous to JAX-WS or JSR-181 that override or define attributes on the service endpoint interface (SEI) and JAXB annotations for the value types used in the interfaces of the SEI.
-
Additional mapping specifications not available using standard JAX-WS or JAXB annotations, primarily for use with the
java.util.Collections
API. -
References to external JAXB mapping metadata from a Toplink OXM file.
When a construct is the direct analog of a JAX-WS, JSR-181, or JAXB annotation, the comment in the schema contains a notation such as:
Corresponding Java annotation: javax.jws.WebParam.Mode
55.7 Configuring Groovy and Aspectj Classes with the Spring Service Component
If you configure a Groovy or Aspectj class in the spring configuration file, you must follow these conventions:
-
Use the
classpath
protocol:script-source="classpath:"
Using a relative file path is not possible because the SCA package is not treated as a regular JAR file for the class loader. For example, the following
classpath
protocol indicates to find the Groovy file from the class path.script-source="classpath:service/GroovyGreeter.groovy"
-
Add Groovy and Aspectj files in any of the following directories when using the
classpath
protocol. No other directories are possible.-
SCA-INF/classes
-
SCA-INF/lib
-
Shared SOA
lib
If your build scripts are configured to clean the
classes
directory, either put the Groovy files in theSCA-INF/lib
directory or design your build scripts to prevent cleaning. -
-
Add spring extension JAR file libraries for Groovy or Aspectj to the class path of the managed server's
setDomainENV.sh
orsetDomainENV.bat
file and restart the server. This ensures that deployment is successful. The restart is required because spring uses Java reflection to instantiate aspect-oriented programming (AOP). The use of reflection restricts the search for classes to the system class loader. Any changes to the system class loader require a server restart.
55.8 Troubleshooting Spring Errors
This section describes how to troubleshoot errors with the spring service component.
55.8.1 Spring Bean Interface to Invoke Cannot Be Found
Assume you have a SOA composite application in which a BPEL process invokes a spring context. However, the spring bean interface to invoke cannot be found. The administration server diagnostic log file displays the error shown in the following example:
[2012-04-09T10:30:07.499-07:00] [AdminServer] [NOTIFICATION] [SOA-31704] [oracle.integration.platform.blocks.java] [tid: [ACTIVE].ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: <anonymous>] [ecid: 11d1def534ea1be0:2058db3f:1369787a1b8:-8000-0000000000002be6,0:2] [WEBSERVICE_ PORT.name: SOACohSpringBPELProcess_pt] [APP: soa-infra] [composite_name: SOACohSpringProj] [component_name: SOACohSpringBPELProcess] [component_instance_ id: 270006] [J2EE_MODULE.name: fabric] [WEBSERVICE.name: soacohspringbpelprocess_ client_ep] [J2EE_APP.name: soa-infra] No mapping found for class SOACohSpringProj.CohEJBInterface.
Ensure that you deploy the JAR file containing the class into the SCA-INF/lib
directory or the classes into the SCA-INF/classes
directory of the SAR file.
55.8.2 Unable to Add a Spring Service Component in the SOA Composite Editor
The Oracle SOA Suite Quick Start installation automatically includes the spring extension files for invoking the spring editor. This enables you to successfully add a spring service component in the SOA Composite Editor and invoke the Create Spring dialog, as described in How to Create a Spring Service Component in Oracle JDeveloper.
If you use the standard Oracle JDeveloper installation outside of Oracle SOA Suite, you must install the spring editor by selecting Check for Updates from the Help main menu in Oracle JDeveloper, then selecting the spring extension files in the Update Center. Otherwise, you cannot successfully add a spring service component into the SOA Composite Editor and invoke the Create Spring dialog. Instead, you receive the error shown in Figure 55-22.