Search in sources :

Example 1 with ConfigBasedEJBClientContextSelector

use of org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector in project eap-additional-testsuite by jboss-set.

the class EJBClientContextSelector method setup.

public static ContextSelector<EJBClientContext> setup(String file, Properties propertiesToReplace) throws IOException {
    // setUp the selector
    final InputStream inputStream = EJBClientContextSelector.class.getClassLoader().getResourceAsStream(file);
    if (inputStream == null) {
        throw new IllegalStateException("Could not find " + file + " in classpath");
    }
    final Properties properties = new Properties();
    properties.load(inputStream);
    // add or replace properties passed from file
    if (propertiesToReplace != null) {
        for (Object key : propertiesToReplace.keySet()) {
            properties.put(key, propertiesToReplace.get(key));
        }
    }
    final EJBClientConfiguration ejbClientConfiguration = new PropertiesBasedEJBClientConfiguration(properties);
    final ConfigBasedEJBClientContextSelector selector = new ConfigBasedEJBClientContextSelector(ejbClientConfiguration);
    return EJBClientContext.setSelector(selector);
}
Also used : PropertiesBasedEJBClientConfiguration(org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration) InputStream(java.io.InputStream) ConfigBasedEJBClientContextSelector(org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector) ConfigBasedEJBClientContextSelector(org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector) Properties(java.util.Properties) PropertiesBasedEJBClientConfiguration(org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration) EJBClientConfiguration(org.jboss.ejb.client.EJBClientConfiguration)

Example 2 with ConfigBasedEJBClientContextSelector

use of org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector in project dwoss by gg-net.

the class WildflyLookup method init.

private synchronized void init() {
    if (initialized)
        return;
    Properties p = new Properties();
    p.put("endpoint.name", "client-endpoint");
    p.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
    p.put("remote.connections", "one");
    p.put("remote.connection.one.port", Integer.toString(CONFIG.getPort()));
    p.put("remote.connection.one.host", CONFIG.getHost());
    p.put("remote.connection.one.username", CONFIG.getUsername());
    p.put("remote.connection.one.password", CONFIG.getPassword());
    EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(p);
    ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(cc);
    EJBClientContext.setSelector(selector);
    final String APP = CONFIG.getApp();
    Object instance = null;
    String discoveryName = "ejb:/" + APP + "//" + Discovery.NAME;
    try {
        instance = context().lookup(discoveryName);
    } catch (NamingException ex) {
        throw new RuntimeException("Error on frist lookup", ex);
    }
    L.debug("Lookup of {} sucessfull", discoveryName);
    Discovery discovery = (Discovery) instance;
    List<String> names = discovery.allJndiNames("java:app/" + APP);
    L.debug("Discovery returned {} raw entries", names.size());
    namesAndLookup = names.stream().filter(n -> n.contains("!")).map(n -> new KeyEquals(n.split("!")[1], "ejb:/" + APP + "//" + n)).distinct().collect(Collectors.toMap(KeyEquals::getKey, KeyEquals::getValue));
    if (L.isDebugEnabled())
        namesAndLookup.forEach((k, v) -> L.debug("Lookup cache key={}, value={}", k, v));
    // namesAndLookup = new HashMap<>();
    // for (String name : names) {
    // if ( !name.contains("!") ) continue;
    // String key = name.split("!")[1];
    // // INFO: There is no solution for ?statefull yet.
    // String value = "ejb:/" + APP + "//" + name;
    // L.debug("Storing lookup key={}, value={}", key, value);
    // namesAndLookup.put(key, value);
    // }
    L.debug("RemoteLookup initilaized");
    initialized = true;
}
Also used : java.util(java.util) Logger(org.slf4j.Logger) Discovery(eu.ggnet.dwoss.discover.Discovery) LoggerFactory(org.slf4j.LoggerFactory) javax.naming(javax.naming) RemoteLookup(eu.ggnet.saft.core.cap.RemoteLookup) Collectors(java.util.stream.Collectors) lombok(lombok) ConfigBasedEJBClientContextSelector(org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector) IsStateful(eu.ggnet.dwoss.common.api.IsStateful) org.jboss.ejb.client(org.jboss.ejb.client) Objects.requireNonNull(java.util.Objects.requireNonNull) EjbConnectionConfiguration(eu.ggnet.dwoss.util.EjbConnectionConfiguration) ConfigBasedEJBClientContextSelector(org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector) Discovery(eu.ggnet.dwoss.discover.Discovery)

