本文整理汇总了Java中org.apache.tomcat.util.descriptor.web.ContextResource类的典型用法代码示例。如果您正苦于以下问题:Java ContextResource类的具体用法?Java ContextResource怎么用?Java ContextResource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContextResource类属于org.apache.tomcat.util.descriptor.web包,在下文中一共展示了ContextResource类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addContextResource
import org.apache.tomcat.util.descriptor.web.ContextResource; //导入依赖的package包/类
@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);
}
}
开发者ID:psi-probe,项目名称:psi-probe,代码行数:19,代码来源:Tomcat80ContainerAdapter.java
示例2: setupServer
import org.apache.tomcat.util.descriptor.web.ContextResource; //导入依赖的package包/类
@Before
public void setupServer() throws Exception {
String webappDirLocation = "target/test-webapp";
tomcat = new Tomcat();
File temp = File.createTempFile("test-webapp", ".tmp");
tomcat.setBaseDir(temp.getParent());
tomcat.setPort(SERVER_PORT);
tomcat.enableNaming();
Context context = tomcat.addWebapp(WEBAPP_BASE, new File(webappDirLocation).getAbsolutePath());
ContextResource resource = new ContextResource();
resource.setName("jdbc/twetDataSource");
resource.setAuth("Container");
resource.setType(javax.sql.DataSource.class.getName());
resource.setScope("Sharable");
resource.setProperty("driverClassName", "org.hsqldb.jdbc.JDBCDriver");
resource.setProperty("url", "jdbc:hsqldb:mem:testdb");
context.getNamingResources().addResource(resource);
tomcat.getServer().getGlobalNamingResources().addResource(resource);
tomcat.start();
}
开发者ID:ggeorgovassilis,项目名称:gwt-sl,代码行数:21,代码来源:BaseIntegrationTest.java
示例3: addContextResource
import org.apache.tomcat.util.descriptor.web.ContextResource; //导入依赖的package包/类
public void addContextResource(Context context, List resourceList,
boolean contextBound) {
NamingResourcesImpl namingResources = context.getNamingResources();
ContextResource[] resources = namingResources.findResources();
for (int i = 0; i < resources.length; i++) {
ContextResource contextResource = resources[i];
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());
//lookupResource(resource, contextBound, false);
resourceList.add(resource);
}
}
开发者ID:andresol,项目名称:psi-probe-plus,代码行数:22,代码来源:Tomcat80ContainerAdaptor.java
示例4: importOpenEJBResourcesInTomcat
import org.apache.tomcat.util.descriptor.web.ContextResource; //导入依赖的package包/类
public static void importOpenEJBResourcesInTomcat(final Collection<ResourceInfo> resources, final StandardServer server) {
final NamingResourcesImpl naming = server.getGlobalNamingResources();
for (final ResourceInfo info : resources) {
final String name = info.id;
// if invalid or existing or lazy just skip it cause doesnt work during startup
if (name == null || naming.findResource(name) != null || info.properties.containsKey("UseAppClassLoader")) {
continue;
}
final ContextResource resource = new ContextResource();
resource.setName(name);
resource.setProperty(Constants.FACTORY, ResourceFactory.class.getName());
resource.setProperty(NamingUtil.NAME, name);
resource.setType(info.className);
resource.setAuth("Container");
naming.addResource(resource);
}
}
开发者ID:apache,项目名称:tomee,代码行数:21,代码来源:TomcatJndiBuilder.java
示例5: start
import org.apache.tomcat.util.descriptor.web.ContextResource; //导入依赖的package包/类
public void start(final StandardServer server) {
if (SystemInstance.get().isDefaultProfile()) { // add user tomee is no user are specified
try {
final NamingResourcesImpl resources = server.getGlobalNamingResources();
final ContextResource userDataBaseResource = resources.findResource("UserDatabase");
final UserDatabase db = (UserDatabase) server.getGlobalNamingContext().lookup(userDataBaseResource.getName());
if (!db.getUsers().hasNext() && db instanceof MemoryUserDatabase) {
final MemoryUserDatabase mudb = (MemoryUserDatabase) db;
final boolean oldRo = mudb.getReadonly();
try {
((MemoryUserDatabase) db).setReadonly(false);
db.createRole("tomee-admin", "tomee admin role");
db.createUser("tomee", "tomee", "TomEE");
db.findUser("tomee").addRole(db.findRole("tomee-admin"));
} finally {
mudb.setReadonly(oldRo);
}
}
} catch (final Throwable t) {
// no-op
}
}
}
开发者ID:apache,项目名称:tomee,代码行数:25,代码来源:TomcatWebAppBuilder.java
示例6: setUpTomcat
import org.apache.tomcat.util.descriptor.web.ContextResource; //导入依赖的package包/类
public static void setUpTomcat(String dataSourceFactory) throws LifecycleException, ServletException {
// create a tomcat instance
tomcat = new Tomcat();
tomcat.setBaseDir(".");
tomcat.setPort(0);
tomcat.enableNaming();
// create a context with our test servlet
Context ctx = tomcat.addContext(CONTEXT_PATH, new File(".").getAbsolutePath());
Tomcat.addServlet(ctx, SERVLET_NAME, new TestServlet());
ctx.addServletMappingDecoded("/*", SERVLET_NAME);
// add our metrics filter
FilterDef def = new FilterDef();
def.setFilterClass(TomcatServletMetricsFilter.class.getName());
def.setFilterName("metricsFilter");
def.addInitParameter("buckets",".01, .05, .1, .25, .5, 1, 2.5, 5, 10, 30");
ctx.addFilterDef(def);
FilterMap map = new FilterMap();
map.setFilterName("metricsFilter");
map.addURLPattern("/*");
ctx.addFilterMap(map);
// create a datasource
ContextResource resource = new ContextResource();
resource.setName("jdbc/db");
resource.setAuth("Container");
resource.setType("javax.sql.DataSource");
resource.setScope("Sharable");
resource.setProperty("name", "foo");
resource.setProperty("factory", dataSourceFactory);
resource.setProperty("driverClassName", "org.h2.Driver");
resource.setProperty("url", "jdbc:h2:mem:dummy");
resource.setProperty("jdbcInterceptors", "nl.nlighten.prometheus.tomcat.TomcatJdbcInterceptor(logFailed=true,logSlow=true,threshold=0,buckets=.01|.05|.1|1|10,slowQueryBuckets=1|10|30)");
ctx.getNamingResources().addResource(resource);
// start instance
tomcat.init();
tomcat.start();
}
开发者ID:nlighten,项目名称:tomcat_exporter,代码行数:41,代码来源:AbstractTomcatMetricsTest.java
示例7: addResource
import org.apache.tomcat.util.descriptor.web.ContextResource; //导入依赖的package包/类
@Override
public void addResource(final ContextResource ref) {
normalize(ref);
super.addResource(ref);
if (isTomcatResource) {
pushResourceToAddInOpenEJB(ref);
}
}
开发者ID:apache,项目名称:tomee,代码行数:9,代码来源:OpenEJBNamingResource.java
示例8: processInitialNamingResources
import org.apache.tomcat.util.descriptor.web.ContextResource; //导入依赖的package包/类
private void processInitialNamingResources() {
// Resource links
final ContextResourceLink[] resourceLinks = namingResources.findResourceLinks();
for (final ContextResourceLink resourceLink : resourceLinks) {
addResourceLink(resourceLink);
}
// Resources
final ContextResource[] resources = namingResources.findResources();
for (final ContextResource resource : resources) {
addResource(resource);
}
// Resources Env
final ContextResourceEnvRef[] resourceEnvRefs = namingResources.findResourceEnvRefs();
for (final ContextResourceEnvRef resourceEnvRef : resourceEnvRefs) {
addResourceEnvRef(resourceEnvRef);
}
// Environment entries
final ContextEnvironment[] contextEnvironments = namingResources.findEnvironments();
for (final ContextEnvironment contextEnvironment : contextEnvironments) {
addEnvironment(contextEnvironment);
}
// EJB references
final ContextEjb[] ejbs = namingResources.findEjbs();
for (final ContextEjb ejb : ejbs) {
addEjb(ejb);
}
}
开发者ID:apache,项目名称:tomee,代码行数:32,代码来源:OpenEJBNamingContextListener.java
示例9: newStandardServer
import org.apache.tomcat.util.descriptor.web.ContextResource; //导入依赖的package包/类
@Override
public TomcatHostBuilder newStandardServer(int port, File baseDir, int httpPort, int ajpPort) {
ContextResource memoryDatabase = new ContextResource();
memoryDatabase.setName("name");
memoryDatabase.setDescription("desc");
TomcatServerBuilder serverBuilder = newServer(port);
if (baseDir != null) {
serverBuilder.setCatalinaBase(baseDir);
serverBuilder.setCatalinaHome(baseDir);
}
Map<String, String> connConfig = new HashMap<>();
connConfig.put(Constants.EXECUTOR_NAME_ATTR, DEFAULT_EXECUTOR_NAME);
return serverBuilder.enableNaming()
// .addLifecycleListener(SecurityListener.class)
.addLifecycleListener(AprLifecycleListener.class)
.addLifecycleListener(JreMemoryLeakPreventionListener.class)
.addLifecycleListener(GlobalResourcesLifecycleListener.class)
.addLifecycleListener(ThreadLocalLeakPreventionListener.class)
.addGlobalResource(memoryDatabase)
.addService(DEFAULT_SERVICE_NAME)
// TODO .withDefaultRealm()
.setBackgroundProcessorDelay(0)
.setStartStopThreads(0)
.addExecutor(DEFAULT_EXECUTOR_NAME, "tomcat-exec-", DEFAULT_EXECUTOR_MIN, DEFAULT_EXECUTOR_MAX, EMPTY_MAP)
.addConnector(Tomcat.PROTOCOL_BIO, httpPort, connConfig)
.addConnector(Tomcat.PROTOCOL_AJP, ajpPort, connConfig)
.addHost(LOCALHOST, "webapps");
}
开发者ID:pidster-dot-org,项目名称:embed-apache-tomcat,代码行数:32,代码来源:CatalinaBuilderImpl.java
示例10: addGlobalResource
import org.apache.tomcat.util.descriptor.web.ContextResource; //导入依赖的package包/类
@Override
public TomcatServerBuilder addGlobalResource(ContextResource resource) {
if (!enableNaming) {
enableJndi();
}
if (server.getGlobalNamingResources() == null) {
NamingResourcesImpl globalNamingResources = new NamingResourcesImpl();
server.setGlobalNamingResources(globalNamingResources);
globalNamingResources.setContainer(server);
}
server.getGlobalNamingResources().addResource(resource);
return this;
}
开发者ID:pidster-dot-org,项目名称:embed-apache-tomcat,代码行数:16,代码来源:TomcatServerBuilderImpl.java
示例11: tomcatFactory
import org.apache.tomcat.util.descriptor.web.ContextResource; //导入依赖的package包/类
@Bean
public TomcatEmbeddedServletContainerFactory tomcatFactory() {
return new TomcatEmbeddedServletContainerFactory() {
@Override
protected TomcatEmbeddedServletContainer getTomcatEmbeddedServletContainer(
Tomcat tomcat) {
tomcat.enableNaming();
return super.getTomcatEmbeddedServletContainer(tomcat);
}
@Override
/**
* Configure Tomcat connection pooling. In the future other configuration parameters
* could be added from https://tomcat.apache.org/tomcat-8.0-doc/jdbc-pool.html
*/
protected void postProcessContext(Context context) {
ContextResource r = new ContextResource();
r.setName(env.getProperty("sta.datasource.name", "jdbc/sensorThings"));
r.setAuth(env.getProperty("sta.datasource.auth", "Container"));
r.setType(env.getProperty("sta.datasource.type", "javax.sql.DataSource"));
r.setProperty("factory",
env.getProperty("sta.datasource.factory","org.apache.tomcat.jdbc.pool.DataSourceFactory"));
r.setProperty("driverClassName",
env.getProperty("sta.datasource.driverClassName", "org.postgresql.Driver"));
r.setProperty("url",
env.getProperty("sta.datasource.url", "jdbc:postgresql://localhost:5432/sensorthings"));
r.setProperty("username",
env.getProperty("sta.datasource.username", "sensorthings"));
r.setProperty("password",
env.getProperty("sta.datasource.password", "ChangeMe!"));
r.setProperty("maxTotal",
env.getProperty("sta.datasource.maxTotal", "20"));
r.setProperty("maxIdle",
env.getProperty("sta.datasource.maxIdle", "10"));
r.setProperty("maxWaitMillis",
env.getProperty("sta.datasource.maxWaitMillis", "-1"));
r.setProperty("defaultAutoCommit",
env.getProperty("sta.datasource.defaultAutoCommit", "false"));
r.setProperty("testOnBorrow",
env.getProperty("sta.datasource.testOnBorrow", "true"));
r.setProperty("validationQuery",
env.getProperty("sta.datasource.validationQuery", "SELECT 1;"));
r.setProperty("validationInterval",
env.getProperty("sta.datasource.validationInterval", "5000"));
context.getNamingResources().addResource(r);
}
};
}
开发者ID:kinota,项目名称:kinota-server,代码行数:51,代码来源:Application.java
示例12: isOpenEjb
import org.apache.tomcat.util.descriptor.web.ContextResource; //导入依赖的package包/类
private boolean isOpenEjb(final NamingResourcesImpl naming, final String name) {
final ContextResource resource = naming.findResource(name);
return resource != null && ResourceFactory.class.getName().equals(resource.getProperty("factory"));
}
开发者ID:apache,项目名称:tomee,代码行数:5,代码来源:TomcatJndiBuilder.java
示例13: setResource
import org.apache.tomcat.util.descriptor.web.ContextResource; //导入依赖的package包/类
private void setResource(final ContextResource resource, final String name, final Object object) {
NamingUtil.setStaticValue(new Resource(resource), name, object);
}
开发者ID:apache,项目名称:tomee,代码行数:4,代码来源:TomcatJndiBuilder.java
示例14: Resource
import org.apache.tomcat.util.descriptor.web.ContextResource; //导入依赖的package包/类
public Resource(final ContextResource contextResource) {
this.contextResource = contextResource;
}
开发者ID:apache,项目名称:tomee,代码行数:4,代码来源:TomcatJndiBuilder.java
示例15: pushResourceToAddInOpenEJB
import org.apache.tomcat.util.descriptor.web.ContextResource; //导入依赖的package包/类
private void pushResourceToAddInOpenEJB(final ContextResource ref) {
tomcatResources.add(ref);
}
开发者ID:apache,项目名称:tomee,代码行数:4,代码来源:OpenEJBNamingResource.java
示例16: addResource
import org.apache.tomcat.util.descriptor.web.ContextResource; //导入依赖的package包/类
public void addResource(final ContextResource resource) {
bindResource(resource);
}
开发者ID:apache,项目名称:tomee,代码行数:4,代码来源:OpenEJBNamingContextListener.java
示例17: addGlobalResource
import org.apache.tomcat.util.descriptor.web.ContextResource; //导入依赖的package包/类
/**
* @param resource
* @return this builder
*/
TomcatServerBuilder addGlobalResource(ContextResource resource);
开发者ID:pidster-dot-org,项目名称:embed-apache-tomcat,代码行数:6,代码来源:TomcatServerBuilder.java
注:本文中的org.apache.tomcat.util.descriptor.web.ContextResource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论