1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
package test;
import java.util.*;
import javax.naming.*;
import com.bean.*;
public class EJBClient {
public static void main(String[] args) {
Properties ppt = null;
Context ctx = null;
Object ref = null;
MonPremierEJBHome home = null;
MonPremierEJB bean = null;
try {
ppt = new Properties();
ppt.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
ppt.put(Context.PROVIDER_URL, "localhost:1099");
ctx = new InitialContext(ppt);
ref = ctx.lookup("MonPremierEJBBean");
home = (MonPremierEJBHome) javax.rmi.PortableRemoteObject.narrow(ref,
MonPremierEJBHome.class);
bean = home.create();
System.out.println("message = " + bean.message());
bean.remove();
}
catch (Exception e) {
e.printStackTrace();
}
}
} |