@Override public void handleTimeout(InetAddress address, EchoPacket request) { String oldPrefix = ThreadCategory.getPrefix(); try { ThreadCategory.setPrefix(m_prefix); m_cb.handleTimeout(address, request); } finally { ThreadCategory.setPrefix(oldPrefix); } }
@Override public void handleResponse(InetAddress address, EchoPacket response) { String oldPrefix = ThreadCategory.getPrefix(); try { ThreadCategory.setPrefix(m_prefix); m_cb.handleResponse(address, response); } finally { ThreadCategory.setPrefix(oldPrefix); } }
public class LogPrefixPreservingPingResponseCallback implements PingResponseCallback { private final PingResponseCallback m_cb; private final String m_prefix = ThreadCategory.getPrefix(); public LogPrefixPreservingPingResponseCallback(PingResponseCallback cb) { m_cb = cb; } @Override public void handleError(InetAddress address, EchoPacket request, Throwable t) { String oldPrefix = ThreadCategory.getPrefix(); try { ThreadCategory.setPrefix(m_prefix); m_cb.handleError(address, request, t); } finally { ThreadCategory.setPrefix(oldPrefix); } } @Override public void handleResponse(InetAddress address, EchoPacket response) { String oldPrefix = ThreadCategory.getPrefix(); try { ThreadCategory.setPrefix(m_prefix); m_cb.handleResponse(address, response); } finally { ThreadCategory.setPrefix(oldPrefix); } } @Override public void handleTimeout(InetAddress address, EchoPacket request) { String oldPrefix = ThreadCategory.getPrefix(); try { ThreadCategory.setPrefix(m_prefix); m_cb.handleTimeout(address, request); } finally { ThreadCategory.setPrefix(oldPrefix); } } }
/** Constructor for DefaultReportWrapperService. */ public DefaultReportWrapperService() { String oldPrefix = ThreadCategory.getPrefix(); ThreadCategory.setPrefix(LOG4J_CATEGORY); log = ThreadCategory.getInstance(DefaultReportWrapperService.class); ThreadCategory.setPrefix(oldPrefix); }
/** Constructor for XMPPNotificationManager. */ protected XMPPNotificationManager() { // get the category logger String oldPrefix = ThreadCategory.getPrefix(); ThreadCategory.setPrefix(LOG4J_CATEGORY); try { // Load up some properties File config = null; try { config = ConfigFileConstants.getFile(ConfigFileConstants.XMPP_CONFIG_FILE_NAME); } catch (IOException e) { log().warn(ConfigFileConstants.XMPP_CONFIG_FILE_NAME + " not readable", e); } if (Boolean.getBoolean("useSystemXMPPConfig") || !config.canRead()) { this.props.putAll(System.getProperties()); } else { FileInputStream fis = null; try { fis = new FileInputStream(config); this.props.load(fis); } catch (FileNotFoundException e) { log().warn("unable to load " + config, e); } catch (IOException e) { log().warn("unable to load " + config, e); } finally { IOUtils.closeQuietly(fis); } } xmppServer = this.props.getProperty("xmpp.server"); xmppServiceName = this.props.getProperty("xmpp.servicename", xmppServer); xmppUser = this.props.getProperty("xmpp.user"); xmppPassword = this.props.getProperty("xmpp.pass"); xmppPort = Integer.valueOf(this.props.getProperty("xmpp.port", XMPP_PORT)); xmppConfig = new ConnectionConfiguration(xmppServer, xmppPort, xmppServiceName); boolean debuggerEnabled = Boolean.parseBoolean(props.getProperty("xmpp.debuggerEnabled")); xmppConfig.setDebuggerEnabled(debuggerEnabled); if (debuggerEnabled) { log().setLevel(ThreadCategory.Level.DEBUG); } xmppConfig.setSASLAuthenticationEnabled( Boolean.parseBoolean(props.getProperty("xmpp.SASLEnabled", "true"))); xmppConfig.setSelfSignedCertificateEnabled( Boolean.parseBoolean(props.getProperty("xmpp.selfSignedCertificateEnabled"))); if (Boolean.parseBoolean(props.getProperty("xmpp.TLSEnabled"))) { xmppConfig.setSecurityMode(SecurityMode.enabled); } else { xmppConfig.setSecurityMode(SecurityMode.disabled); } if (this.props.containsKey("xmpp.truststorePassword")) { xmppConfig.setTruststorePassword(this.props.getProperty("xmpp.truststorePassword")); } else { xmppConfig.setTruststorePassword(TRUST_STORE_PASSWORD); } if (log().isDebugEnabled()) { log().debug("XMPP Manager connection config: " + xmppConfig.toString()); } xmpp = new XMPPConnection(xmppConfig); // Connect to xmpp server connectToServer(); } finally { ThreadCategory.setPrefix(oldPrefix); } }