微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

org.apache.catalina.Service的实例源码

项目:tomcat7    文件ContextConfig.java   
private Server getServer() {
    Container c = context;
    while (c != null && !(c instanceof Engine)) {
        c = c.getParent();
    }

    if (c == null) {
        return null;
    }

    Service s = ((Engine)c).getService();

    if (s == null) {
        return null;
    }

    return s.getServer();
}
项目:tomcat7    文件Mbeanfactory.java   
/**
 * Create a new Connector
 *
 * @param parent MBean Name of the associated parent component
 * @param address The IP address on which to bind
 * @param port TCP port number to listen on
 * @param isAjp Create a AJP/1.3 Connector
 * @param isSSL Create a secure Connector
 *
 * @exception Exception if an MBean cannot be created or registered
 */
private String createConnector(String parent,String address,int port,boolean isAjp,boolean isSSL)
    throws Exception {
    Connector retobj = new Connector();
    if ((address!=null) && (address.length()>0)) {
        retobj.setProperty("address",address);
    }
    // Set port number
    retobj.setPort(port);
    // Set the protocol
    retobj.setProtocol(isAjp ? "AJP/1.3" : "HTTP/1.1");
    // Set SSL
    retobj.setSecure(isSSL);
    retobj.setScheme(isSSL ? "https" : "http");
    // Add the new instance to its parent component
    // FIX ME - addConnector will fail
    ObjectName pname = new ObjectName(parent);
    Service service = getService(pname);
    service.addConnector(retobj);

    // Return the corresponding MBean name
    ObjectName coname = retobj.getobjectName();

    return (coname.toString());
}
项目:tomcat7    文件Mbeanfactory.java   
/**
 * Creates a new StandardService and StandardEngine.
 *
 * @param domain       Domain name for the container instance
 * @param defaultHost  Name of the default host to be used in the Engine
 * @param baseDir      Base directory value for Engine 
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public String createStandardServiceEngine(String domain,String defaultHost,String baseDir) throws Exception{

    if (!(container instanceof Server)) {
        throw new Exception("Container not Server");
    }

    StandardEngine engine = new StandardEngine();
    engine.setDomain(domain);
    engine.setName(domain);
    engine.setDefaultHost(defaultHost);
    engine.setBaseDir(baseDir);

    Service service = new StandardService();
    service.setContainer(engine);
    service.setName(domain);

    ((Server) container).addService(service);

    return engine.getobjectName().toString();
}
项目:tomcat7    文件MBeanUtils.java   
/**
 * Deregister the MBean for this
 * <code>Service</code> object.
 *
 * @param service The Service 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(Service service)
    throws Exception {

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

}
项目:tomcat7    文件MBeanUtils.java   
/**
 * Determine the name of the domain to register MBeans for from a given
 * Service.
 * 
 * @param service 
 *
 * @deprecated  To be removed since to creates a circular dependency. Will
 *              be replaced in Tomcat 8 by a new method on {@link
 *              Service}.
 */
@Deprecated
public static String getDomain(Service service) {

    // Null service -> return null
    if (service == null) {
        return null;
    }

    String domain = null;

    Container engine = service.getContainer();

    // Use the engine name first
    if (engine != null) {
        domain = engine.getName();
    }

    // No engine or no engine name,use the service name 
    if (domain == null) {
        domain = service.getName();
    }

    // No service name,use null
    return domain;
}
项目:tomcat7    文件RealmBase.java   
/**
 * Return the Server object that is the ultimate parent for the container
 * with which this Realm is associated. If the server cannot be found (eg
 * because the container hierarchy is not complete),<code>null</code> is
 * returned.
 */
protected Server getServer() {
    Container c = container;
    if (c instanceof Context) {
        c = c.getParent();
    }
    if (c instanceof Host) {
        c = c.getParent();
    }
    if (c instanceof Engine) {
        Service s = ((Engine)c).getService();
        if (s != null) {
            return s.getServer();
        }
    }
    return null;
}
项目:tomcat7    文件StandardServer.java   
/**
 * Add a new Service to the set of defined Services.
 *
 * @param service The Service to be added
 */
