public static CDIExtension getInitializedExtension() { try { InitialContext ic = InitialContextHelper.getInitialContext(); if (ic == null) { throw new RuntimeException(); } return (CDIExtension)lookupJerseyConfigJNDIContext(ic).lookup(JNDI_CDIEXTENSION_NAME); } catch (NamingException ex) { throw new RuntimeException(ex); } }
public static CDIExtension getInitializedExtension() { try { InitialContext ic = InitialContextHelper.getInitialContext(); if (ic == null) { throw new RuntimeException(); } return (CDIExtension)lookupJerseyConfigJNDIContext(ic).lookup(JNDI_CDIEXTENSION_NAME); } catch (NamingException ex) { throw new RuntimeException(ex); } }
private static Object lookupInJndi(String name) { try { InitialContext ic = InitialContextHelper.getInitialContext(); if (ic == null) { return null; } Object beanManager = ic.lookup(name); // Some implementations of InitialContext return null instead of // throwing NamingException if there is no Object associated with // the name if (beanManager == null) { LOGGER.config("The CDI BeanManager is not available at " + name); return null; } LOGGER.config("The CDI BeanManager is at " + name); return beanManager; } catch (NamingException ex) { LOGGER.log(Level.CONFIG, "The CDI BeanManager is not available at " + name, ex); } return null; }
public static CDIExtension getInitializedExtension() { try { InitialContext ic = InitialContextHelper.getInitialContext(); if (ic == null) { throw new RuntimeException(); } return (CDIExtension)lookupJerseyConfigJNDIContext(ic).lookup(JNDI_CDIEXTENSION_NAME); } catch (NamingException ex) { throw new RuntimeException(ex); } }
private static Object lookupInJndi(String name) { try { InitialContext ic = InitialContextHelper.getInitialContext(); if (ic == null) { return null; } Object beanManager = ic.lookup(name); // Some implementations of InitialContext return null instead of // throwing NamingException if there is no Object associated with // the name if (beanManager == null) { LOGGER.config("The CDI BeanManager is not available at " + name); return null; } LOGGER.config("The CDI BeanManager is at " + name); return beanManager; } catch (NamingException ex) { LOGGER.log(Level.CONFIG, "The CDI BeanManager is not available at " + name, ex); } return null; }
private static Object lookupInJndi(String name) { try { InitialContext ic = InitialContextHelper.getInitialContext(); if (ic == null) { return null; } Object beanManager = ic.lookup(name); // Some implementations of InitialContext return null instead of // throwing NamingException if there is no Object associated with // the name if (beanManager == null) { LOGGER.config("The CDI BeanManager is not available at " + name); return null; } LOGGER.config("The CDI BeanManager is at " + name); return beanManager; } catch (NamingException ex) { LOGGER.log(Level.CONFIG, "The CDI BeanManager is not available at " + name, ex); } return null; }
private void initialize(BeanManager manager) { // initialize in a separate method because Weld creates a proxy for the extension // and we don't want to waste time initializing it // workaround for Weld proxy bug if (!lookupExtensionInBeanManager) { try { InitialContext ic = InitialContextHelper.getInitialContext(); if (ic != null) { javax.naming.Context jerseyConfigJNDIContext = createJerseyConfigJNDIContext(ic); jerseyConfigJNDIContext.rebind(JNDI_CDIEXTENSION_NAME, this); } } catch (NamingException ex) { throw new RuntimeException(ex); } } // tracks all discovered parameters Map<Class<? extends Annotation>, Set<DiscoveredParameter>> map2 = new HashMap<Class<? extends Annotation>, Set<DiscoveredParameter>>(); for (Class<? extends Annotation> qualifier : knownParameterQualifiers) { map2.put(qualifier, new HashSet<DiscoveredParameter>()); } discoveredParameterMap = Collections.unmodifiableMap(map2); // tracks the synthetic qualifiers we have to create to handle a specific // combination of JAX-RS injection annotation + default value + encoded syntheticQualifierMap = new HashMap<DiscoveredParameter, SyntheticQualifier>(); // things to do in a second time, i.e. once Jersey has been initialized, // as opposed to when CDI delivers the SPI events to its extensions toBeInitializedLater = new ArrayList<InitializedLater>(); }
void lateInitialize() { try { for (InitializedLater object : toBeInitializedLater) { object.later(); } } finally { // clear the JNDI reference as soon as possible if (!lookupExtensionInBeanManager) { try { InitialContext ic = InitialContextHelper.getInitialContext(); if (ic != null) { lookupJerseyConfigJNDIContext(ic).unbind(JNDI_CDIEXTENSION_NAME); } } catch (NamingException ex) { throw new RuntimeException(ex); } } } }
private void initialize(BeanManager manager) { // initialize in a separate method because Weld creates a proxy for the extension // and we don't want to waste time initializing it // workaround for Weld proxy bug if (!lookupExtensionInBeanManager) { try { InitialContext ic = InitialContextHelper.getInitialContext(); if (ic != null) { javax.naming.Context jerseyConfigJNDIContext = createJerseyConfigJNDIContext(ic); jerseyConfigJNDIContext.rebind(JNDI_CDIEXTENSION_NAME, this); } } catch (NamingException ex) { throw new RuntimeException(ex); } } // tracks all discovered parameters Map<Class<? extends Annotation>, Set<DiscoveredParameter>> map2 = new HashMap<Class<? extends Annotation>, Set<DiscoveredParameter>>(); for (Class<? extends Annotation> qualifier : knownParameterQualifiers) { map2.put(qualifier, new HashSet<DiscoveredParameter>()); } discoveredParameterMap = Collections.unmodifiableMap(map2); // tracks the synthetic qualifiers we have to create to handle a specific // combination of JAX-RS injection annotation + default value + encoded syntheticQualifierMap = new HashMap<DiscoveredParameter, SyntheticQualifier>(); // things to do in a second time, i.e. once Jersey has been initialized, // as opposed to when CDI delivers the SPI events to its extensions toBeInitializedLater = new ArrayList<InitializedLater>(); }
private void initialize(BeanManager manager) { // initialize in a separate method because Weld creates a proxy for the extension // and we don't want to waste time initializing it // workaround for Weld proxy bug if (!lookupExtensionInBeanManager) { try { InitialContext ic = InitialContextHelper.getInitialContext(); if (ic != null) { javax.naming.Context jerseyConfigJNDIContext = createJerseyConfigJNDIContext(ic); jerseyConfigJNDIContext.rebind(JNDI_CDIEXTENSION_NAME, this); } } catch (NamingException ex) { throw new RuntimeException(ex); } } // tracks all discovered parameters Map<Class<? extends Annotation>, Set<DiscoveredParameter>> map2 = new HashMap<Class<? extends Annotation>, Set<DiscoveredParameter>>(); for (Class<? extends Annotation> qualifier : knownParameterQualifiers) { map2.put(qualifier, new HashSet<DiscoveredParameter>()); } discoveredParameterMap = Collections.unmodifiableMap(map2); // tracks the synthetic qualifiers we have to create to handle a specific // combination of JAX-RS injection annotation + default value + encoded syntheticQualifierMap = new HashMap<DiscoveredParameter, SyntheticQualifier>(); // things to do in a second time, i.e. once Jersey has been initialized, // as opposed to when CDI delivers the SPI events to its extensions toBeInitializedLater = new ArrayList<InitializedLater>(); }
private void configureJndiResources(ResourceConfig rc) { // Obtain any instances that are registered in JNDI // Assumes such instances are singletons // Registered classes have to be interfaces javax.naming.Context x = InitialContextHelper.getInitialContext(); if (x != null) { Iterator<Class<?>> i = rc.getClasses().iterator(); while (i.hasNext()) { Class<?> c = i.next(); if (!c.isInterface()) continue; try { Object o = x.lookup(c.getName()); if (o != null) { i.remove(); rc.getSingletons().add(o); LOGGER.log(Level.INFO, "An instance of the class " + c.getName() + " is found by JNDI look up using the class name as the JNDI name. " + "The instance will be registered as a singleton."); } } catch (NamingException ex) { LOGGER.log(Level.CONFIG, "JNDI lookup failed for Jersey application resource " + c.getName(), ex); } } } }
private void configureJndiResources(ResourceConfig rc) { // Obtain any instances that are registered in JNDI // Assumes such instances are singletons // Registered classes have to be interfaces javax.naming.Context x = InitialContextHelper.getInitialContext(); if (x != null) { Iterator<Class<?>> i = rc.getClasses().iterator(); while (i.hasNext()) { Class<?> c = i.next(); if (!c.isInterface()) continue; try { Object o = x.lookup(c.getName()); if (o != null) { i.remove(); rc.getSingletons().add(o); LOGGER.log(Level.INFO, "An instance of the class " + c.getName() + " is found by JNDI look up using the class name as the JNDI name. " + "The instance will be registered as a singleton."); } } catch (NamingException ex) { LOGGER.log(Level.CONFIG, "JNDI lookup failed for Jersey application resource " + c.getName(), ex); } } } }
private void configureJndiResources(ResourceConfig rc) { // Obtain any instances that are registered in JNDI // Assumes such instances are singletons // Registered classes have to be interfaces javax.naming.Context x = InitialContextHelper.getInitialContext(); if (x != null) { Iterator<Class<?>> i = rc.getClasses().iterator(); while (i.hasNext()) { Class<?> c = i.next(); if (!c.isInterface()) continue; try { Object o = x.lookup(c.getName()); if (o != null) { i.remove(); rc.getSingletons().add(o); LOGGER.log(Level.INFO, "An instance of the class " + c.getName() + " is found by JNDI look up using the class name as the JNDI name. " + "The instance will be registered as a singleton."); } } catch (NamingException ex) { LOGGER.log(Level.CONFIG, "JNDI lookup failed for Jersey application resource " + c.getName(), ex); } } } }
void lateInitialize() { try { for (InitializedLater object : toBeInitializedLater) { object.later(); } } finally { // clear the JNDI reference as soon as possible if (!lookupExtensionInBeanManager) { try { InitialContext ic = InitialContextHelper.getInitialContext(); if (ic != null) { lookupJerseyConfigJNDIContext(ic).unbind(JNDI_CDIEXTENSION_NAME); } } catch (NamingException ex) { throw new RuntimeException(ex); } } } }
public static void initialize(ResourceConfig rc) { try { InitialContext ic = InitialContextHelper.getInitialContext(); if (ic == null) { return;
public static void initialize(ResourceConfig rc) { try { InitialContext ic = InitialContextHelper.getInitialContext(); if (ic == null) { return;
void lateInitialize() { try { for (InitializedLater object : toBeInitializedLater) { object.later(); } } finally { // clear the JNDI reference as soon as possible if (!lookupExtensionInBeanManager) { try { InitialContext ic = InitialContextHelper.getInitialContext(); if (ic != null) { lookupJerseyConfigJNDIContext(ic).unbind(JNDI_CDIEXTENSION_NAME); } } catch (NamingException ex) { throw new RuntimeException(ex); } } } }
public static void initialize(ResourceConfig rc) { try { InitialContext ic = InitialContextHelper.getInitialContext(); if (ic == null) { return;
public static void initialize(ResourceConfig rc) { try { InitialContext ic = InitialContextHelper.getInitialContext(); if (ic == null) { return;
public static void initialize(ResourceConfig rc) { try { InitialContext ic = InitialContextHelper.getInitialContext(); if (ic == null) { return;