~ubuntu-branches/ubuntu/raring/libjboss-remoting-java/raring

« back to all changes in this revision

Viewing changes to src/tests/org/jboss/test/remoting/transporter/proxy/CustomerProcessorImpl.java

  • Committer: Package Import Robot
  • Author(s): Torsten Werner
  • Date: 2011-09-09 14:01:03 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: package-import@ubuntu.com-20110909140103-hqokx61534tas9rg
Tags: 2.5.3.SP1-1
* Newer but not newest upstream release. Do not build samples.
* Change debian/watch to upstream's svn repo.
* Add patch to fix compile error caused by tomcat update.
  (Closes: #628303)
* Switch to source format 3.0.
* Switch to debhelper level 7.
* Remove useless Depends.
* Update Standards-Version: 3.9.2.
* Update README.source.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.jboss.test.remoting.transporter.proxy;
 
2
 
 
3
import org.jboss.remoting.transporter.TransporterClient;
 
4
import org.jboss.remoting.transporter.TransporterServer;
 
5
 
 
6
import java.util.Random;
 
7
 
 
8
/**
 
9
 * @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
 
10
 */
 
11
public class CustomerProcessorImpl implements CustomerProcessor, Auditor
 
12
{
 
13
   private String locatorURI = "socket://localhost:5401";
 
14
 
 
15
   private int callCounter = 0;
 
16
   public static final String COMPANYNAME = "acme co.";
 
17
 
 
18
   /**
 
19
    * Takes the customer passed, and if not null and customer id
 
20
    * is less than 0, will create a new random id and set it.
 
21
    * The customer object returned will be the modified customer
 
22
    * object passed.
 
23
    *
 
24
    * @param customer
 
25
    * @return
 
26
    */
 
27
   public ICustomer processCustomer(Customer customer)
 
28
   {
 
29
      if (customer != null && customer.getCustomerId() < 0)
 
30
      {
 
31
         customer.setCustomerId(new Random().nextInt(1000));
 
32
      }
 
33
 
 
34
      ICustomer customerProxy = null;
 
35
      try
 
36
      {
 
37
         TransporterServer server = TransporterServer.createTransporterServer(locatorURI, customer, ICustomer.class.getName());
 
38
         customerProxy = (ICustomer) TransporterClient.createTransporterClient(locatorURI, ICustomer.class);
 
39
      }
 
40
      catch (Exception e)
 
41
      {
 
42
         e.printStackTrace();
 
43
      }
 
44
 
 
45
      callCounter++;
 
46
 
 
47
      System.out.println("processed customer with new id of " + customerProxy.getCustomerId());
 
48
      return customerProxy;
 
49
   }
 
50
 
 
51
   public String getCompanyName()
 
52
   {
 
53
      return COMPANYNAME;
 
54
   }
 
55
 
 
56
   public int getNumberOfCalls()
 
57
   {
 
58
      return callCounter;
 
59
   }
 
60
}