/** * Create a new Valve and associate it with a {@link Container}. * * @param className The fully qualified class name of the {@link Valve} to * create * @param parent The MBean name of the associated parent * {@link Container}. * * @return The MBean name of the {@link Valve} that was created or * <code>null</code> if the {@link Valve} does not implement * {@link LifecycleMBeanBase}. */ public String createValve(String className, String parent) throws Exception { // Look for the parent ObjectName parentName = new ObjectName(parent); Container container = getParentContainerFromParent(parentName); if (container == null) { // TODO throw new IllegalArgumentException(); } Valve valve = (Valve) Class.forName(className).newInstance(); container.getPipeline().addValve(valve); if (valve instanceof LifecycleMBeanBase) { return ((LifecycleMBeanBase) valve).getObjectName().toString(); } else { return null; } }
/** * Create a new Valve and associate it with a {@link Container}. * * @param className * The fully qualified class name of the {@link Valve} to create * @param parent * The MBean name of the associated parent {@link Container}. * * @return The MBean name of the {@link Valve} that was created or * <code>null</code> if the {@link Valve} does not implement * {@link LifecycleMBeanBase}. */ public String createValve(String className, String parent) throws Exception { // Look for the parent ObjectName parentName = new ObjectName(parent); Container container = getParentContainerFromParent(parentName); if (container == null) { // TODO throw new IllegalArgumentException(); } Valve valve = (Valve) Class.forName(className).newInstance(); container.getPipeline().addValve(valve); if (valve instanceof LifecycleMBeanBase) { return ((LifecycleMBeanBase) valve).getObjectName().toString(); } else { return null; } }
@Override protected String getDomainInternal() { // Use the same domain as our associated container if we have one Object c = getContainer(); if (c instanceof LifecycleMBeanBase) { return ((LifecycleMBeanBase) c).getDomain(); } return null; }
/** * Invoke a pre-startup initialization. This is used to allow connectors * to bind to restricted ports under Unix operating environments. */ @Override protected void initInternal() throws LifecycleException { super.initInternal(); if (container != null) { container.init(); } // Initialize any Executors for (Executor executor : findExecutors()) { if (executor instanceof LifecycleMBeanBase) { ((LifecycleMBeanBase) executor).setDomain(getDomain()); } executor.init(); // StandardThreadExecutor#initInternal } // Initialize our defined Connectors synchronized (connectorsLock) { for (Connector connector : connectors) { try { connector.init(); } catch (Exception e) { String message = sm.getString( "standardService.connector.initFailed", connector); log.error(message, e); if (Boolean.getBoolean("org.apache.catalina.startup.EXIT_ON_INIT_FAILURE")) throw new LifecycleException(message); } } } }
/** * Invoke a pre-startup initialization. This is used to allow connectors * to bind to restricted ports under Unix operating environments. */ @Override protected void initInternal() throws LifecycleException { super.initInternal(); if (container != null) { //初始化容器StandEngine container.init(); } // Initialize any Executors for (Executor executor : findExecutors()) { if (executor instanceof LifecycleMBeanBase) { ((LifecycleMBeanBase) executor).setDomain(getDomain()); } executor.init(); } // 等到容器初始化的差不多的时候才去初始化连接器 // Initialize our defined Connectors synchronized (connectorsLock) { for (Connector connector : connectors) { try { // connector.init(); } catch (Exception e) { String message = sm.getString( "standardService.connector.initFailed", connector); log.error(message, e); if (Boolean.getBoolean("org.apache.catalina.startup.EXIT_ON_INIT_FAILURE")) throw new LifecycleException(message); } } } }
/** * Invoke a pre-startup initialization. This is used to allow connectors to * bind to restricted ports under Unix operating environments. */ @Override protected void initInternal() throws LifecycleException { super.initInternal(); if (container != null) { container.init(); } // Initialize any Executors for (Executor executor : findExecutors()) { if (executor instanceof LifecycleMBeanBase) { ((LifecycleMBeanBase) executor).setDomain(getDomain()); } executor.init(); } // Initialize our defined Connectors synchronized (connectorsLock) { for (Connector connector : connectors) { try { connector.init(); } catch (Exception e) { String message = sm.getString("standardService.connector.initFailed", connector); log.error(message, e); if (Boolean.getBoolean("org.apache.catalina.startup.EXIT_ON_INIT_FAILURE")) throw new LifecycleException(message); } } } }
/** * Invoke a pre-startup initialization. This is used to allow connectors * to bind to restricted ports under Unix operating environments. */ @Override protected void initInternal() throws LifecycleException { super.initInternal(); if (container != null) { container.init(); } // Initialize any Executors for (Executor executor : findExecutors()) { if (executor instanceof LifecycleMBeanBase) { ((LifecycleMBeanBase) executor).setDomain(getDomain()); } executor.init(); } // Initialize our defined Connectors synchronized (connectors) { for (Connector connector : connectors) { try { connector.init(); } catch (Exception e) { String message = sm.getString( "standardService.connector.initFailed", connector); log.error(message, e); if (Boolean.getBoolean("org.apache.catalina.startup.EXIT_ON_INIT_FAILURE")) throw new LifecycleException(message); } } } }
/** * Invoke a pre-startup initialization. This is used to allow connectors * to bind to restricted ports under Unix operating environments. */ @Override protected void initInternal() throws LifecycleException { super.initInternal(); if (container != null) { //engine容器初始化 tomcat默认server.xml里的<service>元素下是<engine> container.init(); } // Initialize any Executors for (Executor executor : findExecutors()) { if (executor instanceof LifecycleMBeanBase) { ((LifecycleMBeanBase) executor).setDomain(getDomain()); } executor.init(); } // Initialize our defined Connectors synchronized (connectors) { for (Connector connector : connectors) { try { connector.init(); } catch (Exception e) { String message = sm.getString( "standardService.connector.initFailed", connector); log.error(message, e); if (Boolean.getBoolean("org.apache.catalina.startup.EXIT_ON_INIT_FAILURE")) throw new LifecycleException(message); } } } }
public LazyStopStandardRoot(final WebResourceRoot delegate) { this.delegate = delegate; this.isJmxEnabled = JmxEnabled.class.isInstance(delegate); this.isLifecycleMBeanBase = LifecycleMBeanBase.class.isInstance(delegate); }
public void postDeregister() { if (isLifecycleMBeanBase) { LifecycleMBeanBase.class.cast(delegate).postDeregister(); } }
public void postRegister(final Boolean registrationDone) { if (isLifecycleMBeanBase) { LifecycleMBeanBase.class.cast(delegate).postRegister(registrationDone); } }
public void preDeregister() throws Exception { if (isLifecycleMBeanBase) { LifecycleMBeanBase.class.cast(delegate).preDeregister(); } }
public ObjectName preRegister(final MBeanServer server, final ObjectName name) throws Exception { if (isLifecycleMBeanBase) { return LifecycleMBeanBase.class.cast(delegate).preRegister(server, name); } return name; }