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

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

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

Context.getNamingResources介绍

[英]Return the naming resources associated with this web application.
[中]返回与此web应用程序关联的命名资源。

代码示例

代码示例来源:origin: psi-probe/psi-probe

@Override
public void addContextResourceLink(Context context, List<ApplicationResource> resourceList,
  boolean contextBound) {
 NamingResources namingResources = context.getNamingResources();
 for (ContextResourceLink link : namingResources.findResourceLinks()) {
  ApplicationResource resource = new ApplicationResource();
  logger.debug("reading resourceLink: {}", link.getName());
  resource.setApplicationName(context.getName());
  resource.setName(link.getName());
  resource.setType(link.getType());
  resource.setLinkTo(link.getGlobal());
  resourceList.add(resource);
 }
}

代码示例来源:origin: psi-probe/psi-probe

@Override
public void addContextResourceLink(Context context, List<ApplicationResource> resourceList,
  boolean contextBound) {
 NamingResourcesImpl namingResources = context.getNamingResources();
 for (ContextResourceLink link : namingResources.findResourceLinks()) {
  ApplicationResource resource = new ApplicationResource();
  logger.debug("reading resourceLink: {}", link.getName());
  resource.setApplicationName(context.getName());
  resource.setName(link.getName());
  resource.setType(link.getType());
  resource.setLinkTo(link.getGlobal());
  registerGlobalResourceAccess(link);
  resourceList.add(resource);
 }
}

代码示例来源:origin: psi-probe/psi-probe

@Override
public void addContextResourceLink(Context context, List<ApplicationResource> resourceList,
  boolean contextBound) {
 NamingResourcesImpl namingResources = context.getNamingResources();
 for (ContextResourceLink link : namingResources.findResourceLinks()) {
  ApplicationResource resource = new ApplicationResource();
  logger.debug("reading resourceLink: {}", link.getName());
  resource.setApplicationName(context.getName());
  resource.setName(link.getName());
  resource.setType(link.getType());
  resource.setLinkTo(link.getGlobal());
  registerGlobalResourceAccess(link);
  resourceList.add(resource);
 }
}

代码示例来源:origin: psi-probe/psi-probe

@Override
public void addContextResourceLink(Context context, List<ApplicationResource> resourceList,
  boolean contextBound) {
 NamingResourcesImpl namingResources = context.getNamingResources();
 for (ContextResourceLink link : namingResources.findResourceLinks()) {
  ApplicationResource resource = new ApplicationResource();
  logger.debug("reading resourceLink: {}", link.getName());
  resource.setApplicationName(context.getName());
  resource.setName(link.getName());
  resource.setType(link.getType());
  resource.setLinkTo(link.getGlobal());
  registerGlobalResourceAccess(link);
  resourceList.add(resource);
 }
}

代码示例来源:origin: psi-probe/psi-probe

@Override
public void addContextResource(Context context, List<ApplicationResource> resourceList,
  boolean contextBound) {
 NamingResourcesImpl namingResources = context.getNamingResources();
 for (ContextResource contextResource : namingResources.findResources()) {
  ApplicationResource resource = new ApplicationResource();
  logger.info("reading resource: {}", contextResource.getName());
  resource.setApplicationName(context.getName());
  resource.setName(contextResource.getName());
  resource.setType(contextResource.getType());
  resource.setScope(contextResource.getScope());
  resource.setAuth(contextResource.getAuth());
  resource.setDescription(contextResource.getDescription());
  resourceList.add(resource);
 }
}

代码示例来源:origin: psi-probe/psi-probe

@Override
public void addContextResource(Context context, List<ApplicationResource> resourceList,
  boolean contextBound) {
 NamingResourcesImpl namingResources = context.getNamingResources();
 for (ContextResource contextResource : namingResources.findResources()) {
  ApplicationResource resource = new ApplicationResource();
  logger.info("reading resource: {}", contextResource.getName());
  resource.setApplicationName(context.getName());
  resource.setName(contextResource.getName());
  resource.setType(contextResource.getType());
  resource.setScope(contextResource.getScope());
  resource.setAuth(contextResource.getAuth());
  resource.setDescription(contextResource.getDescription());
  resourceList.add(resource);
 }
}

代码示例来源:origin: psi-probe/psi-probe

