package mate.test;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import org.jboss.ejb.client.ContextSelector;
import org.jboss.ejb.client.EJBClientConfiguration;
import org.jboss.ejb.client.EJBClientContext;
import org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration;
import org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector;
public class Client1 {
public static void main(String[]args) throws Exception{
String jndiName = "ejb:TestEar/TestEjb//TestBean!" + TestBeanRemote.class.getName();//ear:good
Properties p = new Properties();
{
p.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
p.put("remote.connections", "default");
p.put("remote.connection.default.host", "192.168.1.100");
p.put("remote.connection.default.port", "4447");
p.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "true");
p.put("remote.connection.default.username", "testX");
p.put("remote.connection.default.password", "test1234");
p.put("remote.connection.default.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS", "JBOSS-LOCAL-USER");
p.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
}
EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(p);
ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(cc);
EJBClientContext.setSelector(selector);
Properties props = new Properties();
props.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
InitialContext context = new InitialContext(props);
TestBeanRemote vLookup = (TestBeanRemote) context.lookup(jndiName);
System.out.println("x" + vLookup.getNameFree());
System.out.println("x" + vLookup.getName());
}
}
Anyway, thank you Mates. I can NOT find any better example that has an EJB client. ;\