@Override
public void addService(Service service) {

    service.setServer(this);

    synchronized (servicesLock) {
        Service results[] = new Service[services.length + 1];
        System.arraycopy(services,results,services.length);
        results[services.length] = service;
        services = results;

        if (getState().isAvailable()) {
            try {
                service.start();
            } catch (LifecycleException e) {
                // Ignore
            }
        }

        // Report this property change to interested listeners
        support.firePropertyChange("service",null,service);
    }

}
项目:tomcat7    文件StandardServer.java   
/**
 * Return the specified Service (if it exists); otherwise return
 * <code>null</code>.
 *
 * @param name Name of the Service to be returned
 */
@Override
public Service findService(String name) {

    if (name == null) {
        return (null);
    }
    synchronized (servicesLock) {
        for (int i = 0; i < services.length; i++) {
            if (name.equals(services[i].getName())) {
                return (services[i]);
            }
        }
    }
    return (null);

}
项目:tomcat7    文件ApplicationContext.java   
private void populateSessionTrackingModes() {
    // URL re-writing is always enabled by default
    defaultSessionTrackingModes = EnumSet.of(SessionTrackingMode.URL);
    supportedSessionTrackingModes = EnumSet.of(SessionTrackingMode.URL);

    if (context.getCookies()) {
        defaultSessionTrackingModes.add(SessionTrackingMode.COOKIE);
        supportedSessionTrackingModes.add(SessionTrackingMode.COOKIE);
    }

    // SSL not enabled by default as it can only used on its own
    // Context > Host > Engine > Service
    Service s = ((Engine) context.getParent().getParent()).getService();
    Connector[] connectors = s.findConnectors();
    // Need at least one SSL enabled connector to use the SSL session ID.
    for (Connector connector : connectors) {
        if (Boolean.TRUE.equals(connector.getAttribute("SSLEnabled"))) {
            supportedSessionTrackingModes.add(SessionTrackingMode.SSL);
            break;
        }
    }
}
项目:lazycat    文件StandardServer.java   
/**
 * Add a new Service to the set of defined Services.
 *
 * @param service
 *            The Service to be added
 */
@Override
public void addService(Service service) {

    service.setServer(this);

    synchronized (servicesLock) {
        Service results[] = new Service[services.length + 1];
        System.arraycopy(services,service);
    }

}
项目:lams    文件ServerLifecycleListener.java   
/**
 * Create the MBeans for the specified Service and its nested components.
 *
 * @param service Service for which to create MBeans
 *
 * @exception Exception if an exception is thrown during MBean creation
 */
protected void createMBeans(Service service) throws Exception {

    // Create the MBean for the Service itself
    if (log.isDebugEnabled())
        log.debug("Creating MBean for Service " + service);
    //MBeanUtils.createMBean(service);
    if (service instanceof StandardService) {
        ((StandardService) service).addPropertychangelistener(this);
    }

    // Create the MBeans for the corresponding Connectors
    Connector connectors[] = service.findConnectors();
    for (int j = 0; j < connectors.length; j++) {
        createMBeans(connectors[j]);
    }

    // Create the MBean for the associated Engine and friends
    Engine engine = (Engine) service.getContainer();
    if (engine != null) {
        createMBeans(engine);
    }

}
项目:lazycat    文件ApplicationContext.java   
private void populateSessionTrackingModes() {
    // URL re-writing is always enabled by default
    defaultSessionTrackingModes = EnumSet.of(SessionTrackingMode.URL);
    supportedSessionTrackingModes = EnumSet.of(SessionTrackingMode.URL);

    if (context.getCookies()) {
        defaultSessionTrackingModes.add(SessionTrackingMode.COOKIE);
        supportedSessionTrackingModes.add(SessionTrackingMode.COOKIE);
    }

    // SSL not enabled by default as it can only used on its own
    // Context > Host > Engine > Service
    Service s = ((Engine) context.getParent().getParent()).getService();
    Connector[] connectors = s.findConnectors();
    // Need at least one SSL enabled connector to use the SSL session ID.
    for (Connector connector : connectors) {
        if (Boolean.TRUE.equals(connector.getAttribute("SSLEnabled"))) {
            supportedSessionTrackingModes.add(SessionTrackingMode.SSL);
            break;
        }
    }
}
项目:lazycat    文件RealmBase.java   
/**
 * Return the Server object that is the ultimate parent for the container
 * with which this Realm is associated. If the server cannot be found (eg
 * because the container hierarchy is not complete),<code>null</code> is
 * returned.
 */
