Java Code Examples for org.apache.catalina.mbeans.MBeanUtils#getDomain()

The following examples show how to use org.apache.catalina.mbeans.MBeanUtils#getDomain() . 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: WebappLoader.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Stop associated {@link ClassLoader} and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#stopInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected void stopInternal() throws LifecycleException {

    if (log.isDebugEnabled())
        log.debug(sm.getString("webappLoader.stopping"));

    setState(LifecycleState.STOPPING);

    // Remove context attributes as appropriate
    if (container instanceof Context) {
        ServletContext servletContext =
            ((Context) container).getServletContext();
        servletContext.removeAttribute(Globals.CLASS_PATH_ATTR);
    }

    // Throw away our current class loader
    if (classLoader != null) {
        ((Lifecycle) classLoader).stop();
        DirContextURLStreamHandler.unbind(classLoader);
    }

    try {
        StandardContext ctx=(StandardContext)container;
        String contextName = ctx.getName();
        if (!contextName.startsWith("/")) {
            contextName = "/" + contextName;
        }
        ObjectName cloname = new ObjectName
            (MBeanUtils.getDomain(ctx) + ":type=WebappClassLoader,context="
             + contextName + ",host=" + ctx.getParent().getName());
        Registry.getRegistry(null, null).unregisterComponent(cloname);
    } catch (Exception e) {
        log.error("LifecycleException ", e);
    }

    classLoader = null;
}
 
Example 2
Source File: SimpleTcpCluster.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
protected String getDomainInternal() {
    Container container = getContainer();
    if (container == null) {
        return null;
    }
    return MBeanUtils.getDomain(container);
}
 
Example 3
Source File: StandardServer.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Obtain the MBean domain for this server. The domain is obtained using
 * the following search order:
 * <ol>
 * <li>Name of first {@link org.apache.catalina.Engine}.</li>
 * <li>Name of first {@link Service}.</li>
 * </ol>
 */
@Override
protected String getDomainInternal() {
    
    String domain = null;
    
    Service[] services = findServices();
    if (services.length > 0) {
        Service service = services[0];
        if (service != null) {
            domain = MBeanUtils.getDomain(service);
        }
    }
    return domain;
}
 
Example 4
Source File: StandardServer.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Obtain the MBean domain for this server. The domain is obtained using
 * the following search order:
 * <ol>
 * <li>Name of first {@link org.apache.catalina.Engine}.</li>
 * <li>Name of first {@link Service}.</li>
 * </ol>
 */
@Override
protected String getDomainInternal() {
    
    String domain = null;
    
    Service[] services = findServices();
    if (services.length > 0) {
        Service service = services[0];
        if (service != null) {
            domain = MBeanUtils.getDomain(service);
        }
    }
    return domain;
}
 
Example 5
Source File: WebappLoader.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Stop associated {@link ClassLoader} and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#stopInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected void stopInternal() throws LifecycleException {

    if (log.isDebugEnabled())
        log.debug(sm.getString("webappLoader.stopping"));

    setState(LifecycleState.STOPPING);

    // Remove context attributes as appropriate
    if (container instanceof Context) {
        ServletContext servletContext =
            ((Context) container).getServletContext();
        servletContext.removeAttribute(Globals.CLASS_PATH_ATTR);
    }

    // Throw away our current class loader
    if (classLoader != null) {
        ((Lifecycle) classLoader).stop();
        DirContextURLStreamHandler.unbind(classLoader);
    }

    try {
        StandardContext ctx=(StandardContext)container;
        String contextName = ctx.getName();
        if (!contextName.startsWith("/")) {
            contextName = "/" + contextName;
        }
        ObjectName cloname = new ObjectName
            (MBeanUtils.getDomain(ctx) + ":type=WebappClassLoader,context="
             + contextName + ",host=" + ctx.getParent().getName());
        Registry.getRegistry(null, null).unregisterComponent(cloname);
    } catch (Exception e) {
        log.error("LifecycleException ", e);
    }

    classLoader = null;
}
 
Example 6
Source File: StandardWrapper.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Load and initialize an instance of this servlet, if there is not already
 * at least one initialized instance.  This can be used, for example, to
 * load servlets that are marked in the deployment descriptor to be loaded
 * at server startup time.
 * <p>
 * <b>IMPLEMENTATION NOTE</b>:  Servlets whose classnames begin with
 * <code>org.apache.catalina.</code> (so-called "container" servlets)
 * are loaded by the same classloader that loaded this class, rather than
 * the classloader for the current web application.
 * This gives such classes access to Catalina internals, which are
 * prevented for classes loaded for web applications.
 *
 * @exception ServletException if the servlet init() method threw
 *  an exception
 * @exception ServletException if some other loading problem occurs
 */
@Override
public synchronized void load() throws ServletException {
    instance = loadServlet();
    
    if (!instanceInitialized) {
        initServlet(instance);
    }

    if (isJspServlet) {
        StringBuilder oname =
            new StringBuilder(MBeanUtils.getDomain(getParent()));
        
        oname.append(":type=JspMonitor,name=");
        oname.append(getName());
        
        oname.append(getWebModuleKeyProperties());
        
        try {
            jspMonitorON = new ObjectName(oname.toString());
            Registry.getRegistry(null, null)
                .registerComponent(instance, jspMonitorON, null);
        } catch( Exception ex ) {
            log.info("Error registering JSP monitoring with jmx " +
                     instance);
        }
    }
}
 
Example 7
Source File: RealmBase.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public String getDomainInternal() {
    return MBeanUtils.getDomain(container);
}
 
Example 8
Source File: ValveBase.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public String getDomainInternal() {
    return MBeanUtils.getDomain(getContainer());
}
 
Example 9
Source File: Connector.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
protected String getDomainInternal() {
    return MBeanUtils.getDomain(getService());
}
 
Example 10
Source File: ManagerBase.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public String getDomainInternal() {
    return MBeanUtils.getDomain(container);
}
 
Example 11
Source File: FailedContext.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
@Deprecated
protected String getDomainInternal() { return MBeanUtils.getDomain(this); }
 
Example 12
Source File: WebappLoader.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
protected String getDomainInternal() {
    return MBeanUtils.getDomain(container);
}
 
Example 13
Source File: StandardService.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
protected String getDomainInternal() {
    
    return MBeanUtils.getDomain(this);
}
 
Example 14
Source File: ContainerBase.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
protected String getDomainInternal() {
    return MBeanUtils.getDomain(this);
}
 
Example 15
Source File: RealmBase.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
public String getDomainInternal() {
    return MBeanUtils.getDomain(container);
}
 
Example 16
Source File: ValveBase.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
public String getDomainInternal() {
    return MBeanUtils.getDomain(getContainer());
}
 
Example 17
Source File: Connector.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
protected String getDomainInternal() {
    return MBeanUtils.getDomain(getService());
}
 
Example 18
Source File: ManagerBase.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
public String getDomainInternal() {
    return MBeanUtils.getDomain(container);
}
 
Example 19
Source File: FailedContext.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
@Deprecated
protected String getDomainInternal() { return MBeanUtils.getDomain(this); }
 
Example 20
Source File: WebappLoader.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
protected String getDomainInternal() {
    return MBeanUtils.getDomain(container);
}