@Test public void testGetExistingContext() { ContextSelector selector = ContextSelectorStaticBinder.getSingleton().getContextSelector(); Context context = selector.getLoggerContext(); assertEquals("toto", context.getName()); }
public LoggerContext getLoggerContext() { String contextName = null; Context ctx = null; LoggerContext lc = threadLocal.get(); if (lc != null) { return lc; } try { ctx = JNDIUtil.getInitialContext(); contextName = (String) JNDIUtil.lookup(ctx, JNDI_CONTEXT_NAME); } catch (NamingException ne) { } if (contextName == null) { return defaultContext; } else { LoggerContext loggerContext = synchronizedContextMap.get(contextName); if (loggerContext == null) { loggerContext = new LoggerContext(); loggerContext.setName(contextName); synchronizedContextMap.put(contextName, loggerContext); URL url = findConfigFileURL(ctx, loggerContext); if (url != null) { configureLoggerContextByURL(loggerContext, url); } else { try { new ContextInitializer(loggerContext).autoConfig(); } catch (JoranException je) { } } if (!StatusUtil.contextHasStatusListener(loggerContext)) StatusPrinter.printInCaseOfErrorsOrWarnings(loggerContext); } return loggerContext; } }
ContextJNDISelector implements ContextSelector { public LoggerContext getLoggerContext() { String contextName = null; Context ctx = null; LoggerContext lc = threadLocal.get(); if (lc != null) { return lc; } try { ctx = JNDIUtil.getInitialContext(); contextName = (String) JNDIUtil.lookup(ctx, JNDI_CONTEXT_NAME); } catch (NamingException ne) { } if (contextName == null) { return defaultContext; } else { LoggerContext loggerContext = synchronizedContextMap.get(contextName); if (loggerContext == null) { loggerContext = new LoggerContext(); loggerContext.setName(contextName); synchronizedContextMap.put(contextName, loggerContext); URL url = findConfigFileURL(ctx, loggerContext); if (url != null) { configureLoggerContextByURL(loggerContext, url); } else { try { new ContextInitializer(loggerContext).autoConfig(); } catch (JoranException je) { } } if (!StatusUtil.contextHasStatusListener(loggerContext)) StatusPrinter.printInCaseOfErrorsOrWarnings(loggerContext); } return loggerContext; } } }
ContextJNDISelector implements ContextSelector { public LoggerContext getLoggerContext() { String contextName = null; Context ctx = null; LoggerContext lc = threadLocal.get(); if (lc != null) { return lc; } try { ctx = JNDIUtil.getInitialContext(); contextName = (String) JNDIUtil.lookup(ctx, JNDI_CONTEXT_NAME); } catch (NamingException ne) { } if (contextName == null) { return defaultContext; } else { LoggerContext loggerContext = synchronizedContextMap.get(contextName); if (loggerContext == null) { loggerContext = new LoggerContext(); loggerContext.setName(contextName); synchronizedContextMap.put(contextName, loggerContext); URL url = findConfigFileURL(ctx, loggerContext); if (url != null) { configureLoggerContextByURL(loggerContext, url); } else { try { new ContextInitializer(loggerContext).autoConfig(); } catch (JoranException je) { } } if (!StatusUtil.contextHasStatusListener(loggerContext)) StatusPrinter.printInCaseOfErrorsOrWarnings(loggerContext); } return loggerContext; } } ContextJNDISelector(LoggerContext context); }
ContextJNDISelector implements ContextSelector { public LoggerContext getLoggerContext() { String contextName = null; Context ctx = null; LoggerContext lc = threadLocal.get(); if (lc != null) { return lc; } try { ctx = JNDIUtil.getInitialContext(); contextName = (String) JNDIUtil.lookup(ctx, JNDI_CONTEXT_NAME); } catch (NamingException ne) { } if (contextName == null) { return defaultContext; } else { LoggerContext loggerContext = synchronizedContextMap.get(contextName); if (loggerContext == null) { loggerContext = new LoggerContext(); loggerContext.setName(contextName); synchronizedContextMap.put(contextName, loggerContext); URL url = findConfigFileURL(ctx, loggerContext); if (url != null) { configureLoggerContextByURL(loggerContext, url); } else { try { new ContextInitializer(loggerContext).autoConfig(); } catch (JoranException je) { } } if (!StatusUtil.contextHasStatusListener(loggerContext)) StatusPrinter.printInCaseOfErrorsOrWarnings(loggerContext); } return loggerContext; } } ContextJNDISelector(LoggerContext context); LoggerContext getDefaultLoggerContext(); LoggerContext detachLoggerContext(String loggerContextName); LoggerContext getLoggerContext(); List<String> getContextNames(); LoggerContext getLoggerContext(String name); int getCount(); void setLocalContext(LoggerContext context); void removeLocalContext(); }
ContextJNDISelector implements ContextSelector { public LoggerContext getLoggerContext() { String contextName = null; Context ctx = null; LoggerContext lc = threadLocal.get(); if (lc != null) { return lc; } try { ctx = JNDIUtil.getInitialContext(); contextName = (String) JNDIUtil.lookup(ctx, JNDI_CONTEXT_NAME); } catch (NamingException ne) { } if (contextName == null) { return defaultContext; } else { LoggerContext loggerContext = synchronizedContextMap.get(contextName); if (loggerContext == null) { loggerContext = new LoggerContext(); loggerContext.setName(contextName); synchronizedContextMap.put(contextName, loggerContext); URL url = findConfigFileURL(ctx, loggerContext); if (url != null) { configureLoggerContextByURL(loggerContext, url); } else { try { new ContextInitializer(loggerContext).autoConfig(); } catch (JoranException je) { } } if (!StatusUtil.contextHasStatusListener(loggerContext)) StatusPrinter.printInCaseOfErrorsOrWarnings(loggerContext); } return loggerContext; } } ContextJNDISelector(LoggerContext context); LoggerContext getDefaultLoggerContext(); LoggerContext detachLoggerContext(String loggerContextName); LoggerContext getLoggerContext(); List<String> getContextNames(); LoggerContext getLoggerContext(String name); int getCount(); void setLocalContext(LoggerContext context); void removeLocalContext();  }