Example 3 with ConfigBasedEJBClientContextSelector

use of org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector in project eap-additional-testsuite by jboss-set.

the class EJBClientContextSelector method setup.

public static ContextSelector<EJBClientContext> setup(String file, Properties propertiesToReplace) throws IOException {
    // setUp the selector
    final InputStream inputStream = EJBClientContextSelector.class.getClassLoader().getResourceAsStream(file);
    if (inputStream == null) {
        throw new IllegalStateException("Could not find " + file + " in classpath");
    }
    final Properties properties = new Properties();
    properties.load(inputStream);
    // add or replace properties passed from file
    if (propertiesToReplace != null) {
        for (Object key : propertiesToReplace.keySet()) {
            properties.put(key, propertiesToReplace.get(key));
        }
    }
    final EJBClientConfiguration ejbClientConfiguration = new PropertiesBasedEJBClientConfiguration(properties);
    final ConfigBasedEJBClientContextSelector selector = new ConfigBasedEJBClientContextSelector(ejbClientConfiguration);
    return EJBClientContext.setSelector(selector);
}
Also used : PropertiesBasedEJBClientConfiguration(org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration) InputStream(java.io.InputStream) ConfigBasedEJBClientContextSelector(org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector) ConfigBasedEJBClientContextSelector(org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector) Properties(java.util.Properties) PropertiesBasedEJBClientConfiguration(org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration) EJBClientConfiguration(org.jboss.ejb.client.EJBClientConfiguration)

Example 4 with ConfigBasedEJBClientContextSelector

use of org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector in project eap-additional-testsuite by jboss-set.

the class EJBClientContextSelector method setup.

public static ContextSelector<EJBClientContext> setup(String file, Properties propertiesToReplace) throws IOException {
    // setUp the selector
    final InputStream inputStream = EJBClientContextSelector.class.getClassLoader().getResourceAsStream(file);
    if (inputStream == null) {
        throw new IllegalStateException("Could not find " + file + " in classpath");
    }
    final Properties properties = new Properties();
    properties.load(inputStream);
    // add or replace properties passed from file
    if (propertiesToReplace != null) {
        for (Object key : propertiesToReplace.keySet()) {
            properties.put(key, propertiesToReplace.get(key));
        }
    }
    final EJBClientConfiguration ejbClientConfiguration = new PropertiesBasedEJBClientConfiguration(properties);
    final ConfigBasedEJBClientContextSelector selector = new ConfigBasedEJBClientContextSelector(ejbClientConfiguration);
    return EJBClientContext.setSelector(selector);
}
Also used : PropertiesBasedEJBClientConfiguration(org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration) InputStream(java.io.InputStream) ConfigBasedEJBClientContextSelector(org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector) ConfigBasedEJBClientContextSelector(org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector) Properties(java.util.Properties) PropertiesBasedEJBClientConfiguration(org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration) EJBClientConfiguration(org.jboss.ejb.client.EJBClientConfiguration)

Aggregations

ConfigBasedEJBClientContextSelector (org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector)4 InputStream (java.io.InputStream)3 Properties (java.util.Properties)3 EJBClientConfiguration (org.jboss.ejb.client.EJBClientConfiguration)3 PropertiesBasedEJBClientConfiguration (org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration)3 IsStateful (eu.ggnet.dwoss.common.api.IsStateful)1 Discovery (eu.ggnet.dwoss.discover.Discovery)1 EjbConnectionConfiguration (eu.ggnet.dwoss.util.EjbConnectionConfiguration)1 RemoteLookup (eu.ggnet.saft.core.cap.RemoteLookup)1 java.util (java.util)1 Objects.requireNonNull (java.util.Objects.requireNonNull)1 Collectors (java.util.stream.Collectors)1 javax.naming (javax.naming)1 lombok (lombok)1 org.jboss.ejb.client (org.jboss.ejb.client)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1