org.apache.catalina.util.LifecycleMBeanBase Java Examples

The following examples show how to use org.apache.catalina.util.LifecycleMBeanBase. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MBeanFactory.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
    }
}
 
Example #2
Source File: MBeanFactory.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
    }
}
 
Example #3
Source File: MapperListener.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
protected String getDomainInternal() {
    if (service instanceof LifecycleMBeanBase) {
        return ((LifecycleMBeanBase) service).getDomain();
    } else {
        return null;
    }
}
 
Example #4
Source File: NamingResources.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #5
Source File: StandardService.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
            }
        }
    }
}
 
Example #6
Source File: NamingResources.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #7
Source File: StandardService.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
            }
        }
    }
}
 
Example #8
Source File: LazyStopStandardRoot.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public ObjectName preRegister(final MBeanServer server, final ObjectName name) throws Exception {
    if (isLifecycleMBeanBase) {
        return LifecycleMBeanBase.class.cast(delegate).preRegister(server, name);
    }
    return name;
}
 
Example #9
Source File: LazyStopStandardRoot.java    From tomee with Apache License 2.0 4 votes vote down vote up
public LazyStopStandardRoot(final WebResourceRoot delegate) {
    this.delegate = delegate;
    this.isJmxEnabled = JmxEnabled.class.isInstance(delegate);
    this.isLifecycleMBeanBase = LifecycleMBeanBase.class.isInstance(delegate);
}
 
Example #10
Source File: LazyStopStandardRoot.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Override
public void postDeregister() {
    if (isLifecycleMBeanBase) {
        LifecycleMBeanBase.class.cast(delegate).postDeregister();
    }
}
 
Example #11
Source File: LazyStopStandardRoot.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Override
public void postRegister(final Boolean registrationDone) {
    if (isLifecycleMBeanBase) {
        LifecycleMBeanBase.class.cast(delegate).postRegister(registrationDone);
    }
}
 
Example #12
Source File: LazyStopStandardRoot.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Override
public void preDeregister() throws Exception {
    if (isLifecycleMBeanBase) {
        LifecycleMBeanBase.class.cast(delegate).preDeregister();
    }
}