<Ejb3InAction> 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;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值