This topic has not yet been written. The content below is from the topic description.
Transporters sample - simple 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. 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): 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); } } This is then exposed using the TransporterServer by the org.jboss.remoting.samples.transporter.simple.Server class. 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(); } } 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. Next need to have client to make the remote invocation. This can be found within org.jboss.remoting.samples.transporter.simple.Client. 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); } } 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. 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: ant run-transporter-simple-server and then: ant run-transporter-simple-client The output from the client window should look similar to: Current date: Jul 31, 2006