protected Server getServer() {
    Container c = container;
    if (c instanceof Context) {
        c = c.getParent();
    }
    if (c instanceof Host) {
        c = c.getParent();
    }
    if (c instanceof Engine) {
        Service s = ((Engine) c).getService();
        if (s != null) {
            return s.getServer();
        }
    }
    return null;
}
项目:lams    文件Mbeanfactory.java   
/**
 * Create a new Connector
 *
 * @param parent MBean Name of the associated parent component
 * @param address The IP address on which to bind
 * @param port TCP port number to listen on
 * @param isAjp Create a AJP/1.3 Connector
 * @param isSSL Create a secure Connector
 *
 * @exception Exception if an MBean cannot be created or registered
 */
private String createConnector(String parent,address);
    }
    // Set port number
    retobj.setPort(port);
    // Set the protocol
    retobj.setProtocol(isAjp ? "AJP/1.3" : "HTTP/1.1");
    // Set SSL
    retobj.setSecure(isSSL);
    retobj.setScheme(isSSL ? "https" : "http");
    // Add the new instance to its parent component
    // FIX ME - addConnector will fail
    ObjectName pname = new ObjectName(parent);
    Service service = getService(pname);
    service.addConnector(retobj);

    // Return the corresponding MBean name
    ObjectName coname = retobj.getobjectName();

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

    String mname = createManagedname(service);
    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(service);
    ObjectName oname = createObjectName(domain,service);
    if( mserver.isRegistered( oname ))  {
        mserver.unregisterMBean(oname);
    }
    mserver.registerMBean(mbean,oname);
    return (mbean);

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

    connector.setService(service);
    String mname = createManagedname(connector);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        return;
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ObjectName oname = createObjectName(domain,connector);
    connector.setService(null);
    if( mserver.isRegistered( oname ))  {
        mserver.unregisterMBean(oname);
    }
}
项目:lams    文件MBeanUtils.java   
/**
 * Deregister the MBean for this
 * <code>Service</code> object.
 *
 * @param service The Service to be managed
 *
 * @exception Exception if an MBean cannot be deregistered
 */
static void destroyMBean(Service service)
    throws Exception {

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

}
项目:lams    文件StandardServer.java   
/**
 * Return the specified Service (if it exists); otherwise return
 * <code>null</code>.
 *
 * @param name Name of the Service to be returned
 */
public Service findService(String name) {

    if (name == null) {
        return (null);
    }
    synchronized (services) {
        for (int i = 0; i < services.length; i++) {
            if (name.equals(services[i].getName())) {
                return (services[i]);
            }
        }
    }
    return (null);

}
项目:lams    文件ClusterListener.java   
/**
 * Reset configuration for a particular proxy following an error.
 */
protected void reset(int pos) {

    Service[] services = ServerFactory.getServer().findServices();
    for (int i = 0; i < services.length; i++) {
        Engine engine = (Engine) services[i].getContainer();
        removeAll((Engine) services[i].getContainer(),pos);
        config(engine,pos);
        Container[] children = engine.findChildren();
        for (int j = 0; j < children.length; j++) {
            Container[] children2 = children[j].findChildren();
            for (int k = 0; k < children2.length; k++) {
                addContext((Context) children2[k],pos);
            }
        }
    }

}
项目:jerrydog    文件ServerLifecycleListener.java   
/**
 * Create the MBeans for the specified Service and its nested components.
 *
 * @param service Service for which to create MBeans
 *
 * @exception Exception if an exception is thrown during MBean creation
 */
