Java 类ch.qos.logback.core.spi.LifeCycle 实例源码

项目:logback-config    文件:ConfigConfigurator.java   
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;

}
项目:bartleby    文件:AppenderAction.java   
/**
 * 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();
  }
}
项目:bartleby    文件:LoggerContextListenerAction.java   
@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();
  }
}
项目:konker-platform    文件:KonkerStatusListenerConfigHelper.java   
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);
    }

}
项目:bartleby    文件:LifeCycleManager.java   
/**
 * 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();
}
项目:bartleby    文件:AbstractEventEvaluatorAction.java   
/**
 * 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);
    }
  }
}
项目:bartleby    文件:StatusListenerAction.java   
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();
  }
}
项目:bartleby    文件:StatusListenerConfigHelper.java   
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);
  }
}
项目:sdcct    文件:LoggingInitializerRunListener.java   
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;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:LogbackConfigurator.java   
public void start(LifeCycle lifeCycle) {
    if (lifeCycle instanceof ContextAware) {
        ((ContextAware) lifeCycle).setContext(this.context);
    }
    lifeCycle.start();
}
项目:spring-boot-concourse    文件:LogbackConfigurator.java   
public void start(LifeCycle lifeCycle) {
    if (lifeCycle instanceof ContextAware) {
        ((ContextAware) lifeCycle).setContext(this.context);
    }
    lifeCycle.start();
}
项目:bartleby    文件:ContextBase.java   
public void register(LifeCycle component) {
  getLifeCycleManager().register(component);
}
项目:bartleby    文件:NestedComplexPropertyIA.java   
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;
      }
    }
  }
项目:bartleby    文件:ContextBaseTest.java   
@Override
public void register(LifeCycle component) {
  lastComponent = component;
  super.register(component);
}
项目:bartleby    文件:ContextBaseTest.java   
public LifeCycle getLastComponent() {
  return lastComponent;
}
项目:bartleby    文件:LogbackValve.java   
@Override
public void register(LifeCycle component) {
  lifeCycleManager.register(component);
}
项目:contestparser    文件:LogbackConfigurator.java   
public void start(LifeCycle lifeCycle) {
    if (lifeCycle instanceof ContextAware) {
        ((ContextAware) lifeCycle).setContext(this.context);
    }
    lifeCycle.start();
}
项目:log4j2    文件:RunLogback.java   
@Override
public void shutdown() {
    ((LifeCycle) LoggerFactory.getILoggerFactory()).stop();
}
项目:logging-log4j2    文件:AsyncAppenderLogbackLocationBenchmark.java   
@TearDown(Level.Trial)
public void down() {
    ((LifeCycle) LoggerFactory.getILoggerFactory()).stop();
    new File("perftest.log").delete();
}
项目:logging-log4j2    文件:AsyncAppenderLogbackBenchmark.java   
@TearDown(Level.Trial)
public void down() {
    ((LifeCycle) LoggerFactory.getILoggerFactory()).stop();
    new File("perftest.log").delete();
}
项目:logging-log4j2    文件:RunLogback.java   
@Override
public void shutdown() {
    ((LifeCycle) LoggerFactory.getILoggerFactory()).stop();
}
项目:bartleby    文件:Context.java   
/**
 * 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);
项目:bartleby    文件:LifeCycleManager.java   
/**
 * 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);
}