Java 类org.apache.catalina.Loader 实例源码

项目:tomcat7    文件:MBeanUtils.java   
/**
 * Create, register, and return an MBean for this
 * <code>Loader</code> object.
 *
 * @param loader The Loader to be managed
 *
 * @exception Exception if an MBean cannot be created or registered
 *
 * @deprecated Unused. Will be removed in Tomcat 8.0.x
 */
@Deprecated
static DynamicMBean createMBean(Loader loader)
    throws Exception {

    String mname = createManagedName(loader);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with "+mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    DynamicMBean mbean = managed.createMBean(loader);
    ObjectName oname = createObjectName(domain, loader);
    if( mserver.isRegistered( oname ))  {
        // side effect: stop it
        mserver.unregisterMBean( oname );
    }
    mserver.registerMBean(mbean, oname);
    return (mbean);

}
项目:tomcat7    文件:MBeanUtils.java   
/**
 * Deregister the MBean for this
 * <code>Loader</code> object.
 *
 * @param loader The Loader 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(Loader loader)
    throws Exception {

    String mname = createManagedName(loader);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        return;
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ObjectName oname = createObjectName(domain, loader);
    if( mserver.isRegistered(oname) )
        mserver.unregisterMBean(oname);

}
项目:lams    文件:MBeanUtils.java   
/**
 * Create, register, and return an MBean for this
 * <code>Loader</code> object.
 *
 * @param loader The Loader to be managed
 *
 * @exception Exception if an MBean cannot be created or registered
 */
static DynamicMBean createMBean(Loader loader)
    throws Exception {

    String mname = createManagedName(loader);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with "+mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    DynamicMBean mbean = managed.createMBean(loader);
    ObjectName oname = createObjectName(domain, loader);
    if( mserver.isRegistered( oname ))  {
        // side effect: stop it
        mserver.unregisterMBean( oname );
    }
    mserver.registerMBean(mbean, oname);
    return (mbean);

}
项目:lams    文件:MBeanUtils.java   
/**
 * Deregister the MBean for this
 * <code>Loader</code> object.
 *
 * @param loader The Loader to be managed
 *
 * @exception Exception if an MBean cannot be deregistered
 */
static void destroyMBean(Loader loader)
    throws Exception {

    String mname = createManagedName(loader);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        return;
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ObjectName oname = createObjectName(domain, loader);
    if( mserver.isRegistered(oname) )
        mserver.unregisterMBean(oname);

}
项目:jerrydog    文件:ContextRuleSet.java   
public void begin(Attributes attributes) throws Exception {

        // Look up the required parent class loader
        Container container = (Container) digester.peek();
        ClassLoader parentClassLoader = container.getParentClassLoader();

        // Instantiate a new Loader implementation object
        String className = loaderClass;
        if (attributeName != null) {
            String value = attributes.getValue(attributeName);
            if (value != null)
                className = value;
        }
        Class clazz = Class.forName(className);
        Class types[] = { ClassLoader.class };
        Object args[] = { parentClassLoader };
        Constructor constructor = clazz.getDeclaredConstructor(types);
        Loader loader = (Loader) constructor.newInstance(args);

        // Push the new loader onto the stack
        digester.push(loader);
        if (digester.getDebug() >= 1)
            digester.log("new " + loader.getClass().getName());

    }
项目:jerrydog    文件:MBeanUtils.java   
/**
 * Create, register, and return an MBean for this
 * <code>Loader</code> object.
 *
 * @param loader The Loader to be managed
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public static ModelMBean createMBean(Loader loader)
    throws Exception {

    String mname = createManagedName(loader);     
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with "+mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ModelMBean mbean = managed.createMBean(loader);
    ObjectName oname = createObjectName(domain, loader);
    mserver.registerMBean(mbean, oname);
    return (mbean);       
}
项目:jerrydog    文件:MBeanUtils.java   
/**
 * Deregister the MBean for this
 * <code>Loader</code> object.
 *
 * @param loader The Loader to be managed
 *
 * @exception Exception if an MBean cannot be deregistered
 */
public static void destroyMBean(Loader loader)
    throws Exception {

    String mname = createManagedName(loader);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        return;
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ObjectName oname = createObjectName(domain, loader);
    mserver.unregisterMBean(oname);

}
项目:jerrydog    文件:StandardServer.java   
/**
 * Is this an instance of the default <code>Loader</code> configuration,
 * with all-default properties?
 *
 * @param loader Loader to be tested
 */
