org.apache.catalina.Container.findChild()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(14.0k)|赞(0)|评价(0)|浏览(121)

本文整理了Java中org.apache.catalina.Container.findChild()方法的一些代码示例,展示了Container.findChild()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Container.findChild()方法的具体详情如下:
包路径:org.apache.catalina.Container
类名称:Container
方法名:findChild

Container.findChild介绍

[英]Return the child Container, associated with this Container, with the specified name (if any); otherwise, return null
[中]返回与此容器关联的具有指定名称(如果有)的子容器;否则,返回null

代码示例

代码示例来源:origin: org.apache.openejb/tomee-jaxrs

private static Context findContext(final Container host, final String webContext) {
  Context webapp = Context.class.cast(host.findChild(webContext));
  if (webapp == null && "/".equals(webContext)) { // ROOT
    webapp = Context.class.cast(host.findChild(""));
  } else if (webapp == null && webContext.length() > 0 && !webContext.startsWith("/")) {
    webapp = Context.class.cast(host.findChild("/" + webContext));
  }
  return webapp;
}

代码示例来源:origin: org.codehaus.fabric3.tomcat/fabric3-tomcat-extension

public void deactivate(URI uri) throws WebApplicationActivationException {
  String contextPath = mappings.remove(uri);
  if (contextPath == null) {
    throw new WebApplicationActivationException("Context not registered for component: " + uri);
  }
  StandardContext context = null;
  try {
    for (Container container : connector.getContainer().findChildren()) {
      if (container instanceof StandardHost) {
        context = (StandardContext) container.findChild(contextPath);
        container.removeChild(context);
        try {
          context.destroy();
        } catch (Exception e) {
          throw new WebApplicationActivationException(e);
        }
        break;
      }
    }
    if (context == null) {
      throw new WebApplicationActivationException("Context not found for: " + contextPath);
    }
    context.stop();
    monitor.deactivated(contextPath);
  } catch (LifecycleException e) {
    throw new WebApplicationActivationException(e);
  }
}

代码示例来源:origin: org.apache.tomee/tomee-jaxrs

private static Context findContext(final Container host, final String appId, final String webContext) {
  if (appId != null) { // when using versioning appId is like context#1235 but not the context itself so ensure to test appId first
    final Context ctx = Context.class.cast(host.findChild('/' + appId));
    if (ctx != null) {
      return ctx;
    }
  }
  Context webapp = Context.class.cast(host.findChild(webContext));
  if (webapp == null && "/".equals(webContext)) { // ROOT
    webapp = Context.class.cast(host.findChild(""));
  } else if (webapp == null && webContext.length() > 0 && !webContext.startsWith("/")) {
    webapp = Context.class.cast(host.findChild("/" + webContext));
  }
  return webapp;
}

代码示例来源:origin: org.codehaus.fabric3.tomcat/fabric3-tomcat-extension

@Init
public void init() throws ServletHostException {
  connector = connectorService.getConnector();
  dispatchingServlet = new Fabric3DispatchingServlet();
  Fabric3ServletWrapper wrapper = new Fabric3ServletWrapper(dispatchingServlet);
  wrapper.setName("Fabric3Servlet");
  for (Container container : connector.getContainer().findChildren()) {
    if (container instanceof StandardHost) {
      Container child = container.findChild("");
      if (child != null) {
        container.removeChild(child);
      }
      StandardContext context = createContext("", ".");
      context.addChild(wrapper);
      context.addServletMapping("/*", "Fabric3Servlet");
      container.addChild(context);
      try {
        dispatchingServlet.init(wrapper);
      } catch (ServletException e) {
        throw new AssertionError(e);
      }
    }
  }
}

代码示例来源:origin: codefollower/Tomcat-Research

/**
 * Get Parent ContainerBase to add its child component
 * from child component's ObjectName  as a String
 */
