User: pra     
  Date: 01/08/07 14:09:00

  Added:       src/examples/org/jboss/docs/jms/ra HelloClient.java
  Log:
  Added example code for new JMS chapter
  
  Revision  Changes    Path
  1.1                  manual/src/examples/org/jboss/docs/jms/ra/HelloClient.java
  
  Index: HelloClient.java
  ===================================================================
  /*
  * JBoss, the OpenSource EJB server
  *
  * Distributable under LGPL license.
  * See terms of license at gnu.org.
  */
  
  package org.jboss.docs.jms.ra;
  
  import org.jboss.docs.jms.ra.interfaces.Hello;
  import org.jboss.docs.jms.ra.interfaces.HelloHome;
  
  
  import javax.naming.InitialContext;
  import javax.naming.Context;
  
  /**
   * Client that send hello messages to a session bean (wich does JMS through the 
resource adapter).
   * 
   *
   * @author Peter Antman
   * @version $Revision: 1.1 $
   */
  
  public class HelloClient
  {
     /**
      * The bean JNDI name
      */
      private String beanJNDI;
  
     /**
      * The Hello bean remote reference
      */
      private Hello hello;
  
  
     /**
      * @param beanJNDI bean to send message to
      */
      public HelloClient(String beanJNDI) throws Exception {
          this.beanJNDI = beanJNDI;
        setUp();
      }
  
     /**
      * Helper to get the remote reference to the bean
      */
      protected void setUp() throws Exception {
          // Get Hello bean
          Context context = new InitialContext();
          HelloHome helloH = (HelloHome)context.lookup(beanJNDI);
          hello = helloH.create();
  
      }
  
     /**
      * Say hallo to the bean
      */
      public void hello(String msg) throws Exception {
        System.out.println("Saying hello");
        hello.hello(msg);
      }
  
     
  
      public static void main(String[] args) {
        try {
            HelloClient c = new HelloClient("TopicHello");
            c.hello("Hello topic");
            
        }catch(Exception ex) {
            System.out.println("Error: " + ex);
            ex.printStackTrace();
        }
  
      }
  
  } // HelloClient
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to