本文整理了Java中org.apache.catalina.Engine.findChild()
方法的一些代码示例,展示了Engine.findChild()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Engine.findChild()
方法的具体详情如下:
包路径:org.apache.catalina.Engine
类名称:Engine
方法名:findChild
暂无
代码示例来源:origin: org.jboss.mod_cluster/mod_cluster
/**
* {@inhericDoc}
* @see org.jboss.modcluster.Engine#findHost(java.lang.String)
*/
public Host findHost(String name)
{
org.apache.catalina.Host host = (org.apache.catalina.Host) this.engine.findChild(name);
return (host != null) ? new CatalinaHost(host, this) : null;
}
代码示例来源:origin: org.graniteds/granite-server
protected Context getContext(HttpServletRequest request) {
String serverName = request.getServerName();
String contextPath = request.getContextPath();
Host host = (Host)engine.findChild(serverName);
if (host == null) {
// if it cannot find host, then use the default host.
host = (Host)engine.findChild(engine.getDefaultHost());
if (host == null)
throw new NullPointerException("Could not find Tomcat host for: " + serverName + " or: " + engine.getDefaultHost());
}
Context context = (Context)host.findChild(contextPath);
if (context == null)
throw new NullPointerException("Could not find Tomcat context for: " + contextPath);
return context;
}
代码示例来源:origin: modcluster/mod_cluster
@Override
public Host findHost(String name) {
org.apache.catalina.Host host = (org.apache.catalina.Host) this.engine.findChild(name);
return (host != null) ? this.registry.getHostFactory().createHost(this.registry, host, this) : null;
}
代码示例来源:origin: org.apache.geronimo.modules/geronimo-tomcat
public void addWebService(String contextPath, String[] virtualHosts, WebServiceContainer webServiceContainer, String securityRealmName, String realmName, String transportGuarantee, String authMethod, ClassLoader classLoader) throws Exception {
Context webServiceContext = embedded.createEJBWebServiceContext(contextPath, webServiceContainer, securityRealmName, realmName, transportGuarantee, authMethod, classLoader);
String virtualServer;
if (virtualHosts != null && virtualHosts.length > 0) {
virtualServer = virtualHosts[0];
} else {
virtualServer = engine.getDefaultHost();
}
Container host = engine.findChild(virtualServer);
if (host == null) {
throw new IllegalArgumentException("Invalid virtual host '" + virtualServer + "'. Do you have a matchiing Host entry in the plan?");
}
host.addChild(webServiceContext);
webServices.put(contextPath, webServiceContext);
}
代码示例来源: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.apache.tomcat/tomcat-catalina
/**
* 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 = service.getContainer();
Host host = (Host) engine.findChild(hostName);
// Remove this component from its parent component
if(host!=null) {
engine.removeChild(host);
}
}
代码示例来源:origin: codefollower/Tomcat-Research
/**
* 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);
}
}
代码示例来源:origin: org.apache.catalina/com.springsource.org.apache.catalina
/**
* 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);
}
}
代码示例来源:origin: org.apache.geronimo.ext.tomcat/catalina
/**
* 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);
}
}
代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9
/**
* 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);
}
}
代码示例来源:origin: com.ovea.tajin.server/tajin-server-tomcat7
/**
* 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);
}
}
代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core
/**
* 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 = service.getContainer();
Host host = (Host) engine.findChild(hostName);
// Remove this component from its parent component
if(host!=null) {
engine.removeChild(host);
}
}
代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9
/**
* 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);
}
}
代码示例来源:origin: org.glassfish.web/web-glue
/**
* Load a default-web-module on the specified virtual server.
*/
public void loadDefaultWebModule(
com.sun.enterprise.config.serverbeans.VirtualServer vsBean) {
VirtualServer virtualServer = (VirtualServer)
getEngine().findChild(vsBean.getId());
if (virtualServer != null) {
loadDefaultWebModule(virtualServer);
}
}
代码示例来源:origin: apache/ofbiz-framework
private Host prepareVirtualHost(Tomcat tomcat, List<String> virtualHosts) {
// assume that the first virtual-host will be the default; additional virtual-hosts will be aliases
String hostName = virtualHosts.get(0);
Host host;
Engine engine = tomcat.getEngine();
org.apache.catalina.Container childContainer = engine.findChild(hostName);
if (childContainer instanceof Host) {
host = (Host) childContainer;
} else {
host = new StandardHost();
host.setName(hostName);
engine.addChild(host);
}
virtualHosts.stream()
.filter(virtualHost -> virtualHost != hostName)
.forEach(virtualHost -> host.addAlias(virtualHost));
return host;
}
代码示例来源:origin: tomcat/catalina
/**
* 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 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) {
if(host instanceof StandardHost)
((StandardHost)host).destroy();
else
engine.removeChild(host);
}
}
代码示例来源:origin: org.apache.openejb/openejb-tomcat-catalina
public List<String> setWsContainer(String virtualHost, String contextRoot, String servletName, HttpListener wsContainer) throws Exception {
if (virtualHost == null) virtualHost = engine.getDefaultHost();
Container host = engine.findChild(virtualHost);
if (host == null) {
throw new IllegalArgumentException("Invalid virtual host '" + virtualHost + "'. Do you have a matchiing Host entry in the server.xml?");
}
Context context = (Context) host.findChild("/" + contextRoot);
if (context == null) {
throw new IllegalArgumentException("Could not find web application context " + contextRoot + " in host " + host.getName());
}
Wrapper wrapper = (Wrapper) context.findChild(servletName);
if (wrapper == null) {
throw new IllegalArgumentException("Could not find servlet " + contextRoot + " in web application context " + context.getName());
}
setWsContainer(context, wrapper, wsContainer);
// add service locations
List<String> addresses = new ArrayList<String>();
for (Connector connector : connectors) {
for (String mapping : wrapper.findMappings()) {
URI address = new URI(connector.getScheme(), null, host.getName(), connector.getPort(), "/" + contextRoot + mapping, null, null);
addresses.add(address.toString());
}
}
return addresses;
}
代码示例来源:origin: org.apache.openejb/openejb-tomcat-catalina
public void clearWsContainer(String virtualHost, String contextRoot, String servletName) {
if (virtualHost == null) virtualHost = engine.getDefaultHost();
Container host = engine.findChild(virtualHost);
if (host == null) {
throw new IllegalArgumentException("Invalid virtual host '" + virtualHost + "'. Do you have a matchiing Host entry in the server.xml?");
}
Context context = (Context) host.findChild("/" + contextRoot);
if (context == null) {
throw new IllegalArgumentException("Could not find web application context " + contextRoot + " in host " + host.getName());
}
Wrapper wrapper = (Wrapper) context.findChild(servletName);
if (wrapper == null) {
throw new IllegalArgumentException("Could not find servlet " + contextRoot + " in web application context " + context.getName());
}
// clear the webservice ref in the servlet context
String webServicecontainerId = wrapper.findInitParameter(WsServlet.WEBSERVICE_CONTAINER);
if (webServicecontainerId != null) {
context.getServletContext().removeAttribute(webServicecontainerId);
wrapper.removeInitParameter(WsServlet.WEBSERVICE_CONTAINER);
}
}
代码示例来源:origin: org.apache.openejb/tomee-webservices
public void clearWsContainer(String virtualHost, String contextRoot, String servletName) {
if (virtualHost == null) virtualHost = engine.getDefaultHost();
Container host = engine.findChild(virtualHost);
if (host == null) {
throw new IllegalArgumentException("Invalid virtual host '" + virtualHost + "'. Do you have a matchiing Host entry in the server.xml?");
}
Context context = (Context) host.findChild("/" + contextRoot);
if (context == null) {
throw new IllegalArgumentException("Could not find web application context " + contextRoot + " in host " + host.getName());
}
Wrapper wrapper = (Wrapper) context.findChild(servletName);
if (wrapper == null) {
throw new IllegalArgumentException("Could not find servlet " + servletName + " in web application context " + context.getName());
}
// clear the webservice ref in the servlet context
String webServicecontainerId = wrapper.findInitParameter(WsServlet.WEBSERVICE_CONTAINER);
if (webServicecontainerId != null) {
context.getServletContext().removeAttribute(webServicecontainerId);
wrapper.removeInitParameter(WsServlet.WEBSERVICE_CONTAINER);
}
}
代码示例来源:origin: modcluster/mod_cluster
@Test
public void findHost() {
org.apache.catalina.Host host = mock(org.apache.catalina.Host.class);
HostFactory hostFactory = mock(HostFactory.class);
Host expected = mock(Host.class);
when(this.engine.findChild("host")).thenReturn(host);
when(this.registry.getHostFactory()).thenReturn(hostFactory);
when(hostFactory.createHost(same(this.registry), same(host), same(this.catalinaEngine))).thenReturn(expected);
Host result = this.catalinaEngine.findHost("host");
assertSame(expected, result);
}
内容来源于网络,如有侵权,请联系作者删除!