本文整理了Java中org.apache.catalina.Server.findService()
方法的一些代码示例,展示了Server.findService()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Server.findService()
方法的具体详情如下:
包路径:org.apache.catalina.Server
类名称:Server
方法名:findService
[英]Return the specified Service (if it exists); otherwise return null
.
[中]返回指定的服务(如果存在);否则返回null
。
代码示例来源:origin: org.apache.geronimo.modules/geronimo-tomcat6
public Service getService(String serviceName) {
Service service;
if (serviceName == null) {
Service[] services = server.findServices();
if (services == null || services.length == 0) throw new IllegalStateException("No services in server");
if (services.length > 1) throw new IllegalStateException("More than one service in server. Provide name of desired server" + Arrays.asList(services));
service = services[0];
} else {
service = server.findService(serviceName);
}
return service;
}
代码示例来源:origin: tomcat/catalina
/**
* 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);
}
代码示例来源:origin: org.graniteds/granite-server
public void configure(Map<String, String> params) {
String serviceId = params.get("service");
Server server = ServerFactory.getServer();
if (server == null)
throw new NullPointerException("Could not get Tomcat server");
Service service = null;
if (serviceId != null)
service = server.findService(serviceId);
else {
Service[] services = server.findServices();
if (services != null && services.length > 0)
service = services[0];
}
if (service == null)
throw new NullPointerException("Could not find Tomcat service for: " + (serviceId != null ? serviceId : "(default)"));
engine = (Engine)service.getContainer();
if (engine == null)
throw new NullPointerException("Could not find Tomcat container for: " + (serviceId != null ? serviceId : "(default)"));
}
代码示例来源:origin: stackoverflow.com
MBeanServer mBeanServer = MBeanServerFactory.findMBeanServer(null).get(0);
ObjectName name = new ObjectName("Catalina", "type", "Server");
Server server = (Server) mBeanServer.getAttribute(name, "managedResource");
Service service = server.findService("Catalina");
Engine engine = (Engine) service.getContainer();
Host host = (Host) engine.findChild(engine.getDefaultHost());
host.getAppBase(); //Got it.
代码示例来源:origin: org.graniteds/granite-server
public void configure(Map<String, String> params) {
String serviceId = params.get("service");
Server server = ServerFactory.getServer();
if (server == null)
throw new NullPointerException("Could not get Tomcat server");
Service service = null;
if (serviceId != null)
service = server.findService(serviceId);
else {
Service[] services = server.findServices();
if (services != null && services.length > 0)
service = services[0];
}
if (service == null)
throw new NullPointerException("Could not find Tomcat service for: " + (serviceId != null ? serviceId : "(default)"));
engine = (Engine)service.getContainer();
if (engine == null)
throw new NullPointerException("Could not find Tomcat container for: " + (serviceId != null ? serviceId : "(default)"));
}
代码示例来源:origin: org.graniteds/granite-server
public void configure(Map<String, String> params) {
String serviceId = params.get("service");
Server server = ServerFactory.getServer();
if (server == null)
throw new NullPointerException("Could not get GlassFish V3 server");
Service service = null;
if (serviceId != null)
service = server.findService(serviceId);
else {
Service[] services = server.findServices();
if (services != null && services.length > 0)
service = services[0];
}
if (service == null)
throw new NullPointerException("Could not find GlassFish V3 service for: " + (serviceId != null ? serviceId : "(default)"));
engine = (Engine)service.getContainer();
if (engine == null)
throw new NullPointerException("Could not find GlassFish V3 container for: " + (serviceId != null ? serviceId : "(default)"));
}
内容来源于网络,如有侵权,请联系作者删除!