Properties properties = new Properties(); properties.put("endpoint.name", "farecompare-client-endpoint"); properties.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false"); properties.put("remote.connections", "cmc5101,cmc5102"); properties.put("remote.connection.cmc5101.host", "cmc5-101"); properties.put("remote.connection.cmc5101.port", "4447"); properties.put("remote.connection.cmc5101.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false"); properties.put("remote.connection.cmc5102.host", "cmc5-102"); properties.put("remote.connection.cmc5102.port", "4447"); properties.put("remote.connection.cmc5102.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false"); PropertiesBasedEJBClientConfiguration configuration = new PropertiesBasedEJBClientConfiguration(properties); final ContextSelector ejbClientContextSelector = new ConfigBasedEJBClientContextSelector(configuration); final ContextSelector previousSelector = EJBClientContext.setSelector(ejbClientContextSelector); final Hashtable jndiProperties = new Hashtable(); jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); final Context context = new InitialContext(jndiProperties);
public static <T> T connectEJB(String jndi) throws NamingException { Properties clientProperties = new Properties(); clientProperties.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false"); clientProperties.put("remote.connections", "default"); clientProperties.put("remote.connection.default.port", myPort); clientProperties.put("remote.connection.default.host", myHost); clientProperties.put("remote.connection.default.username", myUser); clientProperties.put("remote.connection.default.password", myPassword); clientProperties.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false"); EJBClientConfiguration ejbClientConfiguration = new PropertiesBasedEJBClientConfiguration(clientProperties); ContextSelector<EJBClientContext> contextSelector = new ConfigBasedEJBClientContextSelector(ejbClientConfiguration); EJBClientContext.setSelector(contextSelector); Properties properties = new Properties(); properties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); Context context = new InitialContext(properties); return (T) context.lookup(jndi); }
final Properties jndiProperties = new Properties(); jndiProperties.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false"); jndiProperties.put("remote.connections", "one"); jndiProperties.put("remote.connection.one.port", "4447"); jndiProperties.put("remote.connection.one.host", "localhost"); jndiProperties.put("remote.connection.one.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false"); jndiProperties.put("remote.connection.one.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS", "JBOSS-LOCAL-USER"); jndiProperties.put("remote.clusters", "ejb"); jndiProperties.put("remote.cluster.ejb.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false"); jndiProperties.put("remote.connection.one.username", username); jndiProperties.put("remote.connection.one.password",password); jndiProperties.put("remote.cluster.ejb.username", username); jndiProperties.put("remote.cluster.ejb.password", password); jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(jndiProperties); ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(cc); EJBClientContext.setSelector(selector); final Context context = new InitialContext(jndiProperties); MessageServieRemote msgService = (MessageServieRemote) context.lookup("ejb:TestEar/TestNopEjb//MessageService!net.jonasbandi.ejbremote.MessageServieRemote"); System.out.println(msgService.getMessage());
private void initializeEJBClientContext() { Properties properties = new Properties(); properties.put("endpoint.name", "client-endpoint"); properties.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false"); properties.put("remote.connections", "default"); properties.put("remote.connection.default.host", "localhost"); properties.put("remote.connection.default.port", "4447"); properties.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false"); PropertiesBasedEJBClientConfiguration configuration = new PropertiesBasedEJBClientConfiguration(properties); final ContextSelector<EJBClientContext> ejbClientContextSelector = new ConfigBasedEJBClientContextSelector(configuration); final ContextSelector<EJBClientContext> previousSelector = EJBClientContext.setSelector(ejbClientContextSelector); }
public JBossLookupConfiguration(Properties jbossEjbClientProperties) { EJBClientConfiguration ejbClientConfiguration = new PropertiesBasedEJBClientConfiguration(jbossEjbClientProperties); ContextSelector<EJBClientContext> ejbClientContextSelector = new ConfigBasedEJBClientContextSelector(ejbClientConfiguration); EJBClientContext.setSelector(ejbClientContextSelector); }
public JBossLookupConfiguration(Properties jbossEjbClientProperties) { EJBClientConfiguration ejbClientConfiguration = new PropertiesBasedEJBClientConfiguration(jbossEjbClientProperties); ContextSelector<EJBClientContext> ejbClientContextSelector = new ConfigBasedEJBClientContextSelector(ejbClientConfiguration); EJBClientContext.setSelector(ejbClientContextSelector); }
"false"); final EJBClientConfiguration ejbClientConfiguration = new PropertiesBasedEJBClientConfiguration( clientProperties); final ContextSelector<EJBClientContext> contextSelector = new ConfigBasedEJBClientContextSelector(
EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(clientProp); ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(cc); EJBClientContext.setSelector(selector);
EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(clientProp); ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(cc); EJBClientContext.setSelector(selector);
public static RemoteNamingStoreEJBClientHandler setupEJBClientContext(final Properties ejbClientProperties, final List<RemoteContext.CloseTask> closeTasks) { EJBClientConfiguration clientConfiguration = new PropertiesBasedEJBClientConfiguration(ejbClientProperties); final EJBClientContext ejbClientContext = EJBClientContext.create(clientConfiguration); final String ejbClientContextName = EJB_CLIENT_CONTEXT_NAME_PREFIX + nextEJBClientContextNumber.addAndGet(1); final EJBClientContextIdentifier ejbClientContextIdentifier = new NamedEJBClientContextIdentifier(ejbClientContextName); // register the context with the selector registerEJBClientContextWithSelector(ejbClientContextIdentifier, ejbClientContext); // add a close task which closes the EJB client context when the remote naming context is closed if (closeTasks != null) { closeTasks.add(new RemoteNamingEJBClientContextCloseTask(ejbClientContext)); } return new RemoteNamingStoreEJBClientHandler(ejbClientContextIdentifier, ejbClientContext); }
@Test public void canLookup_testFacadeBean_usingEjbClientApi_withoutFile() throws Exception { // Set EJB Client API properties programmatically instead of using // jboss-ejb-client.properties file Properties clientProp = new Properties(); clientProp.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false"); clientProp.put("remote.connections", "default"); clientProp.put("remote.connection.default.port", "18080"); clientProp.put("remote.connection.default.host", "localhost"); // clientProp.put("remote.connection.default.username", "ejbUser"); // clientProp.put("remote.connection.default.password", "ejbPassword"); clientProp.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false"); // Set selector (avoiding usage of jboss-ejb-client.properties file) EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(clientProp); ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(cc); EJBClientContext.setSelector(selector); final Hashtable<String, String> jndiProperties = new Hashtable<>(); // jndiProperties.put(Context.PROVIDER_URL, "remote://localhost:14447"); jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); final Context context = new InitialContext(jndiProperties); // Important: We need to use the 'ejb:' prefix... TestRemote testRemote = (TestRemote) context.lookup("ejb:/test//TestRemoteInterfaceBean!" + TestRemote.class.getName()); Assert.assertEquals("TestRemoteBean says hello to EjbClientApi", testRemote.getGreeting("EjbClientApi")); }
@Test public void canLookup_testFacadeBean_usingEjbClientApi_withoutFile() throws Exception { // Set EJB Client API properties programmatically instead of using // jboss-ejb-client.properties file Properties clientProp = new Properties(); clientProp.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false"); clientProp.put("remote.connections", "default"); clientProp.put("remote.connection.default.port", "18080"); clientProp.put("remote.connection.default.host", "localhost"); // clientProp.put("remote.connection.default.username", "ejbUser"); // clientProp.put("remote.connection.default.password", "ejbPassword"); clientProp.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false"); // Set selector (avoiding usage of jboss-ejb-client.properties file) EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(clientProp); ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(cc); EJBClientContext.setSelector(selector); final Hashtable<String, String> jndiProperties = new Hashtable<>(); // jndiProperties.put(Context.PROVIDER_URL, "remote://localhost:14447"); jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); final Context context = new InitialContext(jndiProperties); // Important: We need to use the 'ejb:' prefix... TestRemote testRemote = (TestRemote) context.lookup("ejb:/test//TestRemoteInterfaceBean!" + TestRemote.class.getName()); Assert.assertEquals("TestRemoteBean says hello to EjbClientApi", testRemote.getGreeting("EjbClientApi")); }
try { SecurityActions.setContextClassLoader(module.getClassLoader()); configuration = new PropertiesBasedEJBClientConfiguration(properties);