public Context createRootContext(final NamingProvider namingProvider, final String nameScheme, final FastHashtable<String, Object> env, final ProviderEnvironment providerEnvironment) throws NamingException { assert nameScheme.equals("ejb"); return new EJBRootContext(namingProvider, env, providerEnvironment); } }
private static ClassLoader getContextClassLoader(){ final SecurityManager sm = System.getSecurityManager(); ClassLoader classLoader; if (sm != null) { classLoader = AccessController.doPrivileged((PrivilegedAction<ClassLoader>) EJBRootContext::doGetContextClassLoader); } else { classLoader = doGetContextClassLoader(); } return classLoader; }
EJBRootContext(final NamingProvider namingProvider, final FastHashtable<String, Object> env, final ProviderEnvironment providerEnvironment) { super(env); this.namingProvider = namingProvider; this.providerEnvironment = providerEnvironment; // TODO, Switch to providerEnvironment using WildFLy Naming, when attachments are added Object learned = env.get(LEARNED_AFFINITY_KEY); if (learned == null || ! (learned instanceof LearnedAffinity)) { // check if strong affinity for this context has been set in the environment String clusterName = getClusterAffinityValueFromEnvironment(); if (clusterName != null) { learned = new LearnedAffinity(new ClusterAffinity(clusterName)); } else { learned = new LearnedAffinity(shouldLearnAffinity() ? null : Affinity.NONE); } env.put(LEARNED_AFFINITY_KEY, learned); } this.baseAffinity = (LearnedAffinity) learned; }
/** * Check if the user has specified strong affinity to a cluster for this context and return the cluster name. * @return String the name of the cluster */ private String getClusterAffinityValueFromEnvironment() { Object val; try { val = getEnvironment().get(EJBClient.CLUSTER_AFFINITY); if (val != null && val instanceof String) { return (String) val; } return getLegacyClusterAffinity(); } catch(NamingException ne) { Logs.MAIN.warn("Problem reading cluster affinity specification from env; skipping affinity assignment"); return null; } }
protected Object lookupNative(final Name name) throws NamingException { final int size = name.size(); if (size < 3) { return new RelativeContext(new FastHashtable<>(getEnvironment()), this, SimpleName.of(name)); } else if (size > 4) { throw nameNotFound(name); break; } else if (cp == '?') { throw nameNotFound(name); if (size == 3) { return new RelativeContext(new FastHashtable<>(getEnvironment()), this, SimpleName.of(name)); throw nameNotFound(name); view = Class.forName(viewType, false, getContextClassLoader()); } catch (ClassNotFoundException e) { throw Logs.MAIN.lookupFailed(name, name, e); Long invocationTimeout = getLongValueFromEnvironment(PROPERTY_KEY_INVOCATION_TIMEOUT); if (invocationTimeout != null) { EJBClient.setInvocationTimeout(proxy, invocationTimeout.longValue(), TimeUnit.MILLISECONDS);
private Long getLongValueFromEnvironment(String key) throws NamingException { Object val = getEnvironment().get(key); if (val != null && val instanceof String) { return Long.valueOf(Long.parseLong((String) val)); } return null; }
protected CloseableNamingEnumeration<Binding> listBindingsNative(final Name name) throws NamingException { throw notSupported(); }
protected Object lookupLinkNative(final Name name) throws NamingException { return lookupNative(name); }
protected Object lookupNative(final Name name) throws NamingException { final int size = name.size(); if (size < 3) { return new RelativeContext(new FastHashtable<>(getEnvironment()), this, SimpleName.of(name)); } else if (size > 4) { throw nameNotFound(name); break; } else if (cp == '?') { throw nameNotFound(name); if (size == 3) { return new RelativeContext(new FastHashtable<>(getEnvironment()), this, SimpleName.of(name)); throw nameNotFound(name); view = Class.forName(viewType, false, getContextClassLoader()); } catch (ClassNotFoundException e) { throw Logs.MAIN.lookupFailed(name, name, e); Long invocationTimeout = getLongValueFromEnvironment(PROPERTY_KEY_INVOCATION_TIMEOUT); if (invocationTimeout != null) { EJBClient.setInvocationTimeout(proxy, invocationTimeout.longValue(), TimeUnit.MILLISECONDS);
/** * Check if the user has specified strong affinity to a cluster for this context and return the cluster name. * @return String the name of the cluster */ private String getClusterAffinityValueFromEnvironment() { Object val; try { val = getEnvironment().get(EJBClient.CLUSTER_AFFINITY); if (val != null && val instanceof String) { return (String) val; } return getLegacyClusterAffinity(); } catch(NamingException ne) { Logs.MAIN.warn("Problem reading cluster affinity specification from env; skipping affinity assignment"); return null; } }
private String getLegacyClusterAffinity() throws NamingException { Object val = getEnvironment().get(JBossEJBProperties.PROPERTY_KEY_CLUSTERS); if (val != null && val instanceof String) { String str = (String) val; // Pick the first definition for affinity int index = str.indexOf(','); if (index > -1) { str = str.substring(0, index); } return str.trim(); } return null; }
protected CloseableNamingEnumeration<NameClassPair> listNative(final Name name) throws NamingException { throw notSupported(); }
protected Object lookupLinkNative(final Name name) throws NamingException { return lookupNative(name); }
protected Object lookupNative(final Name name) throws NamingException { final int size = name.size(); if (size < 3) { return new RelativeContext(new FastHashtable<>(getEnvironment()), this, SimpleName.of(name)); } else if (size > 4) { throw nameNotFound(name); break; } else if (cp == '?') { throw nameNotFound(name); if (size == 3) { return new RelativeContext(new FastHashtable<>(getEnvironment()), this, SimpleName.of(name)); throw nameNotFound(name); view = Class.forName(viewType, false, getContextClassLoader()); } catch (ClassNotFoundException e) { throw Logs.MAIN.lookupFailed(name, name, e); Long invocationTimeout = getLongValueFromEnvironment(PROPERTY_KEY_INVOCATION_TIMEOUT); if (invocationTimeout != null) { EJBClient.setInvocationTimeout(proxy, invocationTimeout.longValue(), TimeUnit.MILLISECONDS);
/** * Check if the user has specified strong affinity to a cluster for this context and return the cluster name. * @return String the name of the cluster */ private String getClusterAffinityValueFromEnvironment() { Object val; try { val = getEnvironment().get(EJBClient.CLUSTER_AFFINITY); if (val != null && val instanceof String) { return (String) val; } return getLegacyClusterAffinity(); } catch(NamingException ne) { Logs.MAIN.warn("Problem reading cluster affinity specification from env; skipping affinity assignment"); return null; } }
EJBRootContext(final NamingProvider namingProvider, final FastHashtable<String, Object> env, final ProviderEnvironment providerEnvironment) { super(env); this.namingProvider = namingProvider; this.providerEnvironment = providerEnvironment; // TODO, Switch to providerEnvironment using WildFLy Naming, when attachments are added Object learned = env.get(LEARNED_AFFINITY_KEY); if (learned == null || ! (learned instanceof LearnedAffinity)) { // check if strong affinity for this context has been set in the environment String clusterName = getClusterAffinityValueFromEnvironment(); if (clusterName != null) { learned = new LearnedAffinity(new ClusterAffinity(clusterName)); } else { learned = new LearnedAffinity(shouldLearnAffinity() ? null : Affinity.NONE); } env.put(LEARNED_AFFINITY_KEY, learned); } this.baseAffinity = (LearnedAffinity) learned; }
/** * Check if the user has disabled affinity learning */ private boolean shouldLearnAffinity() { Object val = null; try { val = getEnvironment().get(EJBClient.DISABLE_AFFINITY_LEARNING); } catch(NamingException ne) { Logs.MAIN.warn("Problem reading cluster affinity specification from env; skipping affinity assignment"); } return val == null || "false".equalsIgnoreCase(val.toString()); }
protected CloseableNamingEnumeration<NameClassPair> listNative(final Name name) throws NamingException { throw notSupported(); }
public Context createRootContext(final NamingProvider namingProvider, final String nameScheme, final FastHashtable<String, Object> env, final ProviderEnvironment providerEnvironment) throws NamingException { assert nameScheme.equals("ejb"); return new EJBRootContext(namingProvider, env, providerEnvironment); } }
private static ClassLoader getContextClassLoader(){ final SecurityManager sm = System.getSecurityManager(); ClassLoader classLoader; if (sm != null) { classLoader = AccessController.doPrivileged((PrivilegedAction<ClassLoader>) EJBRootContext::doGetContextClassLoader); } else { classLoader = doGetContextClassLoader(); } return classLoader; }