protected void createMBeans(Service service) throws Exception {

    // Create the MBean for the Service itself
    if (debug >= 2)
        log("Creating MBean for Service " + service);
    MBeanUtils.createMBean(service);
    if (service instanceof StandardService) {
        ((StandardService) service).addPropertychangelistener(this);
    }

    // Create the MBeans for the corresponding Connectors
    Connector connectors[] = service.findConnectors();
    for (int j = 0; j < connectors.length; j++) {
        createMBeans(connectors[j]);
    }

    // Create the MBean for the associated Engine and friends
    Engine engine = (Engine) service.getContainer();
    if (engine != null) {
        createMBeans(engine);
    }

}
项目:jerrydog    文件ServerLifecycleListener.java   
/**
 * Deregister the MBeans for the specified Service and its nested
 * components.
 *
 * @param service Service for which to destroy MBeans
 *
 * @exception Exception if an exception is thrown during MBean destruction
 */
protected void destroyMBeans(Service service) throws Exception {

    // Deregister the MBeans for the associated Engine
    Engine engine = (Engine) service.getContainer();
    if (engine != null) {
        destroyMBeans(engine);
    }

    // Deregister the MBeans for the corresponding Connectors
    Connector connectors[] = service.findConnectors();
    for (int j = 0; j < connectors.length; j++) {
        destroyMBeans(connectors[j],service);
    }

    // Deregister the MBean for the Service itself
    if (debug >= 2) {
        log("Destroying MBean for Service " + service);
    }
    MBeanUtils.destroyMBean(service);
    if (service instanceof StandardService) {
        ((StandardService) service).removePropertychangelistener(this);
    }

}
项目:jerrydog    文件Mbeanfactory.java   
/**
 * Create a new StandardEngine.
 *
 * @param parent MBean Name of the associated parent component
 * @param name Unique name of this Engine
 * @param defaultHost Default hostname of this Engine
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public String createStandardEngine(String parent,String name,String defaultHost)
    throws Exception {

    // Create a new StandardEngine instance
    StandardEngine engine = new StandardEngine();
    engine.setName(name);
    engine.setDefaultHost(defaultHost);

    // Add the new instance to its parent component
    ObjectName pname = new ObjectName(parent);
    Server server = ServerFactory.getServer();
    Service service = server.findService(pname.getKeyProperty("name"));
    service.setContainer(engine);

    // Return the corresponding MBean name
    ManagedBean managed = registry.findManagedBean("StandardEngine");
    ObjectName oname =
        MBeanUtils.createObjectName(managed.getDomain(),engine);
    return (oname.toString());

}
项目:lazycat    文件Mbeanfactory.java   
/**
 * Create a new Connector
 *
 * @param parent
 *            MBean Name of the associated parent component
 * @param address
 *            The IP address on which to bind
 * @param port
 *            TCP port number to listen on
 * @param isAjp
 *            Create a AJP/1.3 Connector
 * @param isSSL
 *            Create a secure Connector
 *
 * @exception Exception
 *                if an MBean cannot be created or registered
 */
private String createConnector(String parent,boolean isSSL)
        throws Exception {
    Connector retobj = new Connector();
    if ((address != null) && (address.length() > 0)) {
        retobj.setProperty("address",address);
    }
    // Set port number
    retobj.setPort(port);
    // Set the protocol
    retobj.setProtocol(isAjp ? "AJP/1.3" : "HTTP/1.1");
    // Set SSL
    retobj.setSecure(isSSL);
    retobj.setScheme(isSSL ? "https" : "http");
    // Add the new instance to its parent component
    // FIX ME - addConnector will fail
    ObjectName pname = new ObjectName(parent);
    Service service = getService(pname);
    service.addConnector(retobj);

    // Return the corresponding MBean name
    ObjectName coname = retobj.getobjectName();

    return (coname.toString());
}
项目:jerrydog    文件MBeanUtils.java   
/**
 * Deregister the MBean for this
 * <code>Connector</code> object.
 *
 * @param connector The Connector to be managed
 *
 * @exception Exception if an MBean cannot be deregistered
 */
