if (node.getType().getElementName().equalsIgnoreCase("appender")) { for (final Node cnode : node.getChildren()) { final Node appNode = new Node(cnode); config.createConfiguration(appNode, event); if (appNode.getObject() instanceof Appender) {
PluginType<NullAppender> nullAppenderType = new PluginType<>(nullAppenderEntry, NullAppender.class, "appender"); Node nullAppenderChildNode = new Node(null, "test-null-appender", nullAppenderType); defaultRouteEntry.setClassName(Route.class.getName()); PluginType<Route> defaultRouteType = new PluginType<>(defaultRouteEntry, Route.class, ""); Node defaultRouteNode = new Node(null, "test-route-default", defaultRouteType); queryIdRouteEntry.setClassName(Route.class.getName()); PluginType<Route> queryIdRouteType = new PluginType<>(queryIdRouteEntry, Route.class, ""); Node queryIdRouteNode = new Node(null, "test-route-mdc", queryIdRouteType); HushableRandomAccessFileAppender.class, "appender"); Node queryIdAppenderNode = new Node(queryIdRouteNode, "test-query-file-appender", queryIdAppenderType); queryIdAppenderNode.getAttributes().put("fileName", logLocation + "/${ctx:sessionId}/${ctx:queryId}.test"); PluginType<TestFilter> filterType = new PluginType<>(filterEntry, TestFilter.class, ""); Node filterNode = new Node(queryIdAppenderNode, "test-filter", filterType); PluginType<PatternLayout> layoutType = new PluginType<>(layoutEntry, PatternLayout.class, ""); Node layoutNode = new Node(queryIdAppenderNode, "PatternLayout", layoutType); layoutNode.getAttributes().put("pattern", LogDivertAppender.nonVerboseLayout);
@SuppressWarnings("unchecked") @Before public void setUp() throws Exception { final PluginManager manager = new PluginManager("Test"); manager.collectPlugins(); plugin = (PluginType<HostAndPort>) manager.getPluginType("HostAndPort"); assertNotNull("Rebuild this module to ensure annotation processing has been done.", plugin); node = new Node(null, "HostAndPort", plugin); node.getAttributes().put("host", "localhost"); }
nullEntry.setName("appender"); PluginType<NullAppender> nullChildType = new PluginType<NullAppender>(nullEntry, NullAppender.class, "appender"); Node nullChildNode = new Node(null, "Null", nullChildType); defaultEntry.setName("Route"); PluginType<Route> defaultType = new PluginType<Route>(defaultEntry, Route.class, "Route"); Node nullNode = new Node(null, "Route", defaultType); nullNode.getChildren().add(nullChildNode); Route defaultRoute = Route.createRoute(null, "${ctx:queryId}", nullNode); entry.setName("Route"); PluginType<Route> type = new PluginType<Route>(entry, Route.class, "Route"); Node node = new Node(null, "Route", type); childEntry.setName("appender"); PluginType<HushableRandomAccessFileAppender> childType = new PluginType<>(childEntry, HushableRandomAccessFileAppender.class, "appender"); Node childNode = new Node(node, "HushableMutableRandomAccess", childType); childNode.getAttributes().put("name", "query-file-appender"); childNode.getAttributes().put("fileName", logLocation + "/${ctx:sessionId}/${ctx:queryId}"); filterEntry.setName("namefilter"); PluginType<NameFilter> filterType = new PluginType<>(filterEntry, NameFilter.class, "filter"); Node filterNode = new Node(childNode, "NameFilter", filterType); filterNode.getAttributes().put("loggingLevel", loggingMode.name()); childNode.getChildren().add(filterNode); layoutEntry.setName("layout"); PluginType<PatternLayout> layoutType = new PluginType<>(layoutEntry, PatternLayout.class, "layout"); Node layoutNode = new Node(childNode, "PatternLayout", layoutType);
@SuppressWarnings("unchecked") @Before public void setUp() throws Exception { final PluginManager manager = new PluginManager("Test"); manager.collectPlugins(); plugin = (PluginType<PluginWithGenericSubclassFoo1Builder>) manager.getPluginType("PluginWithGenericSubclassFoo1Builder"); assertNotNull("Rebuild this module to make sure annotaion processing kicks in.", plugin); node = new Node(null, "Validator", plugin); }
@SuppressWarnings("unchecked") @Before public void setUp() throws Exception { final PluginManager manager = new PluginManager("Test"); manager.collectPlugins(); plugin = (PluginType<ValidatingPlugin>) manager.getPluginType("Validator"); assertNotNull("Rebuild this module to make sure annotaion processing kicks in.", plugin); node = new Node(null, "Validator", plugin); }
@SuppressWarnings("unchecked") @Before public void setUp() throws Exception { final PluginManager manager = new PluginManager("Test"); manager.collectPlugins(); plugin = (PluginType<ValidatingPluginWithGenericBuilder>) manager.getPluginType("ValidatingPluginWithGenericBuilder"); assertNotNull("Rebuild this module to make sure annotaion processing kicks in.", plugin); node = new Node(null, "Validator", plugin); }
@SuppressWarnings("unchecked") @Before public void setUp() throws Exception { final PluginManager manager = new PluginManager("Test"); manager.collectPlugins(); plugin = (PluginType<HostAndPort>) manager.getPluginType("HostAndPort"); assertNotNull("Rebuild this module to ensure annotation processing has been done.", plugin); node = new Node(null, "HostAndPort", plugin); }
@SuppressWarnings("unchecked") @Before public void setUp() throws Exception { final PluginManager manager = new PluginManager("Test"); manager.collectPlugins(); plugin = (PluginType<ValidatingPluginWithTypedBuilder>) manager .getPluginType("ValidatingPluginWithTypedBuilder"); assertNotNull("Rebuild this module to make sure annotaion processing kicks in.", plugin); node = new Node(null, "Validator", plugin); }
/** * Constructor. */ protected AbstractConfiguration(final LoggerContext loggerContext, final ConfigurationSource configurationSource) { this.loggerContext = new WeakReference<>(loggerContext); // The loggerContext is null for the NullConfiguration class. // this.loggerContext = new WeakReference(Objects.requireNonNull(loggerContext, "loggerContext is null")); this.configurationSource = Objects.requireNonNull(configurationSource, "configurationSource is null"); componentMap.put(Configuration.CONTEXT_PROPERTIES, properties); pluginManager = new PluginManager(Node.CATEGORY); rootNode = new Node(); setState(State.INITIALIZING); }
protected void createAdvertiser(final String advertiserString, final ConfigurationSource configSource, final byte[] buffer, final String contentType) { if (advertiserString != null) { final Node node = new Node(null, advertiserString, null); final Map<String, String> attributes = node.getAttributes(); attributes.put("content", new String(buffer)); attributes.put("contentType", contentType); attributes.put("name", "configuration"); if (configSource.getLocation() != null) { attributes.put("location", configSource.getLocation()); } advertiserNode = node; } }
public Node(final Node node) { this.parent = node.parent; this.name = node.name; this.type = node.type; this.attributes.putAll(node.getAttributes()); this.value = node.getValue(); for (final Node child : node.getChildren()) { this.children.add(new Node(child)); } this.object = node.object; }
private void updateFilterNode(final Node target, final Node targetChildNode, final Node sourceChildNode, final PluginManager pluginManager) { if (CompositeFilter.class.isAssignableFrom(targetChildNode.getType().getPluginClass())) { final Node node = new Node(targetChildNode, sourceChildNode.getName(), sourceChildNode.getType()); node.getChildren().addAll(sourceChildNode.getChildren()); node.getAttributes().putAll(sourceChildNode.getAttributes()); targetChildNode.getChildren().add(node); } else { final PluginType pluginType = pluginManager.getPluginType(FILTERS); final Node filtersNode = new Node(targetChildNode, FILTERS, pluginType); final Node node = new Node(filtersNode, sourceChildNode.getName(), sourceChildNode.getType()); node.getAttributes().putAll(sourceChildNode.getAttributes()); final List<Node> children = filtersNode.getChildren(); children.add(targetChildNode); children.add(node); final List<Node> nodes = target.getChildren(); nodes.remove(targetChildNode); nodes.add(filtersNode); } }
private Node constructNode(final String name, final Node parent, final JsonNode jsonNode) { final PluginType<?> type = pluginManager.getPluginType(name); final Node node = new Node(parent, name, type); processAttributes(node, jsonNode); final Iterator<Map.Entry<String, JsonNode>> iter = jsonNode.fields(); final String pluginType = getType(n.get(i), entry.getKey()); final PluginType<?> entryType = pluginManager.getPluginType(pluginType); final Node item = new Node(node, entry.getKey(), entryType); processAttributes(item, n.get(i)); if (pluginType.equals(entry.getKey())) {
if (node.getType().getElementName().equalsIgnoreCase("appender")) { for (final Node cnode : node.getChildren()) { final Node appNode = new Node(cnode); config.createConfiguration(appNode, event); if (appNode.getObject() instanceof Appender) {
final String name = getType(child); final PluginType<?> type = pluginManager.getPluginType(name); final Node childNode = new Node(node, name, type); constructHierarchy(childNode, child); if (type == null) {
protected Node convertToNode(final Node parent, final Component component) { final String name = component.getPluginType(); final PluginType<?> pluginType = pluginManager.getPluginType(name); final Node node = new Node(parent, name, pluginType); node.getAttributes().putAll(component.getAttributes()); node.setValue(component.getValue()); final List<Node> children = node.getChildren(); for (final Component child : component.getComponents()) { children.add(convertToNode(node, child)); } return node; } }
public Appender createAppender(final String appenderName, final String actualName) { final Node node = nodeMap.get(appenderName); if (node == null) { LOGGER.error("No node named {} in {}", appenderName, this); return null; } node.getAttributes().put("name", actualName); if (node.getType().getElementName().equals(Appender.ELEMENT_TYPE)) { final Node appNode = new Node(node); configuration.createConfiguration(appNode, null); if (appNode.getObject() instanceof Appender) { final Appender app = appNode.getObject(); app.start(); return app; } LOGGER.error("Unable to create Appender of type " + node.getName()); return null; } LOGGER.error("No Appender was configured for name {} " + appenderName); return null; } }
final Node loggerNode = new Node(targetChildNode, node.getName(), node.getType()); if (targetNode != null) { targetNode.getAttributes().putAll(node.getAttributes()); final Node childNode = new Node(loggerNode, sourceLoggerChild.getName(), sourceLoggerChild.getType()); targetNode.getChildren().add(childNode); final Node childNode = new Node(loggerNode, sourceLoggerChild.getName(), sourceLoggerChild.getType()); childNode.getAttributes().putAll(sourceLoggerChild.getAttributes());
private Appender createAppender(final Route route, final LogEvent event) { final Node routeNode = route.getNode(); for (final Node node : routeNode.getChildren()) { if (node.getType().getElementName().equals(Appender.ELEMENT_TYPE)) { final Node appNode = new Node(node); configuration.createConfiguration(appNode, event); if (appNode.getObject() instanceof Appender) { final Appender app = appNode.getObject(); app.start(); return app; } error("Unable to create Appender of type " + node.getName()); return null; } } error("No Appender was configured for route " + route.getKey()); return null; }