Sample04 for Weblogic - MDB Samples

0. Prerequisite


This case is for MDB, we still use "weblogic.examples.ejb30.QueueConnectionFactory" which is created in Weblogic examples, and add a new Queue, whose name and JNDI name are both "jms/ShippingRequestQueue".


1. Customize code in chapter4


$ cd $HOME/student/ejbAction

$ cd chapter4

$ for i in `find * -name "*.orig"`; do j=`expr $i :'\(.*\).orig'`; echo diff -u $i $j; diff -u $i $j; echo; echo; done


diff -u build.xml.orig build.xml

...

+ <target name="db-setup" depends="init"description="Database setup for Derby">

+ <sql driver="${derby.driver}"

+ url="${derby.url}"

+ userid="${derby.username}" password="${derby.password}"

+ οnerrοr="continue"

+ print="yes"

+ src="sql/tables.sql"/>

+ </target>

...

<classpath>

<pathelement location="${lib.dir}/${cli.name}.jar"/>

<pathelement location="${bld.ejb.dir}"/>

- <pathelement location="${WLS_HOME}/server/lib/wljmsclient.jar"/>

+ <pathelement location="${WLS_HOME}/server/lib/weblogic.jar"/>

</classpath>

</java>


diff -u etc/jndi.properties.orig etc/jndi.properties

...

#Set required appropriate for your environment

java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory

-java.naming.provider.url=t3://localhost:7001

+java.naming.provider.url=t3://localhost:8001


diff -u sql/tables.sql.orig sql/tables.sql

...

-create table SHIPPING_REQUESTS(

-ITEM_IDnumber(19),

-SHIPPING_ADDRESSvarchar2(255),

-SHIPPING_METHODvarchar2(255),

-INSURANCE_AMOUNTnumber(20,4))

-/

+drop table SHIPPING_REQUESTS;

+create table SHIPPING_REQUESTS (

+ ITEM_ID BIGINT,

+ SHIPPING_ADDRESS VARCHAR(255),

+ SHIPPING_METHOD VARCHAR(255),

+ INSURANCE_AMOUNT FLOAT

+);


diff -u src/ejb/bean/actionbazaar/buslogic/ShippingRequestProcessorMDB.java.orig

...

- @Resource(name = "jdbc/TurtleDS")

+ @Resource(name = "examples-dataSource-demoXAPool")

   public void setDataSource(DataSource dataSource) {

     this.dataSource = dataSource;

}



2. Build, deploy and run


$ cd $ORACLE_HOME/wlserver/samples/server

$ . ./setExamplesEnv.sh                                       # set environment variables


$ cd $HOME/student/ejbAction/chapter4

$ ant undeploy                                                       # if need

$ ant clean

$ ant db-setup                                                        # create db tables

$ ant                                                                        # build and deploy

$ ant run                                                                 # run the case


In console, we can see a message - "Shipping Requestprocessed.."

The result can be observed from ij tool:

$ ij.sh

ij> select * from SHIPPING_REQUESTS;

ITEM_ID       |SHIPPING_ADDRESS          |SHIPPING_METHOD    |INSURANCE_AMOUNT

------------------------------------------------------------------------------------------------------------------------------------

10101            |101 In Hell                                |snailMail                          |101.0

1 row selected

ij> disconnect;

ij> exit;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章