Java Code Examples for org.apache.tomcat.util.modeler.Registry#getRegistry()

The following examples show how to use org.apache.tomcat.util.modeler.Registry#getRegistry() . 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 Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Create and configure (if necessary) and return the registry of
 * managed object descriptions.
 * @return the singleton registry
 */
public static synchronized Registry createRegistry() {
    if (registry == null) {
        registry = Registry.getRegistry(null, null);
        ClassLoader cl = MBeanUtils.class.getClassLoader();

        registry.loadDescriptors("org.apache.catalina.mbeans",  cl);
        registry.loadDescriptors("org.apache.catalina.authenticator", cl);
        registry.loadDescriptors("org.apache.catalina.core", cl);
        registry.loadDescriptors("org.apache.catalina", cl);
        registry.loadDescriptors("org.apache.catalina.deploy", cl);
        registry.loadDescriptors("org.apache.catalina.loader", cl);
        registry.loadDescriptors("org.apache.catalina.realm", cl);
        registry.loadDescriptors("org.apache.catalina.session", cl);
        registry.loadDescriptors("org.apache.catalina.startup", cl);
        registry.loadDescriptors("org.apache.catalina.users", cl);
        registry.loadDescriptors("org.apache.catalina.ha", cl);
        registry.loadDescriptors("org.apache.catalina.connector", cl);
        registry.loadDescriptors("org.apache.catalina.valves",  cl);
        registry.loadDescriptors("org.apache.catalina.storeconfig",  cl);
        registry.loadDescriptors("org.apache.tomcat.util.descriptor.web",  cl);
    }
    return registry;
}
 
Example 2
Source File: MBeanUtils.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Create and configure (if necessary) and return the registry of
 * managed object descriptions.
 */
public static synchronized Registry createRegistry() {

    if (registry == null) {
        registry = Registry.getRegistry(null, null);
        ClassLoader cl = MBeanUtils.class.getClassLoader();

        registry.loadDescriptors("org.apache.catalina.mbeans",  cl);
        registry.loadDescriptors("org.apache.catalina.authenticator", cl);
        registry.loadDescriptors("org.apache.catalina.core", cl);
        registry.loadDescriptors("org.apache.catalina", cl);
        registry.loadDescriptors("org.apache.catalina.deploy", cl);
        registry.loadDescriptors("org.apache.catalina.loader", cl);
        registry.loadDescriptors("org.apache.catalina.realm", cl);
        registry.loadDescriptors("org.apache.catalina.session", cl);
        registry.loadDescriptors("org.apache.catalina.startup", cl);
        registry.loadDescriptors("org.apache.catalina.users", cl);
        registry.loadDescriptors("org.apache.catalina.ha", cl);
        registry.loadDescriptors("org.apache.catalina.connector", cl);
        registry.loadDescriptors("org.apache.catalina.valves",  cl);
    }
    return (registry);

}
 
Example 3
Source File: MBeanUtils.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Create and configure (if necessary) and return the registry of
 * managed object descriptions.
 */
public static synchronized Registry createRegistry() {

    if (registry == null) {
        registry = Registry.getRegistry(null, null);
        ClassLoader cl = MBeanUtils.class.getClassLoader();

        registry.loadDescriptors("org.apache.catalina.mbeans",  cl);
        registry.loadDescriptors("org.apache.catalina.authenticator", cl);
        registry.loadDescriptors("org.apache.catalina.core", cl);
        registry.loadDescriptors("org.apache.catalina", cl);
        registry.loadDescriptors("org.apache.catalina.deploy", cl);
        registry.loadDescriptors("org.apache.catalina.loader", cl);
        registry.loadDescriptors("org.apache.catalina.realm", cl);
        registry.loadDescriptors("org.apache.catalina.session", cl);
        registry.loadDescriptors("org.apache.catalina.startup", cl);
        registry.loadDescriptors("org.apache.catalina.users", cl);
        registry.loadDescriptors("org.apache.catalina.ha", cl);
        registry.loadDescriptors("org.apache.catalina.connector", cl);
        registry.loadDescriptors("org.apache.catalina.valves",  cl);
    }
    return (registry);

}
 
Example 4
Source File: JMXProxyServlet.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Initialize this servlet.
 */
@Override
public void init() throws ServletException {
    // Retrieve the MBean server
    registry = Registry.getRegistry(null, null);
    mBeanServer = Registry.getRegistry(null, null).getMBeanServer();
}
 
Example 5
Source File: MbeansDescriptorsDigesterSource.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public void execute() throws Exception {
    if (registry == null) {
        registry = Registry.getRegistry(null, null);
    }

    InputStream stream = (InputStream) source;

    List<ManagedBean> loadedMbeans = new ArrayList<>();
    synchronized(dLock) {
        if (digester == null) {
            digester = createDigester();
        }

        // Process the input file to configure our registry
        try {
            // Push our registry object onto the stack
            digester.push(loadedMbeans);
            digester.parse(stream);
        } catch (Exception e) {
            log.error(sm.getString("modules.digesterParseError"), e);
            throw e;
        } finally {
            digester.reset();
        }

    }
    for (ManagedBean loadedMbean : loadedMbeans) {
        registry.addManagedBean(loadedMbean);
    }
}
 