public static void destroyMBean(Connector connector,connector);
    connector.setService(null);
    mserver.unregisterMBean(oname);

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

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

}
项目:jerrydog    文件StandardServer.java   
/**
 * Return the specified Service (if it exists); otherwise return
 * <code>null</code>.
 *
 * @param name Name of the Service to be returned
 */
public Service findService(String name) {

    if (name == null) {
        return (null);
    }
    synchronized (services) {
        for (int i = 0; i < services.length; i++) {
            if (name.equals(services[i].getName())) {
                return (services[i]);
            }
        }
    }
    return (null);

}
项目:lazycat    文件MBeanUtils.java   
/**
 * Determine the name of the domain to register MBeans for from a given
 * Service.
 * 
 * @param service
 *
 * @deprecated To be removed since to creates a circular dependency. Will be
 *             replaced in Tomcat 8 by a new method on {@link Service}.
 */
@Deprecated
public static String getDomain(Service service) {

    // Null service -> return null
    if (service == null) {
        return null;
    }

    String domain = null;

    Container engine = service.getContainer();

    // Use the engine name first
    if (engine != null) {
        domain = engine.getName();
    }

    // No engine or no engine name,use the service name
    if (domain == null) {
        domain = service.getName();
    }

    // No service name,use null
    return domain;
}
项目:apache-tomcat-7.0.73-with-comment    文件Mbeanfactory.java   
/**
 * Create a new Connector
 *
 * @param parent MBean Name of the associated parent component
 * @param address The IP address on which to bind
 * @param port TCP port number to listen on
 * @param isAjp Create a AJP/1.3 Connector
 * @param isSSL Create a secure Connector
 *
 * @exception Exception if an MBean cannot be created or registered
 */
private String createConnector(String parent,address);
    }
    // Set port number
    retobj.setPort(port);
    // Set the protocol
    retobj.setProtocol(isAjp ? "AJP/1.3" : "HTTP/1.1");
    // Set SSL
    retobj.setSecure(isSSL);
    retobj.setScheme(isSSL ? "https" : "http");
    // Add the new instance to its parent component
    // FIX ME - addConnector will fail
    ObjectName pname = new ObjectName(parent);
    Service service = getService(pname);
    service.addConnector(retobj);

    // Return the corresponding MBean name
    ObjectName coname = retobj.getobjectName();

    return (coname.toString());
}
项目:apache-tomcat-7.0.73-with-comment    文件Mbeanfactory.java   
/**
 * Creates a new StandardService and StandardEngine.
 *
 * @param domain       Domain name for the container instance
 * @param defaultHost  Name of the default host to be used in the Engine
 * @param baseDir      Base directory value for Engine 
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public String createStandardServiceEngine(String domain,String baseDir) throws Exception{

    if (!(container instanceof Server)) {
        throw new Exception("Container not Server");
    }

    StandardEngine engine = new StandardEngine();
    engine.setDomain(domain);
    engine.setName(domain);
    engine.setDefaultHost(defaultHost);
    engine.setBaseDir(baseDir);

    Service service = new StandardService();
    service.setContainer(engine);
    service.setName(domain);

    ((Server) container).addService(service);

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

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

}
项目:apache-tomcat-7.0.73-with-comment    文件MBeanUtils.java   
/**
 * Determine the name of the domain to register MBeans for from a given
 * Service.
 * 
 * @param service 
 *
 * @deprecated  To be removed since to creates a circular dependency. Will
 *              be replaced in Tomcat 8 by a new method on {@link
 *              Service}.
 */
@Deprecated
public static String getDomain(Service service) {

    // Null service -> return null
    if (service == null) {
        return null;
    }

    String domain = null;

    Container engine = service.getContainer();

    // Use the engine name first
    if (engine != null) {
        domain = engine.getName();
    }

    // No engine or no engine name,use null
    return domain;
}
项目:apache-tomcat-7.0.73-with-comment    文件RealmBase.java   
/**
 * Return the Server object that is the ultimate parent for the container
 * with which this Realm is associated. If the server cannot be found (eg
 * because the container hierarchy is not complete),<code>null</code> is
 * returned.
 */
