org.apache.catalina.Contained Java Examples

The following examples show how to use org.apache.catalina.Contained. 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: MBeanUtils.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Deregister the MBean for this
 * <code>Valve</code> object.
 *
 * @param valve The Valve to be managed
 *
 * @exception Exception if an MBean cannot be deregistered
 * @deprecated  Unused. Will be removed in Tomcat 8.0.x
 */
@Deprecated
static void destroyMBean(Valve valve, Container container)
    throws Exception {

    ((Contained)valve).setContainer(container);
    String mname = createManagedName(valve);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        return;
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ObjectName oname = createObjectName(domain, valve);
    try {
        ((Contained)valve).setContainer(null);
    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
    }
    if( mserver.isRegistered(oname) ) {
        mserver.unregisterMBean(oname);
    }

}
 
Example #2
Source File: MBeanUtils.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Deregister the MBean for this
 * <code>Valve</code> object.
 *
 * @param valve The Valve to be managed
 *
 * @exception Exception if an MBean cannot be deregistered
 * @deprecated  Unused. Will be removed in Tomcat 8.0.x
 */
@Deprecated
static void destroyMBean(Valve valve, Container container)
    throws Exception {

    ((Contained)valve).setContainer(container);
    String mname = createManagedName(valve);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        return;
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ObjectName oname = createObjectName(domain, valve);
    try {
        ((Contained)valve).setContainer(null);
    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
    }
    if( mserver.isRegistered(oname) ) {
        mserver.unregisterMBean(oname);
    }

}
 
Example #3
Source File: StandardPipeline.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * <p>Add a new Valve to the end of the pipeline associated with this
 * Container.  Prior to adding the Valve, the Valve's
 * <code>setContainer()</code> method will be called, if it implements
 * <code>Contained</code>, with the owning Container as an argument.
 * The method may throw an
 * <code>IllegalArgumentException</code> if this Valve chooses not to
 * be associated with this Container, or <code>IllegalStateException</code>
 * if it is already associated with a different Container.</p>
 *
 * @param valve Valve to be added
 *
 * @exception IllegalArgumentException if this Container refused to
 *  accept the specified Valve
 * @exception IllegalArgumentException if the specified Valve refuses to be
 *  associated with this Container
 * @exception IllegalStateException if the specified Valve is already
 *  associated with a different Container
 */
@Override
public void addValve(Valve valve) {

    // Validate that we can add this Valve
    if (valve instanceof Contained)
        ((Contained) valve).setContainer(this.container);

    // Start the new component if necessary
    if (getState().isAvailable()) {
        if (valve instanceof Lifecycle) {
            try {
                ((Lifecycle) valve).start();
            } catch (LifecycleException e) {
                log.error(sm.getString("standardPipeline.valve.start"), e);
            }
        }
    }

    // Add this Valve to the set associated with this Pipeline
    if (first == null) {
        first = valve;
        valve.setNext(basic);
    } else {
        Valve current = first;
        while (current != null) {
            if (current.getNext() == basic) {
                current.setNext(valve);
                valve.setNext(basic);
                break;
            }
            current = current.getNext();
        }
    }

    container.fireContainerEvent(Container.ADD_VALVE_EVENT, valve);
}
 
Example #4
Source File: StandardPipeline.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * <p>Add a new Valve to the end of the pipeline associated with this
 * Container.  Prior to adding the Valve, the Valve's
 * <code>setContainer()</code> method will be called, if it implements
 * <code>Contained</code>, with the owning Container as an argument.
 * The method may throw an
 * <code>IllegalArgumentException</code> if this Valve chooses not to
 * be associated with this Container, or <code>IllegalStateException</code>
 * if it is already associated with a different Container.</p>
 *
 * @param valve Valve to be added
 *
 * @exception IllegalArgumentException if this Container refused to
 *  accept the specified Valve
 * @exception IllegalArgumentException if the specified Valve refuses to be
 *  associated with this Container
 * @exception IllegalStateException if the specified Valve is already
 *  associated with a different Container
 */
@Override
public void addValve(Valve valve) {

    // Validate that we can add this Valve
    if (valve instanceof Contained)
        ((Contained) valve).setContainer(this.container);

    // Start the new component if necessary
    if (getState().isAvailable()) {
        if (valve instanceof Lifecycle) {
            try {
                ((Lifecycle) valve).start();
            } catch (LifecycleException e) {
                log.error("StandardPipeline.addValve: start: ", e);
            }
        }
    }

    // Add this Valve to the set associated with this Pipeline
    if (first == null) {
        first = valve;
        valve.setNext(basic);
    } else {
        Valve current = first;
        while (current != null) {
            if (current.getNext() == basic) {
                current.setNext(valve);
                valve.setNext(basic);
                break;
            }
            current = current.getNext();
        }
    }
    
    container.fireContainerEvent(Container.ADD_VALVE_EVENT, valve);
}
 
Example #5
Source File: LazyValve.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public void setContainer(final Container container) {
    this.container = container;
    if (delegate != null && Contained.class.isInstance(delegate)) {
        Contained.class.cast(delegate).setContainer(container);
    }
}