private static Logger doLegacyGetLogger(final String name) { final org.jboss.logmanager.Logger lmLogger = LogContext.getLogContext().getLogger(""); ConcurrentMap<String, Logger> loggers = lmLogger.getAttachment(LEGACY_KEY); if (loggers == null) { loggers = new ConcurrentHashMap<String, Logger>(); final ConcurrentMap<String, Logger> appearing = lmLogger.attachIfAbsent(LEGACY_KEY, loggers); if (appearing != null) { loggers = appearing; } } Logger l = loggers.get(name); if (l != null) { return l; } final org.jboss.logmanager.Logger logger = org.jboss.logmanager.Logger.getLogger(name); l = new JBossLogManagerLogger(name, logger); final Logger appearing = loggers.putIfAbsent(name, l); if (appearing == null) { return l; } return appearing; }
private static Logger doGetLogger(final String name) { Logger l = LogContext.getLogContext().getAttachment(name, KEY); if (l != null) { return l; } final org.jboss.logmanager.Logger logger = org.jboss.logmanager.Logger.getLogger(name); l = new JBossLogManagerLogger(name, logger); Logger a = logger.attachIfAbsent(KEY, l); if (a == null) { return l; } else { return a; } }
private Map<String, Object> getAttributeMap() { final Logger rootLogger = Logger.getLogger(""); Map<String, Object> map = rootLogger.getAttachment(ATTRIBUTE_KEY); if (map == null) { map = Collections.synchronizedMap(new HashMap<String, Object>()); final Map<String, Object> appearing = rootLogger.attachIfAbsent(ATTRIBUTE_KEY, map); if (appearing != null) { map = appearing; } } return map; } }
public LoggerPluginInstance getInstance(String name, String resourceBundleName) { Logger logger = resourceBundleName == null ? Logger.getLogger(name) : Logger.getLogger(name, resourceBundleName); LoggerPluginInstance lpi = logger.getAttachment(KEY); if (lpi == null) { final SecurityManager sm = System.getSecurityManager(); lpi = new LoggerPluginInstanceImpl(name, resourceBundleName, logger, this); if (sm != null) { return AccessController.doPrivileged(new AttachAction(logger, lpi)); } else { return doAttach(logger, lpi); } } return lpi; }
private static Logger doLegacyGetLogger(final String name) { final org.jboss.logmanager.Logger lmLogger = LogContext.getLogContext().getLogger(""); ConcurrentMap<String, Logger> loggers = lmLogger.getAttachment(LEGACY_KEY); if (loggers == null) { loggers = new ConcurrentHashMap<String, Logger>(); final ConcurrentMap<String, Logger> appearing = lmLogger.attachIfAbsent(LEGACY_KEY, loggers); if (appearing != null) { loggers = appearing; } } Logger l = loggers.get(name); if (l != null) { return l; } final org.jboss.logmanager.Logger logger = org.jboss.logmanager.Logger.getLogger(name); l = new JBossLogManagerLogger(name, logger); final Logger appearing = loggers.putIfAbsent(name, l); if (appearing == null) { return l; } return appearing; }
private static Logger doLegacyGetLogger(final String name) { final org.jboss.logmanager.Logger lmLogger = LogContext.getLogContext().getLogger(""); ConcurrentMap<String, Logger> loggers = lmLogger.getAttachment(LEGACY_KEY); if (loggers == null) { loggers = new ConcurrentHashMap<String, Logger>(); final ConcurrentMap<String, Logger> appearing = lmLogger.attachIfAbsent(LEGACY_KEY, loggers); if (appearing != null) { loggers = appearing; } } Logger l = loggers.get(name); if (l != null) { return l; } final org.jboss.logmanager.Logger logger = org.jboss.logmanager.Logger.getLogger(name); l = new JBossLogManagerLogger(name, logger); final Logger appearing = loggers.putIfAbsent(name, l); if (appearing == null) { return l; } return appearing; }
private static Logger doLegacyGetLogger(final String name) { final org.jboss.logmanager.Logger lmLogger = LogContext.getLogContext().getLogger(""); ConcurrentMap<String, Logger> loggers = lmLogger.getAttachment(LEGACY_KEY); if (loggers == null) { loggers = new ConcurrentHashMap<String, Logger>(); final ConcurrentMap<String, Logger> appearing = lmLogger.attachIfAbsent(LEGACY_KEY, loggers); if (appearing != null) { loggers = appearing; } } Logger l = loggers.get(name); if (l != null) { return l; } final org.jboss.logmanager.Logger logger = org.jboss.logmanager.Logger.getLogger(name); l = new JBossLogManagerLogger(name, logger); final Logger appearing = loggers.putIfAbsent(name, l); if (appearing == null) { return l; } return appearing; }
private static Logger doGetLogger(final String name) { Logger l = LogContext.getLogContext().getAttachment(name, KEY); if (l != null) { return l; } final org.jboss.logmanager.Logger logger = org.jboss.logmanager.Logger.getLogger(name); l = new JBossLogManagerLogger(name, logger); Logger a = logger.attachIfAbsent(KEY, l); if (a == null) { return l; } else { return a; } }
private static Logger doGetLogger(final String name) { Logger l = LogContext.getLogContext().getAttachment(name, KEY); if (l != null) { return l; } final org.jboss.logmanager.Logger logger = org.jboss.logmanager.Logger.getLogger(name); l = new JBossLogManagerLogger(name, logger); Logger a = logger.attachIfAbsent(KEY, l); if (a == null) { return l; } else { return a; } }
private static Logger doGetLogger(final String name) { Logger l = LogContext.getLogContext().getAttachment(name, KEY); if (l != null) { return l; } final org.jboss.logmanager.Logger logger = org.jboss.logmanager.Logger.getLogger(name); l = new JBossLogManagerLogger(name, logger); Logger a = logger.attachIfAbsent(KEY, l); if (a == null) { return l; } else { return a; } }
private static Logger doGetLogger(final String name) { Logger l = LogContext.getLogContext().getAttachment(name, KEY); if (l != null) { return l; } final org.jboss.logmanager.Logger logger = org.jboss.logmanager.Logger.getLogger(name); l = new JBossLogManagerLogger(name, logger); Logger a = logger.attachIfAbsent(KEY, l); if (a == null) { return l; } else { return a; } }
private static Logger doGetLogger(final String name) { Logger l = LogContext.getLogContext().getAttachment(name, KEY); if (l != null) { return l; } final org.jboss.logmanager.Logger logger = org.jboss.logmanager.Logger.getLogger(name); l = new JBossLogManagerLogger(name, logger); Logger a = logger.attachIfAbsent(KEY, l); if (a == null) { return l; } else { return a; } }
private static Logger doGetLogger(final String name) { Logger l = LogContext.getLogContext().getAttachment(name, KEY); if (l != null) { return l; } final org.jboss.logmanager.Logger logger = org.jboss.logmanager.Logger.getLogger(name); l = new JBossLogManagerLogger(name, logger); Logger a = logger.attachIfAbsent(KEY, l); if (a == null) { return l; } else { return a; } }
private static Logger doGetLogger(final String name) { Logger l = LogContext.getLogContext().getAttachment(name, KEY); if (l != null) { return l; } final org.jboss.logmanager.Logger logger = org.jboss.logmanager.Logger.getLogger(name); l = new JBossLogManagerLogger(name, logger); Logger a = logger.attachIfAbsent(KEY, l); if (a == null) { return l; } else { return a; } }
private static Logger doGetLogger(final String name) { Logger l = LogContext.getLogContext().getAttachment(name, KEY); if (l != null) { return l; } final org.jboss.logmanager.Logger logger = org.jboss.logmanager.Logger.getLogger(name); l = new JBossLogManagerLogger(name, logger); Logger a = logger.attachIfAbsent(KEY, l); if (a == null) { return l; } else { return a; } }
private static Logger doGetLogger(final String name) { Logger l = LogContext.getLogContext().getAttachment(name, KEY); if (l != null) { return l; } final org.jboss.logmanager.Logger logger = org.jboss.logmanager.Logger.getLogger(name); l = new JBossLogManagerLogger(name, logger); Logger a = logger.attachIfAbsent(KEY, l); if (a == null) { return l; } else { return a; } }
@Override public Log getInstance(final String name) throws LogConfigurationException { Log log = LogContext.getLogContext().getAttachment(name, LOG_KEY); if (log != null) { return log; } final Logger logger = Logger.getLogger(name); log = new JBossLog(logger); final Log appearing = logger.attachIfAbsent(LOG_KEY, log); if (appearing != null) { log = appearing; } return log; }
@Test public void testMultipleConcurrentDurableSubscribers() throws Exception { org.jboss.logmanager.Logger.getLogger(StompConnection.class.getName()).setLevel(org.jboss.logmanager.Level.TRACE); int NUMBER_OF_THREADS = 25; SubscriberThread[] threads = new SubscriberThread[NUMBER_OF_THREADS]; final CountDownLatch startFlag = new CountDownLatch(1); final CountDownLatch alignFlag = new CountDownLatch(NUMBER_OF_THREADS); for (int i = 0; i < threads.length; i++) { threads[i] = new SubscriberThread("subscriber::" + i, StompClientConnectionFactory.createClientConnection(uri), startFlag, alignFlag); } for (SubscriberThread t : threads) { t.start(); } alignFlag.await(); startFlag.countDown(); for (SubscriberThread t : threads) { t.join(); Assert.assertEquals(0, t.errors.get()); } }
@Test public void testMultipleDurableSubscribers() throws Exception { org.jboss.logmanager.Logger.getLogger(StompConnection.class.getName()).setLevel(org.jboss.logmanager.Level.TRACE); conn.connect(defUser, defPass, "myClientID"); StompClientConnectionV12 conn2 = (StompClientConnectionV12) StompClientConnectionFactory.createClientConnection(uri); conn2.connect(defUser, defPass, "myClientID"); subscribe(conn, UUID.randomUUID().toString(), "client-individual", getName()); subscribe(conn2, UUID.randomUUID().toString(), "clientindividual", getName()); conn.closeTransport(); waitDisconnect(conn); conn2.closeTransport(); waitDisconnect(conn2); }
@Test public void testBasicPluginAuthorization() throws Exception { org.jboss.logmanager.Logger.getLogger(LDAPLoginModule.class.getName()).setLevel(org.jboss.logmanager.Level.DEBUG); org.jboss.logmanager.Logger.getLogger(LegacyLDAPSecuritySettingPlugin.class.getName()).setLevel(org.jboss.logmanager.Level.DEBUG); server.start(); ClientSessionFactory cf = locator.createSessionFactory(); String name = "TEST.FOO"; try { ClientSession session = cf.createSession("admin", "secret", false, true, true, false, 0); session.createQueue(SimpleString.toSimpleString(name), SimpleString.toSimpleString(name)); ClientProducer producer = session.createProducer(); producer.send(name, session.createMessage(false)); session.close(); } catch (ActiveMQException e) { e.printStackTrace(); Assert.fail("should not throw exception"); } cf.close(); } }