private Appender<ILoggingEvent> configureAppender(LoggerContext loggerContext, String name, Config config) throws ReflectiveOperationException { List<Object> children = new ArrayList<>(); @SuppressWarnings("unchecked") Class<Appender<ILoggingEvent>> clazz = (Class<Appender<ILoggingEvent>>) Class .forName(config.getString("class")); Appender<ILoggingEvent> appender = this.configureObject(loggerContext, clazz, config, children); appender.setName(name); for (Object child : children) { if (child instanceof RollingPolicy) { ((RollingPolicy) child).setParent((FileAppender<?>) appender); } if (child instanceof LifeCycle) { ((LifeCycle) child).start(); } } appender.start(); return appender; }
/** * Once the children elements are also parsed, now is the time to activate the * appender options. */ public void end(InterpretationContext ec, String name) { if (inError) { return; } if (appender instanceof LifeCycle) { ((LifeCycle) appender).start(); } Object o = ec.peekObject(); if (o != appender) { addWarn("The object at the of the stack is not the appender named [" + appender.getName() + "] pushed earlier."); } else { ec.popObject(); } }
@Override public void end(InterpretationContext ec, String name) throws ActionException { if (inError) { return; } Object o = ec.peekObject(); if (o != lcl) { addWarn("The object on the top the of the stack is not the LoggerContextListener pushed earlier."); } else { if (lcl instanceof LifeCycle) { ((LifeCycle) lcl).start(); addInfo("Starting LoggerContextListener"); } ((LoggerContext) context).addListener(lcl); ec.popObject(); } }
private static void initAndAddListener(KonkerLoggerContext loggerContext, StatusListener listener) { if(listener != null) { if(listener instanceof ContextAware) { ((ContextAware)listener).setContext(loggerContext); } if(listener instanceof LifeCycle) { ((LifeCycle)listener).start(); } loggerContext.getStatusManager().add(listener); } }
/** * Resets this manager. * <p> * All registered components are stopped and removed from the manager. */ public void reset() { for (LifeCycle component : components) { if (component.isStarted()) { component.stop(); } } components.clear(); }
/** * Once the children elements are also parsed, now is the time to activate the * evaluator options. */ @SuppressWarnings("unchecked") public void end(InterpretationContext ec, String e) { if (inError) { return; } if (evaluator instanceof LifeCycle) { ((LifeCycle) evaluator).start(); addInfo("Starting evaluator named [" + evaluator.getName() + "]"); } Object o = ec.peekObject(); if (o != evaluator) { addWarn("The object on the top the of the stack is not the evaluator pushed earlier."); } else { ec.popObject(); try { Map<String, EventEvaluator<?>> evaluatorMap = (Map<String, EventEvaluator<?>>) context .getObject(CoreConstants.EVALUATOR_MAP); if(evaluatorMap == null) { addError("Could not find EvaluatorMap"); } else { evaluatorMap.put(evaluator.getName(), evaluator); } } catch (Exception ex) { addError("Could not set evaluator named [" + evaluator + "].", ex); } } }
public void end(InterpretationContext ec, String e) { if (inError) { return; } if (statusListener instanceof LifeCycle) { ((LifeCycle) statusListener).start(); } Object o = ec.peekObject(); if (o != statusListener) { addWarn("The object at the of the stack is not the statusListener pushed earlier."); } else { ec.popObject(); } }
private static void initAndAddListener(LoggerContext loggerContext, StatusListener listener) { if (listener != null) { if(listener instanceof ContextAware) // LOGBACK-767 ((ContextAware) listener).setContext(loggerContext); if(listener instanceof LifeCycle) // LOGBACK-767 ((LifeCycle) listener).start(); loggerContext.getStatusManager().add(listener); } }
private <T extends LifeCycle> T buildLifeCycle(T lifeCycle, boolean start) { if (lifeCycle instanceof ContextAware) { ((ContextAware) lifeCycle).setContext(this.loggerContext); } if (start) { lifeCycle.start(); } return lifeCycle; }
public void start(LifeCycle lifeCycle) { if (lifeCycle instanceof ContextAware) { ((ContextAware) lifeCycle).setContext(this.context); } lifeCycle.start(); }
public void register(LifeCycle component) { getLifeCycleManager().register(component); }
public void end(InterpretationContext ec, String tagName) { // pop the action data object pushed in isApplicable() method call // we assume that each this begin IADataForComplexProperty actionData = (IADataForComplexProperty) actionDataStack .pop(); if (actionData.inError) { return; } PropertySetter nestedBean = new PropertySetter(actionData .getNestedComplexProperty()); nestedBean.setContext(context); // have the nested element point to its parent if possible if (nestedBean.computeAggregationType("parent") == AggregationType.AS_COMPLEX_PROPERTY) { nestedBean.setComplexProperty("parent", actionData.parentBean.getObj()); } // start the nested complex property if it implements LifeCycle and is not // marked with a @NoAutoStart annotation Object nestedComplexProperty = actionData.getNestedComplexProperty(); if (nestedComplexProperty instanceof LifeCycle && NoAutoStartUtil.notMarkedWithNoAutoStart(nestedComplexProperty)) { ((LifeCycle) nestedComplexProperty).start(); } Object o = ec.peekObject(); if (o != actionData.getNestedComplexProperty()) { addError("The object on the top the of the stack is not the component pushed earlier."); } else { ec.popObject(); // Now let us attach the component switch (actionData.aggregationType) { case AS_COMPLEX_PROPERTY: actionData.parentBean.setComplexProperty(tagName, actionData .getNestedComplexProperty()); break; case AS_COMPLEX_PROPERTY_COLLECTION: actionData.parentBean.addComplexProperty(tagName, actionData .getNestedComplexProperty()); break; } } }
@Override public void register(LifeCycle component) { lastComponent = component; super.register(component); }
public LifeCycle getLastComponent() { return lastComponent; }
@Override public void register(LifeCycle component) { lifeCycleManager.register(component); }
@Override public void shutdown() { ((LifeCycle) LoggerFactory.getILoggerFactory()).stop(); }
@TearDown(Level.Trial) public void down() { ((LifeCycle) LoggerFactory.getILoggerFactory()).stop(); new File("perftest.log").delete(); }
/** * Register a component that participates in the context's life cycle. * <p> * All components registered via this method will be stopped and removed * from the context when the context is reset. * * @param component the subject component */ void register(LifeCycle component);
/** * Registers a component with this manager. * <p> * @param component the component whose life cycle is to be managed */ public void register(LifeCycle component) { components.add(component); }