/** * DemoClient -- demonstrates using a minimal * Java application to talk to the DemoBean * stateless session bean */ package ejb.demo; import javax.naming.*; import javax.rmi.*; import javax.ejb.*; import java.util.*; /** * DemoClient demonstrates using a minimal stateless * session bean. * Remember view session beans as an extension of your * client running in the server. */ public class DemoClient { static public void main( String[] args ) { try { // Create A DemoBean object, in the server // Note: the name of the class corresponds to the // JNDI property declared in the // DeploymentDescriptor // From DeploymentDescriptor ... // beanHomeName demo.DemoHome Properties env = new Properties(); env.put( "java.naming.factory.initial", "desisoft.ejb.client.JRMPFactory" ); env.put( "desisoft.ejb.nameServer1", "localhost:2050" ); Context ctx = new InitialContext(env); DemoHome home = (DemoHome) PortableRemoteObject.narrow( ctx.lookup( "Demo" ), DemoHome.class ); // Now you have a reference to the DemoHome object // factory use it to ask the container to create an // instance of the Demo bean Demo bean = home.create(); // Here is the call that executes the method on the // server side object System.out.println(bean.demoSelect()); } catch (Exception ex) { ex.printStackTrace(); } } }