private boolean isDefaultLoader(Loader loader) {

    if (!(loader instanceof WebappLoader)) {
        return (false);
    }
    WebappLoader wloader = (WebappLoader) loader;
    if ((wloader.getCheckInterval() != 15) ||
        (wloader.getDebug() != 0) ||
        (wloader.getDelegate() != false) ||
        !wloader.getLoaderClass().equals
         ("org.apache.catalina.loader.WebappClassLoader")) {
        return (false);
    }
    return (true);

}
项目:tomcat8-redis-session-manager    文件:RedisSessionManager.java   
private void initializeSerializer() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
   log.info("Attempting to use serializer :" + serializationStrategyClass);
   serializer = (Serializer) Class.forName(serializationStrategyClass).newInstance();

   Loader loader = null;

   /* 默认支持tomcat7.x
   if (getContainer() != null) {
     loader = getContainer().getLoader();
   }
   */

   // 修改为支持tomcat8.x
   Context context = this.getContext();

   if (context != null) {
    loader = context.getLoader();
}

   ClassLoader classLoader = null;

   if (loader != null) {
     classLoader = loader.getClassLoader();
   }
   serializer.setClassLoader(classLoader);
 }
项目:apache-tomcat-7.0.73-with-comment    文件:MBeanUtils.java   
/**
 * Create, register, and return an MBean for this
 * <code>Loader</code> object.
 *
 * @param loader The Loader to be managed
 *
 * @exception Exception if an MBean cannot be created or registered
 *
 * @deprecated Unused. Will be removed in Tomcat 8.0.x
 */
@Deprecated
static DynamicMBean createMBean(Loader loader)
    throws Exception {

    String mname = createManagedName(loader);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with "+mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    DynamicMBean mbean = managed.createMBean(loader);
    ObjectName oname = createObjectName(domain, loader);
    if( mserver.isRegistered( oname ))  {
        // side effect: stop it
        mserver.unregisterMBean( oname );
    }
    mserver.registerMBean(mbean, oname);
    return (mbean);

}
项目:apache-tomcat-7.0.73-with-comment    文件:MBeanUtils.java   
/**
 * Deregister the MBean for this
 * <code>Loader</code> object.
 *
 * @param loader The Loader 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(Loader loader)
    throws Exception {

    String mname = createManagedName(loader);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        return;
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ObjectName oname = createObjectName(domain, loader);
    if( mserver.isRegistered(oname) )
        mserver.unregisterMBean(oname);

}
项目:appng-tomcat-session    文件:RedisSessionManager.java   
void initializeSerializer() throws ReflectiveOperationException {
    log.info("Attempting to use serializer :" + serializationStrategyClass);
    serializer = (Serializer) Class.forName(serializationStrategyClass).newInstance();

    Loader loader = null;

    if (getContext() != null) {
        loader = getContext().getLoader();
    }

    ClassLoader classLoader = null;

    if (loader != null) {
        classLoader = loader.getClassLoader();
    }
    serializer.setClassLoader(classLoader);
}
项目:lazycat    文件:MBeanUtils.java   
/**
 * Create, register, and return an MBean for this <code>Loader</code>
 * object.
 *
 * @param loader
 *            The Loader to be managed
 *
 * @exception Exception
 *                if an MBean cannot be created or registered
 *
 * @deprecated Unused. Will be removed in Tomcat 8.0.x
 */
@Deprecated
static DynamicMBean createMBean(Loader loader) throws Exception {

    String mname = createManagedName(loader);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with " + mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    DynamicMBean mbean = managed.createMBean(loader);
    ObjectName oname = createObjectName(domain, loader);
    if (mserver.isRegistered(oname)) {
        // side effect: stop it
        mserver.unregisterMBean(oname);
    }
    mserver.registerMBean(mbean, oname);
    return (mbean);

}
项目:lazycat    文件:MBeanUtils.java   
/**
 * Deregister the MBean for this <code>Loader</code> object.
 *
 * @param loader
 *            The Loader 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(Loader loader) throws Exception {

    String mname = createManagedName(loader);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        return;
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ObjectName oname = createObjectName(domain, loader);
    if (mserver.isRegistered(oname))
        mserver.unregisterMBean(oname);

}
项目:various_demos    文件:RedisSessionManager.java   
private void initializeSerializer() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
   log.info("Attempting to use serializer :" + serializationStrategyClass);
   serializer = (Serializer) Class.forName(serializationStrategyClass).newInstance();

   Loader loader = null;

   Context context = this.getContext();
if (context != null) {
    loader = context.getLoader();
}

   /*
    * if (getContainer() != null) {
     loader = getContainer().getLoader();
   }*/
   ClassLoader classLoader = null;

   if (loader != null) {
     classLoader = loader.getClassLoader();
   }
   serializer.setClassLoader(classLoader);
 }