@Override
public void addContextResource(Context context, List<ApplicationResource> resourceList,
  boolean contextBound) {
 NamingResourcesImpl namingResources = context.getNamingResources();
 for (ContextResource contextResource : namingResources.findResources()) {
  ApplicationResource resource = new ApplicationResource();
  logger.info("reading resource: {}", contextResource.getName());
  resource.setApplicationName(context.getName());
  resource.setName(contextResource.getName());
  resource.setType(contextResource.getType());
  resource.setScope(contextResource.getScope());
  resource.setAuth(contextResource.getAuth());
  resource.setDescription(contextResource.getDescription());
  resourceList.add(resource);
 }
}

代码示例来源:origin: psi-probe/psi-probe

@Override
public void addContextResource(Context context, List<ApplicationResource> resourceList,
  boolean contextBound) {
 NamingResources namingResources = context.getNamingResources();
 for (ContextResource contextResource : namingResources.findResources()) {
  ApplicationResource resource = new ApplicationResource();
  logger.info("reading resource: {}", contextResource.getName());
  resource.setApplicationName(context.getName());
  resource.setName(contextResource.getName());
  resource.setType(contextResource.getType());
  resource.setScope(contextResource.getScope());
  resource.setAuth(contextResource.getAuth());
  resource.setDescription(contextResource.getDescription());
  resourceList.add(resource);
 }
}

代码示例来源:origin: tomcat/catalina

/**
 * Return the naming resources associated with this web application.
 */
private NamingResources getNamingResources() {
  
  return ((Context)this.resource).getNamingResources();

}

代码示例来源:origin: stackoverflow.com

Context rootCtx = tomcat.addContext("", base.getAbsolutePath());
//...
rootCtx.getNamingResources().addResource(resource);

代码示例来源:origin: mercyblitz/thinking-in-spring-boot-samples

@Bean
public WebServerFactoryCustomizer<TomcatServletWebServerFactory> webServerFactoryCustomizer() {
  return factory ->
      factory.addContextCustomizers(
          context -> {
            // 设置 JNDI 信息
            ContextEnvironment environment = new ContextEnvironment();
            environment.setName("jndi-name");
            environment.setValue("My JNDI");
            environment.setType(String.class.getName());
            // 配置 Environment,等同于 <Environment/> 元素
            context.getNamingResources().addEnvironment(environment);
          }
      );
}

代码示例来源:origin: wilkinsona/spring-boot-sample-tomcat-jndi

@Override
  protected void postProcessContext(Context context) {
    ContextResource resource = new ContextResource();
    resource.setName("jdbc/myDataSource");
    resource.setType(DataSource.class.getName());
    resource.setProperty("driverClassName", "your.db.Driver");
    resource.setProperty("url", "jdbc:yourDb");
    context.getNamingResources().addResource(resource);
  }
};

代码示例来源:origin: tomcat/catalina

/**
 * Process the end of this element.
 */
public void end() throws Exception {
  // Identify the objects to be used
  Object child = digester.peek(0);
  Object parent = digester.peek(1);
  NamingResources namingResources = null;
  if (parent instanceof Context) {
    namingResources = ((Context) parent).getNamingResources();
  } else {
    namingResources = (NamingResources) parent;
  }
  
  // Call the specified method
  IntrospectionUtils.callMethod1(namingResources, methodName,
      child, paramType, digester.getClassLoader());
}

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

/**
 * Process the end of this element.
 *
 * @param namespace the namespace URI of the matching element, or an
 *   empty string if the parser is not namespace aware or the element has
 *   no namespace
 * @param name the local name if the parser is namespace aware, or just
 *   the element name otherwise
 */
@Override
public void end(String namespace, String name) throws Exception {
  // Identify the objects to be used
  Object child = digester.peek(0);
  Object parent = digester.peek(1);
  NamingResourcesImpl namingResources = null;
  if (parent instanceof Context) {
    namingResources = ((Context) parent).getNamingResources();
  } else {
    namingResources = (NamingResourcesImpl) parent;
  }
  // Call the specified method
  IntrospectionUtils.callMethod1(namingResources, methodName,
      child, paramType, digester.getClassLoader());
}

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

/**
 * Process the end of this element.
 * 
 * @param namespace the namespace URI of the matching element, or an 
 *   empty string if the parser is not namespace aware or the element has
 *   no namespace
 * @param name the local name if the parser is namespace aware, or just 
 *   the element name otherwise
 */
