本文整理汇总了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());
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}
示例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());
}
示例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());
}
示例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;
}
}
}
示例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);
}
示例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());
}
示例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());
}