private Container getParentContainerFromChild(ObjectName oname)
  throws Exception {
  String hostName = oname.getKeyProperty("host");
  String path = oname.getKeyProperty("path");
  Service service = getService(oname);
  Container engine = service.getContainer();
  if (hostName == null) {
    // child's container is Engine
    return engine;
  } else if (path == null) {
    // child's container is Host
    Container host = engine.findChild(hostName);
    return host;
  } else {
    // child's container is Context
    Container host = engine.findChild(hostName);
    path = getPathStr(path);
    Container context = host.findChild(path);
    return context;
  }
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

/**
 * Get Parent ContainerBase to add its child component
 * from child component's ObjectName  as a String
 */
private Container getParentContainerFromChild(ObjectName oname)
  throws Exception {
  String hostName = oname.getKeyProperty("host");
  String path = oname.getKeyProperty("path");
  Service service = getService(oname);
  Container engine = service.getContainer();
  if (hostName == null) {
    // child's container is Engine
    return engine;
  } else if (path == null) {
    // child's container is Host
    Container host = engine.findChild(hostName);
    return host;
  } else {
    // child's container is Context
    Container host = engine.findChild(hostName);
    path = getPathStr(path);
    Container context = host.findChild(path);
    return context;
  }
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

/**
 * Get Parent ContainerBase to add its child component
 * from child component's ObjectName  as a String
 */
private Container getParentContainerFromChild(ObjectName oname)
  throws Exception {
  String hostName = oname.getKeyProperty("host");
  String path = oname.getKeyProperty("path");
  Service service = getService(oname);
  Container engine = service.getContainer();
  if (hostName == null) {
    // child's container is Engine
    return engine;
  } else if (path == null) {
    // child's container is Host
    Container host = engine.findChild(hostName);
    return host;
  } else {
    // child's container is Context
    Container host = engine.findChild(hostName);
    path = getPathStr(path);
    Container context = host.findChild(path);
    return context;
  }
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

/**
 * Remove an existing child Container from association with this parent
 * Container.
 *
 * @param name Name of the existing child Container to be removed
 * @throws MBeanException if the child cannot be removed
 */
public void removeChild(String name) throws MBeanException{
  if (name != null) {
    Container container = doGetManagedResource();
    Container contained = container.findChild(name);
    container.removeChild(contained);
  }
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

/**
 * Remove an existing child Container from association with this parent
 * Container.
 *
 * @param name Name of the existing child Container to be removed
 * @throws MBeanException if the child cannot be removed
 */
public void removeChild(String name) throws MBeanException{
  if (name != null) {
    Container container = doGetManagedResource();
    Container contained = container.findChild(name);
    container.removeChild(contained);
  }
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

Container host = engine.findChild(hostName);
  String pathStr = getPathStr(path);
  Container context = host.findChild(pathStr);
  return context;
} else if (type != null) {

代码示例来源:origin: org.apache.tomee/tomee-catalina

private static boolean undeploy(final StandardContext standardContext, final Container host) {
  final Container child = host.findChild(standardContext.getName());
  // skip undeployment if redeploying (StandardContext.redeploy())
  if (child instanceof org.apache.catalina.Context && org.apache.catalina.Context.class.cast(child).getPaused()) {
    return true;
  }
  // skip undeployment if restarting
  final TomEEWebappClassLoader tomEEWebappClassLoader = lazyClassLoader(
    org.apache.catalina.Context.class.isInstance(child) ? org.apache.catalina.Context.class.cast(child) : null);
  if (tomEEWebappClassLoader != null && tomEEWebappClassLoader.isRestarting()) {
    return true;
  }
  if (child != null) {
    host.removeChild(standardContext);
    return true;
  }
  return false;
}

代码示例来源: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: codefollower/Tomcat-Research

/**
 * Remove an existing child Container from association with this parent
 * Container.
 *
 * @param name Name of the existing child Container to be removed
 */
public void removeChild(String name) throws MBeanException{
  if(name != null){
    try {
      Container container = (Container)getManagedResource();
      Container contained = container.findChild(name);
      container.removeChild(contained);
    } catch (InstanceNotFoundException e) {
      throw new MBeanException(e);
    } catch (RuntimeOperationsException e) {
      throw new MBeanException(e);
    } catch (InvalidTargetObjectTypeException e) {
      throw new MBeanException(e);
    }
  }
}

代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9

/**
 * Remove an existing child Container from association with this parent
 * Container.
 *
 * @param name Name of the existing child Container to be removed
 */
public void removeChild(String name) throws MBeanException{
  if(name != null){
    try {
      Container container = (Container)getManagedResource();
      Container contained = container.findChild(name);
      container.removeChild(contained);
    } catch (InstanceNotFoundException e) {
      throw new MBeanException(e);
    } catch (RuntimeOperationsException e) {
      throw new MBeanException(e);
    } catch (InvalidTargetObjectTypeException e) {
      throw new MBeanException(e);
    }
  }
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-tomcat7

/**
 * Remove an existing child Container from association with this parent
 * Container.
 *
 * @param name Name of the existing child Container to be removed
 */
public void removeChild(String name) throws MBeanException{
  if(name != null){
    try {
      Container container = (Container)getManagedResource();
      Container contained = container.findChild(name);
      container.removeChild(contained);
    } catch (InstanceNotFoundException e) {
      throw new MBeanException(e);
    } catch (RuntimeOperationsException e) {
      throw new MBeanException(e);
    } catch (InvalidTargetObjectTypeException e) {
      throw new MBeanException(e);
    }
  }
}

代码示例来源:origin: org.apache.geronimo.ext.tomcat/catalina

/**
 * Remove an existing child Container from association with this parent
 * Container.
 *
 * @param name Name of the existing child Container to be removed
 */
public void removeChild(String name) throws MBeanException{
  if(name != null){
    try {
      Container container = (Container)getManagedResource();
      Container contained = container.findChild(name);
      container.removeChild(contained);
    } catch (InstanceNotFoundException e) {
      throw new MBeanException(e);
    } catch (RuntimeOperationsException e) {
      throw new MBeanException(e);
    } catch (InvalidTargetObjectTypeException e) {
      throw new MBeanException(e);
    }
  }
}

代码示例来源:origin: org.apache.catalina/com.springsource.org.apache.catalina

/**
 * Remove an existing child Container from association with this parent
 * Container.
 *
 * @param name Name of the existing child Container to be removed
 */
public void removeChild(String name) throws MBeanException{
  if(name != null){
    try {
      Container container = (Container)getManagedResource();
      Container contained = container.findChild(name);
      container.removeChild(contained);
    } catch (InstanceNotFoundException e) {
      throw new MBeanException(e);
    } catch (RuntimeOperationsException e) {
      throw new MBeanException(e);
    } catch (InvalidTargetObjectTypeException e) {
      throw new MBeanException(e);
    }
  }
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9

/**
 * Remove an existing child Container from association with this parent
 * Container.
 *
 * @param name Name of the existing child Container to be removed
 */
public void removeChild(String name) throws MBeanException{
  if(name != null){
    try {
      Container container = (Container)getManagedResource();
      Container contained = container.findChild(name);
      container.removeChild(contained);
    } catch (InstanceNotFoundException e) {
      throw new MBeanException(e);
    } catch (RuntimeOperationsException e) {
      throw new MBeanException(e);
    } catch (InvalidTargetObjectTypeException e) {
      throw new MBeanException(e);
    }
  }
}

相关文章

微信公众号

最新文章

更多