项目:distributed-session-manager    文件:AbstractSessionManager.java   
/**
 * 初始化序列化
 * @throws ClassNotFoundException
 * @throws IllegalAccessException
 * @throws InstantiationException
 */
private void initializeSerializer() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
    log.info("Attempting to use serializer :" + serializationStrategyClass);
    serializer = (Serializer) Class.forName(serializationStrategyClass).newInstance();

    Loader loader = null;

    if (getContainer() != null) {
        loader = getContainer().getLoader();
    }

    ClassLoader classLoader = null;

    if (loader != null) {
        classLoader = loader.getClassLoader();
    }
    serializer.setClassLoader(classLoader);
}
项目:class-guard    文件:MBeanUtils.java   
/**
 * Create, register, and return an MBean for this
 * <code>Loader</code> object.
 *
 * @param loader The Loader to be managed
 *
 * @exception Exception if an MBean cannot be created or registered
 *
 * @deprecated Unused. Will be removed in Tomcat 8.0.x
 */
@Deprecated
static DynamicMBean createMBean(Loader loader)
    throws Exception {

    String mname = createManagedName(loader);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with "+mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    DynamicMBean mbean = managed.createMBean(loader);
    ObjectName oname = createObjectName(domain, loader);
    if( mserver.isRegistered( oname ))  {
        // side effect: stop it
        mserver.unregisterMBean( oname );
    }
    mserver.registerMBean(mbean, oname);
    return (mbean);

}
项目:class-guard    文件:MBeanUtils.java   
/**
 * Create an <code>ObjectName</code> for this
 * <code>Loader</code> object.
 *
 * @param domain Domain in which this name is to be created
 * @param loader The Loader to be named
 *
 * @exception MalformedObjectNameException if a name cannot be created
 */
static ObjectName createObjectName(String domain,
                                          Loader loader)
    throws MalformedObjectNameException {

    ObjectName name = null;
    Container container = loader.getContainer();

    if (container instanceof Engine) {
        name = new ObjectName(domain + ":type=Loader");
    } else if (container instanceof Host) {
        name = new ObjectName(domain + ":type=Loader,host=" +
                          container.getName());
    } else if (container instanceof Context) {
        Context context = ((Context)container);
        ContextName cn = new ContextName(context.getName(), false);
        Container host = context.getParent();
        name = new ObjectName(domain + ":type=Loader,context=" +
                cn.getDisplayName() + ",host=" + host.getName());
    }

    return (name);

}
项目:class-guard    文件:MBeanUtils.java   
/**
 * Deregister the MBean for this
 * <code>Loader</code> object.
 *
 * @param loader The Loader 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(Loader loader)
    throws Exception {

    String mname = createManagedName(loader);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        return;
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ObjectName oname = createObjectName(domain, loader);
    if( mserver.isRegistered(oname) )
        mserver.unregisterMBean(oname);

}
项目:apache-tomcat-7.0.57    文件:MBeanUtils.java   
/**
 * Create, register, and return an MBean for this
 * <code>Loader</code> object.
 *
 * @param loader The Loader to be managed
 *
 * @exception Exception if an MBean cannot be created or registered
 *
 * @deprecated Unused. Will be removed in Tomcat 8.0.x
 */
@Deprecated
static DynamicMBean createMBean(Loader loader)
    throws Exception {

    String mname = createManagedName(loader);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with "+mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    DynamicMBean mbean = managed.createMBean(loader);
    ObjectName oname = createObjectName(domain, loader);
    if( mserver.isRegistered( oname ))  {
        // side effect: stop it
        mserver.unregisterMBean( oname );
    }
    mserver.registerMBean(mbean, oname);
    return (mbean);

}
项目:apache-tomcat-7.0.57    文件:MBeanUtils.java   
/**
 * Create an <code>ObjectName</code> for this
 * <code>Loader</code> object.
 *
 * @param domain Domain in which this name is to be created
 * @param loader The Loader to be named
 *
 * @exception MalformedObjectNameException if a name cannot be created
 */