@Override
public void end(String namespace, String name) throws Exception {
  // Identify the objects to be used
  Object child = digester.peek(0);
  Object parent = digester.peek(1);
  NamingResources namingResources = null;
  if (parent instanceof Context) {
    namingResources = ((Context) parent).getNamingResources();
  } else {
    namingResources = (NamingResources) parent;
  }
  
  // Call the specified method
  IntrospectionUtils.callMethod1(namingResources, methodName,
      child, paramType, digester.getClassLoader());
}

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

/**
 * Process the end of this element.
 *
 * @param namespace the namespace URI of the matching element, or an
 *   empty string if the parser is not namespace aware or the element has
 *   no namespace
 * @param name the local name if the parser is namespace aware, or just
 *   the element name otherwise
 */
@Override
public void end(String namespace, String name) throws Exception {
  // Identify the objects to be used
  Object child = digester.peek(0);
  Object parent = digester.peek(1);
  NamingResourcesImpl namingResources = null;
  if (parent instanceof Context) {
    namingResources = ((Context) parent).getNamingResources();
  } else {
    namingResources = (NamingResourcesImpl) parent;
  }
  // Call the specified method
  IntrospectionUtils.callMethod1(namingResources, methodName,
      child, paramType, digester.getClassLoader());
}

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

/**
 * Process the end of this element.
 *
 * @param namespace the namespace URI of the matching element, or an
 *   empty string if the parser is not namespace aware or the element has
 *   no namespace
 * @param name the local name if the parser is namespace aware, or just
 *   the element name otherwise
 */
@Override
public void end(String namespace, String name) throws Exception {
  // Identify the objects to be used
  Object child = digester.peek(0);
  Object parent = digester.peek(1);
  NamingResourcesImpl namingResources = null;
  if (parent instanceof Context) {
    namingResources = ((Context) parent).getNamingResources();
  } else {
    namingResources = (NamingResourcesImpl) parent;
  }
  // Call the specified method
  IntrospectionUtils.callMethod1(namingResources, methodName,
      child, paramType, digester.getClassLoader());
}

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

/**
 * Process the end of this element.
 * 
 * @param namespace the namespace URI of the matching element, or an 
 *   empty string if the parser is not namespace aware or the element has
 *   no namespace
 * @param name the local name if the parser is namespace aware, or just 
 *   the element name otherwise
 */
@Override
public void end(String namespace, String name) throws Exception {
  // Identify the objects to be used
  Object child = digester.peek(0);
  Object parent = digester.peek(1);
  NamingResources namingResources = null;
  if (parent instanceof Context) {
    namingResources = ((Context) parent).getNamingResources();
  } else {
    namingResources = (NamingResources) parent;
  }
  
  // Call the specified method
  IntrospectionUtils.callMethod1(namingResources, methodName,
      child, paramType, digester.getClassLoader());
}

代码示例来源:origin: ops4j/org.ops4j.pax.exam2

private void registerBeanManager(Context appContext, String jndiObjectFactory,
  String servletListener) {
  ContextResource resource = new ContextResource();
  resource.setAuth("Container");
  resource.setName(BEAN_MANAGER_NAME);
  resource.setType(BEAN_MANAGER_TYPE);
  resource.setProperty("factory", jndiObjectFactory);
  appContext.getNamingResources().addResource(resource);
  ContextResourceEnvRef resourceRef = new ContextResourceEnvRef();
  resourceRef.setName(BEAN_MANAGER_NAME);
  resourceRef.setType(BEAN_MANAGER_TYPE);
  appContext.getNamingResources().addResourceEnvRef(resourceRef);
  appContext.addApplicationListener(servletListener);
}

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

@Override
protected void contextConfig(final Digester digester) {
  final NamingResourcesImpl resources;
  if (context != null) {
    resources = context.getNamingResources();
  } else {
    resources = null;
  }
  if (resources instanceof OpenEJBNamingResource) {
    ((OpenEJBNamingResource) resources).setTomcatResource(true);
  }
  super.contextConfig(digester);
  if (resources instanceof OpenEJBNamingResource) {
    ((OpenEJBNamingResource) resources).setTomcatResource(false);
  }
  if (context instanceof StandardContext) {
    final StandardContext standardContext = (StandardContext) context;
    final NamingContextListener namingContextListener = standardContext.getNamingContextListener();
    if (null != namingContextListener) {
      namingContextListener.setExceptionOnFailedWrite(standardContext.getJndiExceptionOnFailedWrite());
    }
  }
}

相关文章

微信公众号

最新文章

更多

Context类方法