protected Server getServer() {
    Container c = container;
    if (c instanceof Context) {
        c = c.getParent();
    }
    if (c instanceof Host) {
        c = c.getParent();
    }
    if (c instanceof Engine) {
        Service s = ((Engine)c).getService();
        if (s != null) {
            return s.getServer();
        }
    }
    return null;
}
项目:lazycat    文件Mbeanfactory.java   
/**
 * Create a new StandardHost.
 *
 * @param parent
 *            MBean Name of the associated parent component
 * @param name
 *            Unique name of this Host
 * @param appBase
 *            Application base directory name
 * @param autoDeploy
 *            Should we auto deploy?
 * @param deployOnStartup
 *            Deploy on server startup?
 * @param deployXML
 *            Should we deploy Context XML config files property?
 * @param unpackWARs
 *            Should we unpack WARs when auto deploying?
 *
 * @exception Exception
 *                if an MBean cannot be created or registered
 */
public String createStandardHost(String parent,String appBase,boolean autoDeploy,boolean deployOnStartup,boolean deployXML,boolean unpackWARs) throws Exception {

    // Create a new StandardHost instance
    StandardHost host = new StandardHost();
    host.setName(name);
    host.setAppBase(appBase);
    host.setAutoDeploy(autoDeploy);
    host.setDeployOnStartup(deployOnStartup);
    host.setDeployXML(deployXML);
    host.setUnpackWARs(unpackWARs);

    // add HostConfig for active reloading
    HostConfig hostConfig = new HostConfig();
    host.addLifecycleListener(hostConfig);

    // Add the new instance to its parent component
    ObjectName pname = new ObjectName(parent);
    Service service = getService(pname);
    Engine engine = (Engine) service.getContainer();
    engine.addChild(host);

    // Return the corresponding MBean name
    return (host.getobjectName().toString());

}
项目:tomcat7    文件ConnectorCreateRule.java   
/**
 * Process the beginning of this element.
 *
 * @param namespace the namespace URI of the matching element,or an 
 *   empty string if the parser is not namespace aware or the element has
 *   no namespace
 * @param name the local name if the parser is namespace aware,or just 
 *   the element name otherwise
 * @param attributes The attribute list for this element
 */
@Override
public void begin(String namespace,Attributes attributes)
        throws Exception {
    Service svc = (Service)digester.peek();
    Executor ex = null;
    if ( attributes.getValue("executor")!=null ) {
        ex = svc.getExecutor(attributes.getValue("executor"));
    }
    Connector con = new Connector(attributes.getValue("protocol"));
    if ( ex != null )  _setExecutor(con,ex);

    digester.push(con);
}
项目:tomcat7    文件Mbeanfactory.java   
/**
 * Create a new StandardHost.
 *
 * @param parent MBean Name of the associated parent component
 * @param name Unique name of this Host
 * @param appBase Application base directory name
 * @param autoDeploy Should we auto deploy?
 * @param deployOnStartup Deploy on server startup?
 * @param deployXML Should we deploy Context XML config files property?
 * @param unpackWARs Should we unpack WARs when auto deploying?
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public String createStandardHost(String parent,boolean unpackWARs)
    throws Exception {

    // Create a new StandardHost instance
    StandardHost host = new StandardHost();
    host.setName(name);
    host.setAppBase(appBase);
    host.setAutoDeploy(autoDeploy);
    host.setDeployOnStartup(deployOnStartup);
    host.setDeployXML(deployXML);
    host.setUnpackWARs(unpackWARs);

    // add HostConfig for active reloading
    HostConfig hostConfig = new HostConfig();
    host.addLifecycleListener(hostConfig);

    // Add the new instance to its parent component
    ObjectName pname = new ObjectName(parent);
    Service service = getService(pname);
    Engine engine = (Engine) service.getContainer();
    engine.addChild(host);

    // Return the corresponding MBean name
    return (host.getobjectName().toString());

}
项目:tomcat7    文件Mbeanfactory.java   
/**
 * Remove an existing Connector.
 *
 * @param name MBean Name of the component to remove
 *
 * @exception Exception if a component cannot be removed
 */