static ObjectName createObjectName(String domain,
                                          Loader loader)
    throws MalformedObjectNameException {

    ObjectName name = null;
    Container container = loader.getContainer();

    if (container instanceof Engine) {
        name = new ObjectName(domain + ":type=Loader");
    } else if (container instanceof Host) {
        name = new ObjectName(domain + ":type=Loader,host=" +
                          container.getName());
    } else if (container instanceof Context) {
        Context context = ((Context)container);
        ContextName cn = new ContextName(context.getName(), false);
        Container host = context.getParent();
        name = new ObjectName(domain + ":type=Loader,context=" +
                cn.getDisplayName() + ",host=" + host.getName());
    }

    return (name);

}
项目:apache-tomcat-7.0.57    文件:MBeanUtils.java   
/**
 * Deregister the MBean for this
 * <code>Loader</code> object.
 *
 * @param loader The Loader 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(Loader loader)
    throws Exception {

    String mname = createManagedName(loader);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        return;
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ObjectName oname = createObjectName(domain, loader);
    if( mserver.isRegistered(oname) )
        mserver.unregisterMBean(oname);

}
项目:apache-tomcat-7.0.57    文件:MBeanUtils.java   
/**
 * Create, register, and return an MBean for this
 * <code>Loader</code> object.
 *
 * @param loader The Loader to be managed
 *
 * @exception Exception if an MBean cannot be created or registered
 *
 * @deprecated Unused. Will be removed in Tomcat 8.0.x
 */
@Deprecated
static DynamicMBean createMBean(Loader loader)
    throws Exception {

    String mname = createManagedName(loader);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with "+mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    DynamicMBean mbean = managed.createMBean(loader);
    ObjectName oname = createObjectName(domain, loader);
    if( mserver.isRegistered( oname ))  {
        // side effect: stop it
        mserver.unregisterMBean( oname );
    }
    mserver.registerMBean(mbean, oname);
    return (mbean);

}
项目:apache-tomcat-7.0.57    文件:MBeanUtils.java   
/**
 * Create an <code>ObjectName</code> for this
 * <code>Loader</code> object.
 *
 * @param domain Domain in which this name is to be created
 * @param loader The Loader to be named
 *
 * @exception MalformedObjectNameException if a name cannot be created
 */
static ObjectName createObjectName(String domain,
                                          Loader loader)
    throws MalformedObjectNameException {

    ObjectName name = null;
    Container container = loader.getContainer();

    if (container instanceof Engine) {
        name = new ObjectName(domain + ":type=Loader");
    } else if (container instanceof Host) {
        name = new ObjectName(domain + ":type=Loader,host=" +
                          container.getName());
    } else if (container instanceof Context) {
        Context context = ((Context)container);
        ContextName cn = new ContextName(context.getName(), false);
        Container host = context.getParent();
        name = new ObjectName(domain + ":type=Loader,context=" +
                cn.getDisplayName() + ",host=" + host.getName());
    }

    return (name);

}
项目:apache-tomcat-7.0.57    文件:MBeanUtils.java   
/**
 * Deregister the MBean for this
 * <code>Loader</code> object.
 *
 * @param loader The Loader 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(Loader loader)
    throws Exception {

    String mname = createManagedName(loader);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        return;
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ObjectName oname = createObjectName(domain, loader);
    if( mserver.isRegistered(oname) )
        mserver.unregisterMBean(oname);

}
项目:HowTomcatWorks    文件:ContextRuleSet.java   
public void begin(Attributes attributes) throws Exception {

        // Look up the required parent class loader
        Container container = (Container) digester.peek();
        ClassLoader parentClassLoader = container.getParentClassLoader();

        // Instantiate a new Loader implementation object
        String className = loaderClass;
        if (attributeName != null) {
            String value = attributes.getValue(attributeName);
            if (value != null)
                className = value;
        }
        Class clazz = Class.forName(className);
        Class types[] = { ClassLoader.class };
        Object args[] = { parentClassLoader };
        Constructor constructor = clazz.getDeclaredConstructor(types);
        Loader loader = (Loader) constructor.newInstance(args);

        // Push the new loader onto the stack
        digester.push(loader);
        if (digester.getDebug() >= 1)
            digester.log("new " + loader.getClass().getName());

    }
项目:HowTomcatWorks    文件:MBeanUtils.java   
/**
 * Create, register, and return an MBean for this
 * <code>Loader</code> object.
 *
 * @param loader The Loader to be managed
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public static ModelMBean createMBean(Loader loader)
    throws Exception {

    String mname = createManagedName(loader);     
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with "+mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ModelMBean mbean = managed.createMBean(loader);
    ObjectName oname = createObjectName(domain, loader);
    mserver.registerMBean(mbean, oname);
    return (mbean);       
}
项目:HowTomcatWorks    文件:MBeanUtils.java   
/**
 * Deregister the MBean for this
 * <code>Loader</code> object.
 *
 * @param loader The Loader to be managed
 *
 * @exception Exception if an MBean cannot be deregistered
 */
