/** * Gets the logging prefix. * * @param svc the OpenNMS service * @return the logging prefix attribute */ private static Attribute getLoggingPrefix(Service svc) { for (Attribute a : svc.getAttributes()) { if (a.getName().equals("LoggingPrefix")) { return a; } } return null; }
private Attribute getAttribute(org.opennms.netmgt.config.service.Attribute attrib) throws Exception { Class<?> attribClass = Class.forName(attrib.getValue().getType()); Constructor<?> construct = attribClass.getConstructor(new Class[] { String.class }); Object value; Map<String,String> mdc = Logging.getCopyOfContextMap(); try { value = construct.newInstance(new Object[] { attrib.getValue().getContent() }); } finally { Logging.setContextMap(mdc); } return new Attribute(attrib.getName(), value); }
private Attribute getAttribute(org.opennms.netmgt.config.service.Attribute attrib) throws Exception { Class<?> attribClass = Class.forName(attrib.getValue().getType()); Constructor<?> construct = attribClass.getConstructor(new Class[] { String.class }); Object value; String log4jPrefix = ThreadCategory.getPrefix(); try { value = construct.newInstance(new Object[] { attrib.getValue().getContent() }); } finally { ThreadCategory.setPrefix(log4jPrefix); } return new Attribute(attrib.getName(), value); }
if (attribs != null) { for (final org.opennms.netmgt.config.service.Attribute attrib : attribs) { LOG.debug("setting attribute {}", attrib.getName()); getServer().setAttribute(name, getAttribute(attrib));
if (attrib.getName().equals("AuthenticationMethod")) { if (!attrib.getValue().getContent().equals("basic")) { LogUtils.errorf(this, "AuthenticationMethod is \"%s\", but only \"basic\" is supported", attrib.getValue());
if (log().isDebugEnabled()) { log().debug("setting attribute " + attrib.getName());