Combining the remote naming project and EJB client library

To get the benefits of both approaches it is possible to combine the EJB client library and the remote naming implementation without any restrictions. This approach requires that the environment property jboss.naming.client.ejb.context is set to false. Then, the remote naming project creates no internal EJB client context.

To invoke remote EJB components, this approach requires in addition to add the URL package prefix org.jboss.ejb.client.naming. With this environment property, the InitialContext creates the necessary EJB client context to handle the ejb:namespace via the URL context factory implementation of the EJB client library. The EJB client context can now be configured separately with the jboss-ejb-client.properties file.

The only disadvantage is that this approach requires a configuration of the EJB client context and the remote naming project. The benefit is that only one InitialContext is required to invoke EJB components with all optimizations and configuration capabilities of the EJB client library, and the possibility to lookup other objects with the same InitialContext:

Properties prop = new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
prop.put(Context.PROVIDER_URL, "http-remoting://127.0.0.1:8080");
prop.put(Context.SECURITY_PRINCIPAL, "username");
prop.put(Context.SECURITY_CREDENTIALS, "password");
prop.put("jboss.naming.client.ejb.context", false);
prop.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
Context context = new InitialContext(prop);
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.244.216