public static void destroyMBean(Loader loader)
    throws Exception {

    String mname = createManagedName(loader);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        return;
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ObjectName oname = createObjectName(domain, loader);
    mserver.unregisterMBean(oname);

}
项目:HowTomcatWorks    文件:StandardServer.java   
/**
 * Is this an instance of the default <code>Loader</code> configuration,
 * with all-default properties?
 *
 * @param loader Loader to be tested
 */
private boolean isDefaultLoader(Loader loader) {

    if (!(loader instanceof WebappLoader)) {
        return (false);
    }
    WebappLoader wloader = (WebappLoader) loader;
    if ((wloader.getCheckInterval() != 15) ||
        (wloader.getDebug() != 0) ||
        (wloader.getDelegate() != false) ||
        !wloader.getLoaderClass().equals
         ("org.apache.catalina.loader.WebappClassLoader")) {
        return (false);
    }
    return (true);

}
项目:WBSAirback    文件:MBeanUtils.java   
/**
 * Create, register, and return an MBean for this
 * <code>Loader</code> object.
 *
 * @param loader The Loader to be managed
 *
 * @exception Exception if an MBean cannot be created or registered
 */
static DynamicMBean createMBean(Loader loader)
    throws Exception {

    String mname = createManagedName(loader);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with "+mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    DynamicMBean mbean = managed.createMBean(loader);
    ObjectName oname = createObjectName(domain, loader);
    if( mserver.isRegistered( oname ))  {
        // side effect: stop it
        mserver.unregisterMBean( oname );
    }
    mserver.registerMBean(mbean, oname);
    return (mbean);

}
项目:WBSAirback    文件:MBeanUtils.java   
/**
 * Create an <code>ObjectName</code> for this
 * <code>Loader</code> object.
 *
 * @param domain Domain in which this name is to be created
 * @param loader The Loader to be named
 *
 * @exception MalformedObjectNameException if a name cannot be created
 */
static ObjectName createObjectName(String domain,
                                          Loader loader)
    throws MalformedObjectNameException {

    ObjectName name = null;
    Container container = loader.getContainer();

    if (container instanceof Engine) {
        name = new ObjectName(domain + ":type=Loader");
    } else if (container instanceof Host) {
        name = new ObjectName(domain + ":type=Loader,host=" +
                          container.getName());
    } else if (container instanceof Context) {
        Context context = ((Context)container);
        ContextName cn = new ContextName(context.getName());
        Container host = context.getParent();
        name = new ObjectName(domain + ":type=Loader,context=" +
                cn.getDisplayName() + ",host=" + host.getName());
    }

    return (name);

}
项目:WBSAirback    文件:MBeanUtils.java   
/**
 * Deregister the MBean for this
 * <code>Loader</code> object.
 *
 * @param loader The Loader to be managed
 *
 * @exception Exception if an MBean cannot be deregistered
 */
static void destroyMBean(Loader loader)
    throws Exception {

    String mname = createManagedName(loader);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        return;
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ObjectName oname = createObjectName(domain, loader);
    if( mserver.isRegistered(oname) )
        mserver.unregisterMBean(oname);

}
项目:tomee    文件:TomcatWebAppBuilder.java   
private static TomEEWebappClassLoader lazyClassLoader(final org.apache.catalina.Context child) {
    if (child == null) {
        return null;
    }

    final Loader loader = child.getLoader();
    if (loader == null || !(loader instanceof LazyStopLoader)) {
        return null;
    }

    final ClassLoader old = ((LazyStopLoader) loader).getStopClassLoader();
    if (old == null || !(old instanceof TomEEWebappClassLoader)) {
        return null;
    }

    return (TomEEWebappClassLoader) old;
}
项目:tomee    文件:TomcatWebAppBuilder.java   
/**
 * {@inheritDoc}
 */
