EOB 1.1

About EOB
Overview
News & History
Downloads
Persistence
Development
J2EE comparison
Requirements
Bugs & Issues
Limitations of use
Info & Credits

Examples
Overview
Simple Stock Quote Servlet
People & Addresses Beans
Shopping Cart
Velocity Webapp
Clock Applet
Swing Bank Account

Tutorials
Basic

Hosted By
SourceForge.net Logo

EOB logo  Enterprise Object Broker






Tutorial 0 - Basic bean publication

OK, for this tutorial, we're going to build a distributed thermometer.  It reads the temp on the server, and publishes that over RPC to clients.  The server-side implementation is fake here, but there could be some cached JNI using implementation in a real case.

1) A simple interface to publish.

Start with simple interface that illustrates a simple application to be served.  This interface will the thing that is looked up on the client side.
 public interface Thermometer {
   float getTemperature();
 }
2) Create a simple implementation.

Easy enough. Constructor must be public and empty (like the default)...
 public class DefaultThermometer {
   public float getTemperature() {
     return (float) Math.random();
   }
 }
3) Create a bean manifest.

A served application may contain many beans, but this one contains just one.  EOB uses this to work out what to instantiate and what it represents.
 <?xml version="1.0"?>
 <beans-info>
   <bean-info name="My-Thermometer" facade="Thermometer" impl="DefaultThermometer"/>
 </beans-info>
The 'name' is the name by which this thermometer will be looked up.  The 'facade' is the actual interface being implemented.  The 'impl' is the implementation of that facade that EOB will instantiate and route requests through to.

4) Package the three above into a jar file.

Here is the contents of the JAR.  Suppose it was called DefaultThermometer.jar
 Thermometer.class
 DefaultThermometer.class
 EOB-INF/beans.xml
 META-INF/manifest.mf (created by Sun's jar utility)
5) Create a manifest for the application
 <?xml version="1.0"?>
 <application-info>
   <publish-info type="SocketCustomStream" bind-to="*" port="22222"/>
 </application-info>
EOB uses this to work out how to publish the multiple beans that might be included in the application.

6) Make an .eob file

Package the bean jar and EOB application manifest in an .eob file. 

Suppose the resulting file was called DefaultThermometer.eob
 beans/DefaultThermometer.jar
 application.xml
You could drop that .eob into EOB's startupApps/ directory.

7) Make a client side usage of that facade.

A simple mainable class.
 public class ThermometerTest {
   public static void main(String[] args) throws Exception {
       Factory af = new ServerSideClassFactory();
       af.setHostContext(new SocketCustomStreamHostContext("localhost", 22222));
       printTemp((Thermometer) af.lookup("My-Thermometer"));
   }
   private static void printTemp(Thermometer thermometer) {
       System.out.println("The temperature on the server is : " + thermometer.getTemperature());
   }
 }
Package this how you like, but it will need AltRMI's client and common jars in the classpath.  There is also a way of doing the lookup using JNDI meaning that yout don't have to import any AltRMI classes (but still need them in your classpath).

$Revision: 1.5 $ $Date: 2003/04/15 22:47:07 $