IT技术及科技前沿

中文IT博客,为IT专业技术人员提供最全面的信息传播和服务

首页 新随笔 订阅 管理
  • Resource adapters can be classified into three categories: outbound, inbound and bi-directional. Previous article has shown you how to deal with outbound case. In this article, we will teach you how to deal with inbound case. It would be easy to understand how to deal with bi-directional case after reading outbound case and inbound case.

     

    l       Mapping for Inbound Case

    In inbound case, data flows from EIS to application server through adapters. According to connector 1.5 specification, an adapter can deliver inbound messages to MDB. This requires application server to provide its solution to associate the MDB with adapter. On OC4J, such association is defined in orion-ejb-jar.xml, while on WebLogic in weblogic-ejb-jar.xml. orion-ejb-jar.xml also contains configuration of activation spec.

     

    Furthermore, it is normally necessary to define one or more admin objects in inbound case, such as the Queue, Topic etc. These admin object instances are defined in oc4j-connectors.xml on OC4J, and in weblogic-ra.xml on WebLogic.

     

    You may have noticed that there is just one single descriptor file, weblogic-ra.xml, used on WebLogic for both inbound and outbound adapter. This is different on OC4J where 2 files are used: oc4j-ra.xml and oc4j-connectors.xml.

     

    The mapping from OC4J to WebLogic involves 2 steps: fist, map oc4j-connectors.xml to weblogic-ra.xml; second, map orion-ejb-jar.xml to weblogic-ejb-jar.xml and ejb-jar.xml.

     

     

    l       Map oc4j-connectors.xml

    Let's map oc4j-connectors.xml to weblogic-ra.xml first.

    Here is a sample oc4j-connectors.xml descriptor of OC4J which shows a typical configuration for inbound. For standalone adapters, there is one single global file existing for all standalone adapters, and the default location is j2ee/<instance>/config/oc4j-connectors.xml.

    <?xml version="1.0" encoding="UTF-8"?>

     

    <oc4j-connectors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xmlns.oracle.com/oracleas/schema/oc4j-connectors-10_0.xsd" schema-major-version="10" schema-minor-version="0" >

               <connector name="fooConnector" path="fooConnector.rar">

                         <adminobject-config location="eis/MyAdminObject">

                                    <adminobject-class>foo.AdminObjImpl</adminobject-class>

                                    <config-property name="host" value="localhost"/>

                                    <config-property name="port" value="1234"/>

                         </adminobject-config>

               </connector>

     

    </oc4j-connectors>

     

    Each adminobject-config element defines an admin object instance. It should be mapped to weblogic-connector\admin-objects\admin-object-group\admin-object-instance element on WebLogic. Note: One different is that each admin object instance is identified by adminobject-class on OC4J but by admin-object-interface on WebLogic. So it is necessary to check ra.xml to find out the corresponding adminobject-interface value. This difference is caused by the fact that Connector 1.5 specification doesn't define uniqueness of admin object. In the latest Connector 1.6 specification, it is clarified that the combination of adminobject-interface and adminobject-class must be unique in ra.xml.

     

    The location attribute defines where the admin object instance will be bind to JNDI. This should be mapped to admin-object-instance\jndi-name element on WebLogic.

     

    Each property of this admin object instance is defined by a config-property element. It can be mapped to admin-object-instance\ properties\ property element

     

    Here is the result after performing above mapping, and the result file should be packaged as META-INF\weblogic-ra.xml in the RAR file.

    <weblogic-connector xmlns="http://www.bea.com/ns/weblogic/90">

               <jndi-name>fooConnector</jndi-name>

               <enable-global-access-to-classes>true</enable-global-access-to-classes>

              

               <admin-objects>

                         <admin-object-group>

                                    <admin-object-interface>foo.AdminObjIntf</admin-object-interface>

                                    <admin-object-instance>

                                              <jndi-name>eis/MyAdminObject</jndi-name>

                                              <properties>

                                                         <property>

                                                                   <name>host</name>

                                                                   <value>localhost</value>

                                                         </property>

                                                         <property>

                                                                   <name>port</name>

                                                                   <value>1234</value>

                                                         </property>

                                              </properties>

                                    </admin-object-instance>

                         </admin-object-group>

               </admin-objects>   

     

    </weblogic-connector>

     

    l       Map orion-ejb-jar.xml

    Now let's do the second step, map orion-ejb-jar.xml to weblogic-ejb-jar.xml.

     

    Here is a sample orion-ejb-jar.xml descriptor of OC4J which associates MDB with adapter, and defines 2 properties for activation spec. It should be packaged as META-INF\orion-ejb-jar.xml in the MDB's jar file.

    <?xml version="1.0" encoding="utf-8"?>

    <orion-ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xmlns.oracle.com/oracleas/schema/orion-ejb-jar-10_0.xsd">

          <enterprise-beans>

                <message-driven-deployment name="myMDB" destination-location="ejb/myMDB" resource-adapter="fooConnector">

                                    <config-property>

                                               <config-property-name>host</config-property-name>

                                               <config-property-value>192.168.1.1</config-property-value>

                                    </config-property>

                                    <config-property>

                                               <config-property-name>port</config-property-name>

                                               <config-property-value>2001</config-property-value>

                                    </config-property>

                </message-driven-deployment>

          </enterprise-beans>

    </orion-ejb-jar>

    The key element is resource-adapter="fooConnector" which specifies the adapter with which this MDB should associate. You may have noticed that "fooConnector" is the name of the connector, either defined by name="fooConnector" in oc4j-connectors.xml, or by connector-name="fooConnector" in oc4j-ra.xml. WebLogic takes different approach with OC4J. On WebLogic, adapter can be bound to JNDI using element weblogic-connector\jndi-name, and MDB can specify the JNDI name of the adapter that it wants to associate with using element weblogic-enterprise-bean\message-driven-descriptor\resource-adapter-jndi-name.

     

    Each config-property element defines one name/value for a property of the activation spec for this MDB. These values are used to override the values defined in enterprise-beans\message-driven\activation-config\activation-config-property elements in ejb-jar.xml. WebLogic doesn't support such override now and just uses values defined in ejb-jar.xml. So in above case, the ejb-jar.xml contained in MDB jar must be modified to take the value defined in orion-ejb-jar.xml.

     

    Here is the result weblogic-ejb-jar.xml after performing above mapping, and the result file should be packaged as META-INF\weblogic-ejb-jar.xml in the MDB jar file.

    <?xml version = "1.0" encoding = "UTF-8"?>

    <weblogic-ejb-jar xmlns="http://xmlns.oracle.com/weblogic/weblogic-ejb-jar" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-ejb-jar" http://xmlns.oracle.com/weblogic/weblogic-ejb-jar/1.0/weblogic-ejb-jar.xsd ">

               <weblogic-enterprise-bean>

                         <ejb-name>myMDB</ejb-name>

                         <message-driven-descriptor>

                                    <resource-adapter-jndi-name>fooConnector</resource-adapter-jndi-name>

                         </message-driven-descriptor>

                         <jndi-name>ejb/myMDB</jndi-name>

               </weblogic-enterprise-bean>

    </weblogic-ejb-jar>

     

    Here is the ejb-jar.xml which contains the values of activation spec defined in orion-ejb-jar.xml, and the file should be packaged as META-INF\ ejb-jar.xml in the MDB jar file. 

    <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" version="3.0" >

    <enterprise-beans>

                      <message-driven>

                               <ejb-name>myMDB</ejb-name>

                               <ejb-class>foo.MyMDBImpl</ejb-class>

                               <messaging-type>foo.MyMessageLisener</messaging-type>

                               <transaction-type>Container</transaction-type>

                               <activation-config>

                                        <activation-config-property>

                                                 <activation-config-property-name>host</activation-config-property-name>

                                                  <activation-config-property-value>192.168.1.1</activation-config-property-value>

                                        </activation-config-property>

                                        <activation-config-property>

                                                 <activation-config-property-name>port</activation-config-property-name>

                                                 <activation-config-property-value>2001</activation-config-property-value>

                                        </activation-config-property>

                               </activation-config>

     ...

                      </message-driven>

             </enterprise-beans>

    </ejb-jar>

     

     

    After performing above steps, the mapping for inbound case completes.

     

    l       Mapping for Bi-Directional Case

    If the adapter is bi-directional that supports both outbound and inbound, there will be 3 descriptors on OC4J:

    n       oc4j-ra.xml, for outbound, inside RAR

    n       oc4j-connectors.xml, for inbound, inside RAR

    n       orion-ejb-jar.xml, for inbound, inside MDB JAR

     

    They should be mapped to 3 descriptors on WebLogic:

    n       weblogic-ra.xml, for both outbound and inbound, inside RAR

    n       weblogic-ejb-jar.xml, for inbound, inside MDB JAR

    n       ejb-jar.xml, for activation spec configurations of inbound, inside MDB JAR

     

    You can figure out how to do mapping easily based on the information in outbound section and inbound section.

     

     

    l       Reference

    Detailed information on configuring and developing resource adapters on WebLogic is available at Programming Resource Adapters for Oracle WebLogic Server. You can find detailed explanation for weblogic-ra.xml schema in appendix "A. weblogic-ra.xml Schema"

     

    Information on MDB is available at Programming Enterprise JavaBeans for Oracle WebLogic Server and Programming Enterprise JavaBeans, Version 3.0 for Oracle WebLogic Server

    posted on 2010-12-25 13:23  孟和2012  阅读(245)  评论(0编辑  收藏  举报