Example 6
Source File: MbeansDescriptorsIntrospectionSource.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public void execute() throws Exception {
    if( registry==null ) registry=Registry.getRegistry(null, null);
    try {
        ManagedBean managed = createManagedBean(registry, null,
                (Class<?>)source, type);
        if( managed==null ) return;
        managed.setName( type );

        registry.addManagedBean(managed);

    } catch( Exception ex ) {
        log.error(sm.getString("modules.readDescriptorsError"), ex);
    }
}
 
Example 7
Source File: AbstractEndpoint.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
private void unregisterJmx(SSLHostConfig sslHostConfig) {
    Registry registry = Registry.getRegistry(null, null);
    registry.unregisterComponent(sslHostConfig.getObjectName());
    for (SSLHostConfigCertificate sslHostConfigCert : sslHostConfig.getCertificates()) {
        registry.unregisterComponent(sslHostConfigCert.getObjectName());
    }
}
 
Example 8
Source File: AbstractEndpoint.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public final void destroy() throws Exception {
    if (bindState == BindState.BOUND_ON_INIT) {
        unbind();
        bindState = BindState.UNBOUND;
    }
    Registry registry = Registry.getRegistry(null, null);
    registry.unregisterComponent(oname);
    registry.unregisterComponent(socketProperties.getObjectName());
    for (SSLHostConfig sslHostConfig : findSslHostConfigs()) {
        unregisterJmx(sslHostConfig);
    }
}
 
Example 9
Source File: JMXProxyServlet.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize this servlet.
 */
@Override
public void init() throws ServletException {
    // Retrieve the MBean server
    registry = Registry.getRegistry(null, null);
    mBeanServer = Registry.getRegistry(null, null).getMBeanServer();
}
 
Example 10
Source File: MbeansDescriptorsDigesterSource.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public void execute() throws Exception {
    if (registry == null) {
        registry = Registry.getRegistry(null, null);
    }

    InputStream stream = (InputStream) source;

    ArrayList<ManagedBean> loadedMbeans = new ArrayList<ManagedBean>();

    synchronized(dLock) {
        if (digester == null) {
            digester = createDigester();
        }

        // Process the input file to configure our registry
        try {
            // Push our registry object onto the stack
            digester.push(loadedMbeans);
            digester.parse(stream);
        } catch (Exception e) {
            log.error("Error digesting Registry data", e);
            throw e;
        } finally {
            digester.reset();
        }

    }
    Iterator<ManagedBean> iter = loadedMbeans.iterator();
    while (iter.hasNext()) {
        registry.addManagedBean(iter.next());
    }
}
 
Example 11
Source File: MbeansDescriptorsIntrospectionSource.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public void execute() throws Exception {
    if( registry==null ) registry=Registry.getRegistry(null, null);
    try {
        ManagedBean managed = createManagedBean(registry, null,
                (Class<?>)source, type);
        if( managed==null ) return;
        managed.setName( type );

        registry.addManagedBean(managed);

    } catch( Exception ex ) {
        log.error( "Error reading descriptors ", ex);
    }
}
 
Example 12
Source File: MbeansSource.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Override
public void init() throws Exception {
    if( mbeans==null) execute();
    if( registry==null ) registry=Registry.getRegistry(null, null);
    
    registry.invoke(mbeans, "init", false);
}
 
Example 13
Source File: JMXProxyServlet.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize this servlet.
 */
@Override
public void init() throws ServletException {
    // Retrieve the MBean server
    registry = Registry.getRegistry(null, null);
    mBeanServer = Registry.getRegistry(null, null).getMBeanServer();
}
 
Example 14
Source File: MbeansDescriptorsDigesterSource.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
public void execute() throws Exception {
    if (registry == null) {
        registry = Registry.getRegistry(null, null);
    }

    InputStream stream = (InputStream) source;

    ArrayList<ManagedBean> loadedMbeans = new ArrayList<ManagedBean>();

    synchronized(dLock) {
        if (digester == null) {
            digester = createDigester();
        }

        // Process the input file to configure our registry
        try {
            // Push our registry object onto the stack
            digester.push(loadedMbeans);
            digester.parse(stream);
        } catch (Exception e) {
            log.error("Error digesting Registry data", e);
            throw e;
        } finally {
            digester.reset();
        }

    }
    Iterator<ManagedBean> iter = loadedMbeans.iterator();
    while (iter.hasNext()) {
        registry.addManagedBean(iter.next());
    }
}
 
Example 15
Source File: MbeansDescriptorsIntrospectionSource.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
public void execute() throws Exception {
    if( registry==null ) registry=Registry.getRegistry(null, null);
    try {
        ManagedBean managed = createManagedBean(registry, null,
                (Class<?>)source, type);
        if( managed==null ) return;
        managed.setName( type );

        registry.addManagedBean(managed);

    } catch( Exception ex ) {
        log.error( "Error reading descriptors ", ex);
    }
}
 
Example 16
Source File: MbeansSource.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
public void init() throws Exception {
    if( mbeans==null) execute();
    if( registry==null ) registry=Registry.getRegistry(null, null);
    
    registry.invoke(mbeans, "init", false);
}