@Override
public void destroy(final StandardContext standardContext) {
    final Loader standardContextLoader = standardContext.getLoader();
    if (LazyStopLoader.class.isInstance(standardContextLoader)) {
        final Loader delegate = LazyStopLoader.class.cast(standardContextLoader).getDelegateLoader();
        if (TomEEWebappLoader.class.isInstance(delegate)) {
            final TomEEWebappLoader webappLoader = TomEEWebappLoader.class.cast(delegate);
            final ClassLoader loader = webappLoader.internalLoader();
            webappLoader.clearLoader();
            if (TomEEWebappClassLoader.class.isInstance(loader)) {
                TomEEWebappClassLoader.class.cast(loader).internalDestroy();
            }
        }
    }

    final WebResourceRoot root = standardContext.getResources();
    if (LazyStopStandardRoot.class.isInstance(root)) {
        try {
            LazyStopStandardRoot.class.cast(root).internalDestroy();
        } catch (final LifecycleException e) {
            throw new IllegalStateException(e);
        }
    }
}
项目:tomcat7    文件:ClusterManagerBase.java   
public static ClassLoader[] getClassLoaders(Container container) {
    Loader loader = null;
    ClassLoader classLoader = null;
    if (container != null) loader = container.getLoader();
    if (loader != null) classLoader = loader.getClassLoader();
    else classLoader = Thread.currentThread().getContextClassLoader();
    if ( classLoader == Thread.currentThread().getContextClassLoader() ) {
        return new ClassLoader[] {classLoader};
    } else {
        return new ClassLoader[] {classLoader,Thread.currentThread().getContextClassLoader()};
    }
}
项目:tomcat7    文件:ReplicatedContext.java   
public ClassLoader[] getClassLoaders() {
    Loader loader = null;
    ClassLoader classLoader = null;
    loader = this.getLoader();
    if (loader != null) classLoader = loader.getClassLoader();
    if ( classLoader == null ) classLoader = Thread.currentThread().getContextClassLoader();
    if ( classLoader == Thread.currentThread().getContextClassLoader() ) {
        return new ClassLoader[] {classLoader};
    } else {
        return new ClassLoader[] {classLoader,Thread.currentThread().getContextClassLoader()};
    }
}
项目:tomcat7    文件:Embedded.java   
/**
 * Create and return a class loader manager that can be customized, and
 * then attached to a Context, before it is started.
 *
 * @param parent ClassLoader that will be the parent of the one
 *  created by this Loader
 */
public Loader createLoader(ClassLoader parent) {

    if( log.isDebugEnabled() )
        log.debug("Creating Loader with parent class loader '" +
                   parent + "'");

    WebappLoader loader = new WebappLoader(parent);
    return (loader);

}
项目:tomcat7    文件:ContainerBase.java   
/**
 * Return the Loader with which this Container is associated.  If there is
 * no associated Loader, return the Loader associated with our parent
 * Container (if any); otherwise, return <code>null</code>.
 */
@Override
public Loader getLoader() {

    if (loader != null)
        return (loader);
    if (parent != null)
        return (parent.getLoader());
    return (null);

}
项目:lams    文件:Embedded.java   
/**
 * Create and return a class loader manager that can be customized, and
 * then attached to a Context, before it is started.
 *
 * @param parent ClassLoader that will be the parent of the one
 *  created by this Loader
 */
public Loader createLoader(ClassLoader parent) {

    if( log.isDebugEnabled() )
        log.debug("Creating Loader with parent class loader '" +
                   parent + "'");

    WebappLoader loader = new WebappLoader(parent);
    return (loader);

}
项目:lams    文件:ContainerBase.java   
/**
 * Return the Loader with which this Container is associated.  If there is
 * no associated Loader, return the Loader associated with our parent
 * Container (if any); otherwise, return <code>null</code>.
 */
public Loader getLoader() {

    if (loader != null)
        return (loader);
    if (parent != null)
        return (parent.getLoader());
    return (null);

}