This blog is a primer on the new Weblogic SCA container introduced as a tech preview in Weblogic.
Like POJOs way too much and don't like the heavy weight JEE for application assembly? Good news is that Weblogic now houses a new SCA container! You can forever remain oblivious to nitty-gritty details of EJBs and Webservices and hide in the comfort of SCA bindings.
The SCA runtime is installed by default, but the container is imported as a shared library by SCA applications, so one needs to deploy the shared library into Weblogic first. This can be done via the command line:
java weblogic.Deployer -username <uname> -password <passwd> -deploy -library $WL_HOME/common/deployable-libraries/weblogic-sca-1.0.war
One can also use the Administration Console - remember to choose the Install this deployment as a library option.
SCA applications have three main parts:
1. POJO classes (instead of EJBs or Webservices), that house the business logic
2. A spring context file that wires up the POJOs, and declares SCA services/references with appropriate bindings
3. weblogic.xml (for WARs) or weblogic-application.xml (for EARs) where the weblogic-sca shared library is imported
Note that there is no explicit SCDL file. The spring context file itself accomodates the bindings. The coolest part is that the same spring context file and POJO classes, with no changes, can act as a component in a larger composite in Oracle SOA. So if you like some BPEL artifacts thrown into your application, you'll typically upgrade to Oracle SOA, but there is no need to discard or even rewrite the POJO artifacts! In Oracle SOA, there is an explicit SCDL file where bindings are declared, so the bindings in the spring context file will be moot though.
Lets take a typical JEE shopping cart application: ShoppingCartEJB making use of a helper class, which in turn making use of an external webservice. SCA can achieve this using plain POJOs, or beans in Spring parlance. So, we need two beans, a CartImpl class and a CartHelperImpl class. The POJO class CartImpl can be exposed as a SCA service using the sca:service element in the spring context file. This service will function the same as the ShoppingCartEJB via a binding.ejb. The POJO class CartHelperImpl requires an external WS reference. Note how this is referred to just like another bean. For a reference with a binding.ws, the type used must be a JAX-WS compatible interface, generated from the external WSDL using a tool such as Weblogic clientgen.
Sample spring-context.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sca="http://xmlns.oracle.com/weblogic/weblogic-sca"
xmlns:wlsb="http://xmlns.oracle.com/weblogic/weblogic-sca-binding"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://xmlns.oracle.com/weblogic/weblogic-sca
http://xmlns.oracle.com/weblogic/weblogic-sca/1.0/weblogic-sca.xsd
http://xmlns.oracle.com/weblogic/weblogic-sca-binding
http://xmlns.oracle.com/weblogic/weblogic-sca-binding/1.0/weblogic-sca-binding.xsd">
<sca:service name="CartService" type="my.org.Cart" target="Cart">
<wlsb:binding.ejb uri="/ShoppingCartEJB"/>
</sca:service>
<bean id="Cart" class="my.org.CartImpl">
<property name="helper" ref="CartHelper"/>
</bean>
<bean id="CartHelper" class="my.org.CartHelperImpl">
<property name="wsref" ref="CartReference"/>
</bean>
<sca:reference name="CartReference" type="my.org.CartRef">
<wlsb:binding.ws uri="/ShoppingCartEJB"/>
</sca:reference>
</beans>
How does Weblogic know that this is a SCA application and not a regular Spring application? The key is the shared library import in weblogic-application.xml or weblogic.xml. This makes it a SCA application, and the container will look for META-INF/jsca/spring-context.xml resource.
Sample weblogic.xml:
<?xml version="1.0" encoding="UTF-8859-1"?>
<weblogic-application xmlns="http://www.bea.com/ns/weblogic/90">
<library-ref>
<library-name>weblogic-sca</library-name>
</library-ref>
</weblogic-application>
Sample Spring SCA application WAR:
WEB-INF/web.xml
WEB-INF/weblogic.xml
WEB-INF/lib/spring.jar
WEB-INF/lib/commons-logging.jar
WEB-INF/lib/MyScaClasses.jar
META-INF/jsca/spring-context.xml
my/org/Cart
my/org/CartImpl
my/org/CartHelper
my/org/CartHelperImpl
my/org/CartRef
This SCA application can be deployed into WLS:
java weblogic.Deployer -username <uname> -password <passwd> -deploy samplescaapp.war
Again, the Adminstration Console can be used here as well.
Weblogic SCA container will consume this WAR file, and CartImpl will mimic the ShoppingCartEJB behavior to the outside world.
Like POJOs way too much and don't like the heavy weight JEE for application assembly? Good news is that Weblogic now houses a new SCA container! You can forever remain oblivious to nitty-gritty details of EJBs and Webservices and hide in the comfort of SCA bindings.
The SCA runtime is installed by default, but the container is imported as a shared library by SCA applications, so one needs to deploy the shared library into Weblogic first. This can be done via the command line:
java weblogic.Deployer -username <uname> -password <passwd> -deploy -library $WL_HOME/common/deployable-libraries/weblogic-sca-1.0.war
One can also use the Administration Console - remember to choose the Install this deployment as a library option.
SCA applications have three main parts:
1. POJO classes (instead of EJBs or Webservices), that house the business logic
2. A spring context file that wires up the POJOs, and declares SCA services/references with appropriate bindings
3. weblogic.xml (for WARs) or weblogic-application.xml (for EARs) where the weblogic-sca shared library is imported
Note that there is no explicit SCDL file. The spring context file itself accomodates the bindings. The coolest part is that the same spring context file and POJO classes, with no changes, can act as a component in a larger composite in Oracle SOA. So if you like some BPEL artifacts thrown into your application, you'll typically upgrade to Oracle SOA, but there is no need to discard or even rewrite the POJO artifacts! In Oracle SOA, there is an explicit SCDL file where bindings are declared, so the bindings in the spring context file will be moot though.
Lets take a typical JEE shopping cart application: ShoppingCartEJB making use of a helper class, which in turn making use of an external webservice. SCA can achieve this using plain POJOs, or beans in Spring parlance. So, we need two beans, a CartImpl class and a CartHelperImpl class. The POJO class CartImpl can be exposed as a SCA service using the sca:service element in the spring context file. This service will function the same as the ShoppingCartEJB via a binding.ejb. The POJO class CartHelperImpl requires an external WS reference. Note how this is referred to just like another bean. For a reference with a binding.ws, the type used must be a JAX-WS compatible interface, generated from the external WSDL using a tool such as Weblogic clientgen.
Sample spring-context.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sca="http://xmlns.oracle.com/weblogic/weblogic-sca"
xmlns:wlsb="http://xmlns.oracle.com/weblogic/weblogic-sca-binding"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://xmlns.oracle.com/weblogic/weblogic-sca
http://xmlns.oracle.com/weblogic/weblogic-sca/1.0/weblogic-sca.xsd
http://xmlns.oracle.com/weblogic/weblogic-sca-binding
http://xmlns.oracle.com/weblogic/weblogic-sca-binding/1.0/weblogic-sca-binding.xsd">
<sca:service name="CartService" type="my.org.Cart" target="Cart">
<wlsb:binding.ejb uri="/ShoppingCartEJB"/>
</sca:service>
<bean id="Cart" class="my.org.CartImpl">
<property name="helper" ref="CartHelper"/>
</bean>
<bean id="CartHelper" class="my.org.CartHelperImpl">
<property name="wsref" ref="CartReference"/>
</bean>
<sca:reference name="CartReference" type="my.org.CartRef">
<wlsb:binding.ws uri="/ShoppingCartEJB"/>
</sca:reference>
</beans>
How does Weblogic know that this is a SCA application and not a regular Spring application? The key is the shared library import in weblogic-application.xml or weblogic.xml. This makes it a SCA application, and the container will look for META-INF/jsca/spring-context.xml resource.
Sample weblogic.xml:
<?xml version="1.0" encoding="UTF-8859-1"?>
<weblogic-application xmlns="http://www.bea.com/ns/weblogic/90">
<library-ref>
<library-name>weblogic-sca</library-name>
</library-ref>
</weblogic-application>
Sample Spring SCA application WAR:
WEB-INF/web.xml
WEB-INF/weblogic.xml
WEB-INF/lib/spring.jar
WEB-INF/lib/commons-logging.jar
WEB-INF/lib/MyScaClasses.jar
META-INF/jsca/spring-context.xml
my/org/Cart
my/org/CartImpl
my/org/CartHelper
my/org/CartHelperImpl
my/org/CartRef
This SCA application can be deployed into WLS:
java weblogic.Deployer -username <uname> -password <passwd> -deploy samplescaapp.war
Again, the Adminstration Console can be used here as well.
Weblogic SCA container will consume this WAR file, and CartImpl will mimic the ShoppingCartEJB behavior to the outside world.