Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.jboss.remoting.samples.transporter.custom.client;
  
 

Author(s):
Tom Elrod
 
 public class Client
 {
 
    private CustomerProcessor customerProcessor = null;
 
    public void makeClientCall() throws Exception
    {
       Customer customer = createCustomer();
 
       ..println("Customer to be processed: " + customer);
       Customer processedCustomer = .processCustomer(customer);
       ..println("Customer is now: " + processedCustomer);
 
       //TransporterClient.destroyTransporterClient(customerProcessor);
    }
 
    public void getCustomerProcessor() throws Exception
    {
       initTransporterServices();
 
        = (CustomerProcessor) TransporterClient.createTransporterClient(CustomerProcessor.classtrue);
    }
 
    private void initTransporterServices() throws Exception
    {
       // create MBeanServer
       MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
 
       NetworkRegistry registry = NetworkRegistry.getInstance();
 
       String host = InetAddress.getLocalHost().getHostAddress();
       JNDIDetector jndiDetector = new JNDIDetector();
       jndiDetector.setPort(.);
       jndiDetector.setHost(host);
       jndiDetector.setContextFactory("org.jnp.interfaces.NamingContextFactory");
       jndiDetector.setURLPackage("org.jboss.naming:org.jnp.interfaces");
 
 
       InternalTransporterServices transporterService = InternalTransporterServices.getInstance();
 
       transporterService.setup(mbeanServer,
                                jndiDetectornew ObjectName("remoting:type=Detector,transport=jndi"),
                                registrynew ObjectName("remoting:type=NetworkRegistry"),
                                truetrue);
 
       //TODO: -TME Have to start the detector after setup() call?
       jndiDetector.start();
 
    }
 
 
    private Customer createCustomer()
    {
       Customer cust = new Customer();
       cust.setFirstName("Bob");
       cust.setLastName("Smith");
       Address addr = new Address();
       addr.setStreet("101 Oak Stree");
       addr.setCity("Atlanta");
       addr.setZip(30249);
       cust.setAddr(addr);
 
       return cust;
    }
 
    public static void main(String[] args)
    {
       try
       {
          client.getCustomerProcessor();
          while (true)
          {
             try
             {
                client.makeClientCall();
                Thread.currentThread().sleep(5000);
             }
            catch (Exception e)
            {
               e.printStackTrace();
            }
         }
      }
      catch (Exception e)
      {
         e.printStackTrace();
      }
   }
New to GrepCode? Check out our FAQ X