use of eu.ggnet.dwoss.discover.Discovery 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;
}
Aggregations