[jboss-cvs] JBossRemoting/docs/guide/en ...

Tom Elrod tom.elrod at jboss.com
Mon Jul 31 15:17:14 EDT 2006


  User: telrod  
  Date: 06/07/31 15:17:14

  Modified:    docs/guide/en  chap10.xml
  Log:
  JBREM-516 - adding simple transporter sample to doc and samples build.
  
  Revision  Changes    Path
  1.3       +95 -5     JBossRemoting/docs/guide/en/chap10.xml
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: chap10.xml
  ===================================================================
  RCS file: /cvsroot/jboss/JBossRemoting/docs/guide/en/chap10.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- chap10.xml	31 Jul 2006 06:54:11 -0000	1.2
  +++ chap10.xml	31 Jul 2006 19:17:14 -0000	1.3
  @@ -763,8 +763,8 @@
         supplied. At that point, can make typed method invocations on the
         returned object, which will then make the remote invocations under the
         covers. Note that can have multiple transporter clients to the same
  -      target pojo, each using different interface types for making calls.
  -      </para>
  +      target pojo, each using different interface types for making
  +      calls.</para>
   
         <para>When no longer need to make invocations on the target pojo, the
         resources associated with the remoting client will need to be cleaned
  @@ -790,7 +790,7 @@
         that a particular target pojo instance fails. However, note that only
         provide invocation failover and does not take into account state
         transfer between target pojos (would need addition of JBoss Cache or
  -      some other state synchronization tool). </para>
  +      some other state synchronization tool).</para>
       </section>
   
       <para>The transporter sample spans several examples showing different ways
  @@ -802,6 +802,96 @@
       respective sub-packages (named client and server).</para>
   
       <section>
  +      <title>Transporters sample - simple</title>
  +
  +      <para>The simple transporter example (found in
  +      org.jboss.remoting.samples.transporter.simple package) demonstrates a
  +      very simple example of how to use the transporters to expose a plain old
  +      java object for remote method invocations.</para>
  +
  +      <para>In this simple transporter example, will be taking a class that
  +      formats a java.util.Date into a simple String representation and
  +      exposing it so can call on the remotely. The target object in this case,
  +      org.jboss.remoting.samples.transporter.simple.DateProcessorImpl,
  +      implements the
  +      org.jboss.remoting.samples.transporter.simple.DateProcessor interfaces
  +      (as shown below):</para>
  +
  +      <programlisting>public interface DateProcessor
  +{
  +   public String formatDate(Date dateToConvert);
  +}
  +
  +
  +public class DateProcessorImpl implements DateProcessor
  +{
  +   public String formatDate(Date dateToConvert)
  +   {
  +      DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
  +      return dateFormat.format(dateToConvert);
  +   }
  +}</programlisting>
  +
  +      <para>This is then exposed using the TransporterServer by the
  +      org.jboss.remoting.samples.transporter.simple.Server class.</para>
  +
  +      <programlisting>public class Server
  +{
  +   public static void main(String[] args) throws Exception
  +   {
  +      TransporterServer server = TransporterServer.createTransporterServer("socket://localhost:5400", new DateProcessorImpl(), DateProcessor.class.getName());
  +      Thread.sleep(10000);
  +      server.stop();
  +   }
  +}</programlisting>
  +
  +      <para>The Server class simply creates a TransporterServer by indicating
  +      the locator url would like to use for the remoting server, a newly
  +      created instance of DataProcessorImpl, and the interface type would like
  +      to expose remotely. The TransporterServer returned from the
  +      createTransporterServer call is live and ready to receive incoming
  +      method invocation requests. Will then wait 10 seconds for a request,
  +      then stop the server.</para>
  +
  +      <para>Next need to have client to make the remote invocation. This can
  +      be found within
  +      org.jboss.remoting.samples.transporter.simple.Client.</para>
  +
  +      <programlisting>public class Client
  +{
  +   public static void main(String[] args) throws Exception
  +   {
  +      DateProcessor dateProcessor = (DateProcessor) TransporterClient.createTransporterClient("socket://localhost:5400", DateProcessor.class);
  +      String formattedDate = dateProcessor.formatDate(new Date());
  +      System.out.println("Current date: " + formattedDate);
  +   }
  +}</programlisting>
  +
  +      <para> In the Client class, create a TransporterClient which can be cast
  +      to the desired type, which is DataProcessor in this case. In calling the
  +      createTransporterClient, need to specify the locator ulr (same as was
  +      used for the TransporterServer), and the interface type will be calling
  +      on for the target pojo. Once have the DateProcessor variable, will make
  +      the call to formatDate() and pass a newly created Date object. The
  +      return will be a formated String of the date passed. </para>
  +
  +      <para>To run this example, can run the Server and then the Client. Or
  +      can go to the examples directory and run the ant target
  +      'run-transporter-simple-server' and then in another window run the ant
  +      target 'run-transporter-simple-client'. For example:</para>
  +
  +      <programlisting>ant run-transporter-simple-server</programlisting>
  +
  +      <para>and then:</para>
  +
  +      <programlisting>ant run-transporter-simple-client</programlisting>
  +
  +      <para>The output from the client window should look similar to:</para>
  +
  +      <programlisting>Current date: Jul 31, 2006</programlisting>
  +    </section>
  +
  +    <section>
         <title>Transporter sample - basic</title>
   
         <para>The basic transporter example (found in
  @@ -809,8 +899,8 @@
         build a simple transporter for making remote invocations on plain old
         java objects.</para>
   
  -      <para>In this first, basic transporter example, will be using a few
  -      domain objects; <code>Customer</code> and Address, which are just data
  +      <para>In this basic transporter example, will be using a few domain
  +      objects; <code>Customer</code> and Address, which are just data
         objects.</para>
   
         <programlisting>public class <emphasis role="bold">Customer</emphasis> implements Serializable
  
  
  



More information about the jboss-cvs-commits mailing list