您的位置:首页 >> 编程开发 >> Java >> Java基础 >> Eclipse >> 正文
Eclipse RSS
 

TutorialforbuildingJ2EEApplicationsusingJBOSSandECLIPSE-7

http://www.rdxx.com 06年12月09日 04:26 互联网 我要投稿

关键词: Tutorial , san , J2EE , Eclipse , JB , ATI , UI , ONS , IP

Note : Since you have generated your classes you have to again fix the incorrectly-generated deployment descriptors in jboss.xml, under <message-driven> and <session>.

Now, let's deploy our bean. Go to Lomboz J2EE View, start your server if it is not running, and deploy your bean.

Messages will appear in console showing deployment status.

Note : Steps for deploying beans have been detailed in previous chapters.

Once the bean is deployed successfully, create your test client.


Create Test Client :

Now, to create a test client in this case, the Test Client Wizard can't help us, because it requires a Home interface and EJB interface to be selected, whereas for Message Driven Beans there is no Home interface and EJB interface required (as discussed above).

So, write a class and the necessary methods to invoke operations on the RequestItems Bean.

Add a class named RequestMDBClient under the package au.com.tusc.mdb.

Add a method named getContext with the following signature:

private InitialContext getContext() throws NamingException 

Add the following lines of code to get the instance of IntialContext as shown below.




Add a method named testMDBBean with the following signature.

public void testMDBBean()

Now implement this method, in which the following steps are needed:

  1. Add a Data Object which is to be sent as the message.

  2. Create the Initial context reference.

  3. Create the Connection factory reference.

  4. Use this context to perform the lookup, where the lookup string is "queue/MdbQueue".

  5. Create the QueueConnection.

  6. Create the QueueSender.

  7. Create the QueueSession for the bean.

  8. Create the Object Message and pass the Data Object in message.

  9. Send the message.

  10. Finally, commit the session, and then close both the session and the connection. A code snippet of the testMDBean method is shown below.




Now your test client is complete, so let's test the client.

Test your Client :

To test your client, Select RequestMDBClient node > Go to the top level menu and select the 'Running Man' icon.

On that select 'Run as' > select Java Application.

Note : The steps to run test clients have been covered in previous chapters.

Now, under your console, you should get the following messages:


This message on the console doesn't tell us whether the message has been delivered to relevant beans or not. In order to verify that, go to the database using JMX Management Console View > Hypersonic > Invoke Database Manager and then run a query on table 'supplier' to see if a message has been added for the supplier.


Note: Details on accessing this Database Manager are provided in chapter 1.

Since a supplier named Sebastian has received our message, our message has been transferred successfully.

Exercise :

Now, to progress further, please complete the following exercise. Implement DeliverItems as an MD bean. Detailed tasks are given below.

  1. Create an MD Bean named DeliverItems under the package au.com.tusc.mdb.

    9 7 3 1 2 3 4 5 6 4 8 :


 
 
标签: Tutorial , san , J2EE , Eclipse , JB , ATI , UI , ONS , IP 打印本文
 
 
  热点搜索
 
 
 



Valid XHTML 1.0 Transitional
Copyright ©2005 - 2008 Rdxx.Com,All Rights Reserved
收藏本页
收藏本站