package org.apache.maven.plugins.eclipse.wtp.test.client; import java.rmi.RemoteException; import java.util.Properties; import javax.ejb.CreateException; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.rmi.PortableRemoteObject; import org.apache.maven.plugins.eclipse.wtp.test.WtpEjbRemote; import org.apache.maven.plugins.eclipse.wtp.test.WtpEjbRemoteHome; public class WtpClient { /** * @param args * @throws NamingException * @throws CreateException * @throws RemoteException */ @SuppressWarnings("unchecked") public static void main(String[] args) throws NamingException, RemoteException, CreateException { long startime = System.currentTimeMillis(); try { if (args.length != 1) { System.out.println("Usage: java org.apache.maven.plugins.eclipse.wtp.test.client.WtpClient URL"); return; } System.out.println("Start SAMPLE"); Properties prop = new Properties(); prop.setProperty(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); prop.setProperty(Context.PROVIDER_URL, args[0]); Context ctx = new InitialContext(prop); Object obj = ctx.lookup("org.apache.maven.plugins.eclipse.wtp.test.WtpEjbRemoteHome"); WtpEjbRemoteHome remoteHome = (WtpEjbRemoteHome) PortableRemoteObject.narrow(obj, WtpEjbRemoteHome.class); WtpEjbRemote remote = remoteHome.create(); System.out.println("before call to method1"); remote.method1(); System.out.println("before call to method2"); remote.method2("Hello 2"); System.out.println("before call to method3"); remote.method3(); System.out.println("END SAMPLE"); } finally { long endtime = System.currentTimeMillis(); System.out.println("Total execution time is : " + (endtime - startime) + " ms."); } } }