public void removeConnector(String name) throws Exception {

    // Acquire a reference to the component to be removed
    ObjectName oname = new ObjectName(name);
    Service service = getService(oname);
    String port = oname.getKeyProperty("port");
    //String address = oname.getKeyProperty("address");

    Connector conns[] = service.findConnectors();

    for (int i = 0; i < conns.length; i++) {
        String connAddress = String.valueOf(conns[i].getProperty("address"));
        String connPort = ""+conns[i].getPort();

        // if (((address.equals("null")) &&
        if ((connAddress==null) && port.equals(connPort)) {
            service.removeConnector(conns[i]);
            conns[i].destroy();
            break;
        }
        // } else if (address.equals(connAddress))
        if (port.equals(connPort)) {
            // Remove this component from its parent component
            service.removeConnector(conns[i]);
            conns[i].destroy();
            break;
        }
    }

}
项目:tomcat7    文件Mbeanfactory.java   
/**
 * Remove an existing Host.
 *
 * @param name MBean Name of the component to remove
 *
 * @exception Exception if a component cannot be removed
 */
public void removeHost(String name) throws Exception {

    // Acquire a reference to the component to be removed
    ObjectName oname = new ObjectName(name);
    String hostName = oname.getKeyProperty("host");
    Service service = getService(oname);
    Engine engine = (Engine) service.getContainer();
    Host host = (Host) engine.findChild(hostName);

    // Remove this component from its parent component
    if(host!=null) {
        engine.removeChild(host);
    }
}
项目:tomcat7    文件Mbeanfactory.java   
/**
 * Remove an existing Service.
 *
 * @param name MBean Name of the component to remove
 *
 * @exception Exception if a component cannot be removed
 */
public void removeService(String name) throws Exception {

    if (!(container instanceof Server)) {
        throw new Exception();
    }

    // Acquire a reference to the component to be removed
    ObjectName oname = new ObjectName(name);
    Service service = getService(oname); 
    ((Server) container).removeService(service);
}
项目:tomcat7    文件MBeanUtils.java   
/**
 * Deregister the MBean for this
 * <code>Connector</code> object.
 *
 * @param connector The Connector 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(Connector connector,Service service)
    throws Exception {

    // domain is engine name
    String domain = service.getContainer().getName();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ObjectName oname = createObjectName(domain,connector);
    if( mserver.isRegistered( oname ))  {
        mserver.unregisterMBean(oname);
    }
    // Unregister associated request processor
    String worker = null;
    ProtocolHandler handler = connector.getProtocolHandler();
    if (handler instanceof Http11Protocol) {
        worker = ((Http11Protocol)handler).getName();
    } else if (handler instanceof Http11NioProtocol) {
        worker = ((Http11NioProtocol)handler).getName();
    } else if (handler instanceof Http11AprProtocol) {
        worker = ((Http11AprProtocol)handler).getName();
    } else if (handler instanceof AjpProtocol) {
        worker = ((AjpProtocol)handler).getName();
    } else if (handler instanceof AjpAprProtocol) {
        worker = ((AjpAprProtocol)handler).getName();
    }
    ObjectName query = new ObjectName(
            domain + ":type=RequestProcessor,worker=" + worker + ",*");
    Set<ObjectName> results = mserver.queryNames(query,null);
    for(ObjectName result : results) {
        mserver.unregisterMBean(result);
    }
}
项目:tomcat7    文件StandardServer.java   
/**
 * Remove the specified Service from the set associated from this
 * Server.
 *
 * @param service The Service to be removed
 */
@Override
public void removeService(Service service) {

    synchronized (servicesLock) {
        int j = -1;
        for (int i = 0; i < services.length; i++) {
            if (service == services[i]) {
                j = i;
                break;
            }
        }
        if (j < 0)
            return;
        try {
            services[j].stop();
        } catch (LifecycleException e) {
            // Ignore
        }
        int k = 0;
        Service results[] = new Service[services.length - 1];
        for (int i = 0; i < services.length; i++) {
            if (i != j)
                results[k++] = services[i];
        }
        services = results;

        // Report this property change to interested listeners
        support.firePropertyChange("service",service,null);
    }

}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。