当前位置: 首页>>代码示例>>Java>>正文


Java Server.findService方法代码示例

本文整理汇总了Java中org.apache.catalina.Server.findService方法的典型用法代码示例。如果您正苦于以下问题:Java Server.findService方法的具体用法?Java Server.findService怎么用?Java Server.findService使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.catalina.Server的用法示例。


在下文中一共展示了Server.findService方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createStandardEngine

import org.apache.catalina.Server; //导入方法依赖的package包/类
/**
 * 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());

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:32,代码来源:MBeanFactory.java

示例2: removeContext

import org.apache.catalina.Server; //导入方法依赖的package包/类
/**
 * Remove an existing Context.
 *
 * @param name MBean Name of the comonent to remove
 *
 * @exception Exception if a component cannot be removed
 */
public void removeContext(String name) throws Exception {
    // Acquire a reference to the component to be removed
    ObjectName oname = new ObjectName(name);
    String serviceName = oname.getKeyProperty("service");
    String hostName = oname.getKeyProperty("host");
    String contextName = getPathStr(oname.getKeyProperty("path"));
    Server server = ServerFactory.getServer();
    Service service = server.findService(serviceName);
    Engine engine = (Engine) service.getContainer();
    Host host = (Host) engine.findChild(hostName);
    Context context = (Context) host.findChild(contextName);

    // Remove this component from its parent component
    host.removeChild(context);

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:24,代码来源:MBeanFactory.java

示例3: removeHost

import org.apache.catalina.Server; //导入方法依赖的package包/类
/**
 * Remove an existing Host.
 *
 * @param name MBean Name of the comonent 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 serviceName = oname.getKeyProperty("service");
    String hostName = oname.getKeyProperty("host");
    Server server = ServerFactory.getServer();
    Service service = server.findService(serviceName);
    Engine engine = (Engine) service.getContainer();
    Host host = (Host) engine.findChild(hostName);

    // Remove this component from its parent component
    engine.removeChild(host);

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:23,代码来源:MBeanFactory.java

示例4: removeService

import org.apache.catalina.Server; //导入方法依赖的package包/类
/**
 * 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 {

    // Acquire a reference to the component to be removed
    ObjectName oname = new ObjectName(name);
    String serviceName = oname.getKeyProperty("serviceName");
    Server server = ServerFactory.getServer();
    Service service = server.findService(serviceName);

    // Remove this component from its parent component
    server.removeService(service);

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:MBeanFactory.java

示例5: createDefaultContext

import org.apache.catalina.Server; //导入方法依赖的package包/类
/**
 * Create a new DefaultContext.
 *
 * @param parent MBean Name of the associated parent component
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public String createDefaultContext(String parent)
    throws Exception {

    // Create a new StandardDefaultContext instance
    StandardDefaultContext context = new StandardDefaultContext();

    // Add the new instance to its parent component
    ObjectName pname = new ObjectName(parent);
    String type = pname.getKeyProperty("type");
    Server server = ServerFactory.getServer();
    String serviceName = pname.getKeyProperty("service");
    if (serviceName == null) {
        serviceName = pname.getKeyProperty("name");
    }
    Service service = server.findService(serviceName);
    Engine engine = (Engine) service.getContainer();
    String hostName = pname.getKeyProperty("host");
    if (hostName == null) { //if DefaultContext is nested in Engine
        context.setParent(engine);
        engine.addDefaultContext(context);
    } else {                // if DefaultContext is nested in Host
        Host host = (Host) engine.findChild(hostName);
        context.setParent(host);
        host.addDefaultContext(context);
    }

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

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:41,代码来源:MBeanFactory.java

示例6: createStandardContext

import org.apache.catalina.Server; //导入方法依赖的package包/类
/**
 * Create a new StandardContext.
 *
 * @param parent MBean Name of the associated parent component
 * @param path The context path for this Context
 * @param docBase Document base directory (or WAR) for this Context
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public String createStandardContext(String parent, String path,
                                    String docBase)
    throws Exception {
    
    // Create a new StandardContext instance
    StandardContext context = new StandardContext();    
    path = getPathStr(path);
    context.setPath(path);
    context.setDocBase(docBase);
    ContextConfig contextConfig = new ContextConfig();
    context.addLifecycleListener(contextConfig);

    // Add the new instance to its parent component
    ObjectName pname = new ObjectName(parent);
    Server server = ServerFactory.getServer();
    Service service = server.findService(pname.getKeyProperty("service"));
    Engine engine = (Engine) service.getContainer();
    Host host = (Host) engine.findChild(pname.getKeyProperty("host"));

    // Add context to the host
    host.addChild(context);
    
    // Return the corresponding MBean name
    ManagedBean managed = registry.findManagedBean("StandardContext");

    ObjectName oname =
        MBeanUtils.createObjectName(managed.getDomain(), context);
    return (oname.toString());

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:40,代码来源:MBeanFactory.java

示例7: createStandardHost

import org.apache.catalina.Server; //导入方法依赖的package包/类
/**
 * 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 deployXML Should we deploy Context XML config files property?
 * @param liveDeploy Should we live deploy?
 * @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 name,
                                 String appBase, boolean autoDeploy,
                                 boolean deployXML, boolean liveDeploy,
                                 boolean unpackWARs)
    throws Exception {

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

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

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

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:43,代码来源:MBeanFactory.java

示例8: removeConnector

import org.apache.catalina.Server; //导入方法依赖的package包/类
/**
 * Remove an existing Connector.
 *
 * @param name MBean Name of the comonent to remove
 *
 * @param serviceName Service name of the connector 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);
    Server server = ServerFactory.getServer();
    String serviceName = oname.getKeyProperty("service");
    Service service = server.findService(serviceName);
    String port = oname.getKeyProperty("port");
    String address = oname.getKeyProperty("address");
    
    Connector conns[] = (Connector[]) service.findConnectors();

    for (int i = 0; i < conns.length; i++) {
        Class cls = conns[i].getClass();
        Method getAddrMeth = cls.getMethod("getAddress", null);
        Object addrObj = getAddrMeth.invoke(conns[i], null);
        String connAddress = null;
        if (addrObj != null) {
            connAddress = addrObj.toString();
        } 
        Method getPortMeth = cls.getMethod("getPort", null);
        Object portObj = getPortMeth.invoke(conns[i], null);
        String connPort = new String();
        if (portObj != null) {
            connPort = portObj.toString();
        }
        if (((address.equals("null")) && (connAddress==null)) && port.equals(connPort)) {
            service.removeConnector(conns[i]);
            break;
        } else if (address.equals(connAddress) && port.equals(connPort)) {
            // Remove this component from its parent component
            service.removeConnector(conns[i]);
            break;
        } 
    }

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:47,代码来源:MBeanFactory.java

示例9: removeService

import org.apache.catalina.Server; //导入方法依赖的package包/类
/**
 * 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 {

    // Acquire a reference to the component to be removed
    ObjectName oname = new ObjectName(name);
    String serviceName = oname.getKeyProperty("name");
    Server server = ServerFactory.getServer();
    Service service = server.findService(serviceName);

    // Remove this component from its parent component
    server.removeService(service);

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:20,代码来源:MBeanFactory.java

示例10: createAjpConnector

import org.apache.catalina.Server; //导入方法依赖的package包/类
/**
 * Create a new AjpConnector
 *
 * @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
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public String createAjpConnector(String parent, String address, int port)
    throws Exception {

    Object retobj = null;

    try {

        // Create a new CoyoteConnector instance for AJP
        // use reflection to avoid j-t-c compile-time circular dependencies
        Class cls = Class.forName("org.apache.coyote.tomcat4.CoyoteConnector");
        Constructor ct = cls.getConstructor(null);
        retobj = ct.newInstance(null);
        Class partypes1 [] = new Class[1];
        // Set address
        String str = new String();
        partypes1[0] = str.getClass();
        Method meth1 = cls.getMethod("setAddress", partypes1);
        Object arglist1[] = new Object[1];
        arglist1[0] = address;
        meth1.invoke(retobj, arglist1);
        // Set port number
        Class partypes2 [] = new Class[1];
        partypes2[0] = Integer.TYPE;
        Method meth2 = cls.getMethod("setPort", partypes2);
        Object arglist2[] = new Object[1];
        arglist2[0] = new Integer(port);
        meth2.invoke(retobj, arglist2);
        // set protocolHandlerClassName for AJP
        Class partypes3 [] = new Class[1];
        partypes3[0] = str.getClass();
        Method meth3 = cls.getMethod("setProtocolHandlerClassName", partypes3);
        Object arglist3[] = new Object[1];
        arglist3[0] = new String("org.apache.jk.server.JkCoyoteHandler");
        meth3.invoke(retobj, arglist3);

    } catch (Exception e) {
        throw new MBeanException(e);
    }

    // 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.addConnector((Connector)retobj);

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

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:62,代码来源:MBeanFactory.java

示例11: createHttpConnector

import org.apache.catalina.Server; //导入方法依赖的package包/类
/**
 * Create a new HttpConnector
 *
 * @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
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public String createHttpConnector(String parent, String address, int port)
    throws Exception {

    Object retobj = null;

    try {

        // Create a new CoyoteConnector instance
        // use reflection to avoid j-t-c compile-time circular dependencies
        Class cls = Class.forName("org.apache.coyote.tomcat4.CoyoteConnector");
        Constructor ct = cls.getConstructor(null);
        retobj = ct.newInstance(null);
        Class partypes1 [] = new Class[1];
        // Set address
        String str = new String();
        partypes1[0] = str.getClass();
        Method meth1 = cls.getMethod("setAddress", partypes1);
        Object arglist1[] = new Object[1];
        arglist1[0] = address;
        meth1.invoke(retobj, arglist1);
        // Set port number
        Class partypes2 [] = new Class[1];
        partypes2[0] = Integer.TYPE;
        Method meth2 = cls.getMethod("setPort", partypes2);
        Object arglist2[] = new Object[1];
        arglist2[0] = new Integer(port);
        meth2.invoke(retobj, arglist2);
    } catch (Exception e) {
        throw new MBeanException(e);
    }

    // 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.addConnector((Connector)retobj);

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

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:54,代码来源:MBeanFactory.java


注:本文中的org.apache.catalina.Server.findService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。