当前位置: 首页>>代码示例>>Java>>正文


Java Context.addServletMappingDecoded方法代码示例

本文整理汇总了Java中org.apache.catalina.Context.addServletMappingDecoded方法的典型用法代码示例。如果您正苦于以下问题:Java Context.addServletMappingDecoded方法的具体用法?Java Context.addServletMappingDecoded怎么用?Java Context.addServletMappingDecoded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.catalina.Context的用法示例。


在下文中一共展示了Context.addServletMappingDecoded方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: embededTomcatServer

import org.apache.catalina.Context; //导入方法依赖的package包/类
@Bean
public Tomcat embededTomcatServer(ApplicationContext context) throws Exception {
    HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context).build(); 

    // Tomcat and Jetty (also see notes below)
    Servlet servlet = new TomcatHttpHandlerAdapter(handler);

    Tomcat tomcatServer = new Tomcat();
    tomcatServer.setHostname("localhost");
    tomcatServer.setPort(this.port);
    Context rootContext = tomcatServer.addContext("", System.getProperty("java.io.tmpdir"));
    Tomcat.addServlet(rootContext, "httpHandlerServlet", servlet);
    rootContext.addServletMappingDecoded("/", "httpHandlerServlet");

    return tomcatServer;
}
 
开发者ID:hantsy,项目名称:spring-reactive-sample,代码行数:17,代码来源:Application.java

示例2: beforeTest

import org.apache.catalina.Context; //导入方法依赖的package包/类
@Before
public void beforeTest() throws Exception {
    tomcatServer = new Tomcat();
    tomcatServer.setPort(serverPort);
    
    File baseDir = new File("tomcat");
    tomcatServer.setBaseDir(baseDir.getAbsolutePath());

    File applicationDir = new File(baseDir + "/webapps", "/ROOT");
    if (!applicationDir.exists()) {
        applicationDir.mkdirs();
    }

    Context appContext = tomcatServer.addWebapp("", applicationDir.getAbsolutePath());
    Tomcat.addServlet(appContext, "helloWorldServlet", new TestServlet());
    appContext.addServletMappingDecoded("/hello", "helloWorldServlet");

    tomcatServer.start();
    System.out.println("Tomcat server: http://" + tomcatServer.getHost().getName() + ":" + serverPort + "/");
}
 
开发者ID:opentracing-contrib,项目名称:java-agent,代码行数:21,代码来源:TomcatServletITest.java

示例3: addAceqlServlet

import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
 * Add a Servlet using properties with the index
 * 
 * @param properties
 *            the properties than contain all servlet & configurators info
 * @param rootCtx
 *            the tomcat root context
 */
public void addAceqlServlet(Properties properties, Context rootCtx) {

	if (properties == null) {
		throw new IllegalArgumentException("properties can not be null");
	}

	String aceQLManagerServletCallName = TomcatStarterUtil.getAceQLManagerSevletName(properties);

	// Add the ServerSqlManager servlet to the context
	@SuppressWarnings("unused")
	Wrapper wrapper = Tomcat.addServlet(rootCtx, aceQLManagerServletCallName, new ServerSqlManager());

	rootCtx.addServletMappingDecoded("/*", aceQLManagerServletCallName);

	TomcatStarterUtil.setInitParametersInStore(properties);

	// Unecessary because we must start at / because of ou Rest API
	// String serverSqlManagerUrlPattern = serverSqlManagerServletName;
	// if (!serverSqlManagerUrlPattern.startsWith("/")) {
	// serverSqlManagerUrlPattern = "/" + serverSqlManagerUrlPattern;
	// }

}
 
开发者ID:kawansoft,项目名称:aceql-http,代码行数:32,代码来源:TomcatStarter.java

示例4: setup

import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
 * Setup the test by deploying an embedded tomcat and adding the rest endpoints.
 * @throws Throwable Throws uncaught throwables for test to fail.
 */
@Before
public void setup() throws Throwable {
	registryTomcat = new Tomcat();
	registryTomcat.setPort(3000);
	registryTomcat.setBaseDir(testWorkingDir);
	Context context = registryTomcat.addWebapp(CONTEXT, testWorkingDir);
	context.addApplicationListener(RegistryStartup.class.getName());
	ResourceConfig restServletConfig = new ResourceConfig();
	restServletConfig.register(RegistryREST.class);
	restServletConfig.register(Registry.class);
	ServletContainer restServlet = new ServletContainer(restServletConfig);
	registryTomcat.addServlet(CONTEXT, "restServlet", restServlet);
	context.addServletMappingDecoded("/rest/*", "restServlet");
	registryTomcat.start();
}
 
开发者ID:DescartesResearch,项目名称:Pet-Supply-Store,代码行数:20,代码来源:HeartbeatTest.java

示例5: setup

import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
 * Setup the test by deploying an embedded tomcat and adding the rest endpoints.
 * @throws Throwable Throws uncaught throwables for test to fail.
 */
@Before
public void setup() throws Throwable {
	testTomcat = new Tomcat();
	testTomcat.setPort(0);
	testTomcat.setBaseDir(testWorkingDir);
	Context context = testTomcat.addWebapp(CONTEXT, testWorkingDir);
	ResourceConfig restServletConfig = new ResourceConfig();
	restServletConfig.register(RegistryREST.class);
	restServletConfig.register(Registry.class);
	ServletContainer restServlet = new ServletContainer(restServletConfig);
	testTomcat.addServlet(CONTEXT, "restServlet", restServlet);
	context.addServletMappingDecoded("/rest/*", "restServlet");
	testTomcat.start();
}
 
开发者ID:DescartesResearch,项目名称:Pet-Supply-Store,代码行数:19,代码来源:RegistryTest.java

示例6: setup

import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
 * Setup the test by deploying an embedded tomcat and adding the rest endpoints.
 * @throws Throwable Throws uncaught throwables for test to fail.
 */
@Before
public void setup() throws Throwable {
	testTomcat = new Tomcat();
	testTomcat.setPort(0);
	testTomcat.setBaseDir(testWorkingDir);
	Context context = testTomcat.addWebapp(CONTEXT, testWorkingDir);
	ResourceConfig restServletConfig = new ResourceConfig();
	restServletConfig.register(TestEntityEndpoint.class);
	ServletContainer restServlet = new ServletContainer(restServletConfig);
	testTomcat.addServlet(CONTEXT, "restServlet", restServlet);
	context.addServletMappingDecoded("/rest/*", "restServlet");
	testTomcat.start();
}
 
开发者ID:DescartesResearch,项目名称:Pet-Supply-Store,代码行数:18,代码来源:CRUDClientServerTest.java

示例7: setupAndAddTestTomcat

import org.apache.catalina.Context; //导入方法依赖的package包/类
private void setupAndAddTestTomcat(int i) {
	Tomcat testTomcat = new Tomcat();
	testTomcat.setPort(0);
	testTomcat.setBaseDir(testWorkingDir);
	Context context;
	try {
		context = testTomcat.addWebapp(CONTEXT, testWorkingDir);
		testTomcat.getEngine().setName("Catalina" + i);
		TestServlet testServlet = new TestServlet();
		testServlet.setId(i);
		testTomcat.addServlet(CONTEXT, "notFoundServlet", new NotFoundServlet());
		testTomcat.addServlet(CONTEXT, "timeoutStatusServlet", new TimeoutStatusServlet());
		testTomcat.addServlet(CONTEXT, "timeoutingServlet", new SlowTimeoutingServlet());
		testTomcat.addServlet(CONTEXT, "restServlet", testServlet);
		context.addServletMappingDecoded("/rest/" + ENDPOINT, "restServlet");
		context.addServletMappingDecoded("/rest/" + ENDPOINT + "/*", "restServlet");
		context.addServletMappingDecoded("/rest/" + NOT_FOUND_ENDPOINT, "notFoundServlet");
		context.addServletMappingDecoded("/rest/" + NOT_FOUND_ENDPOINT + "/*", "notFoundServlet");
		context.addServletMappingDecoded("/rest/" + TIMEOUT_STATUS_ENDPOINT, "timeoutStatusServlet");
		context.addServletMappingDecoded("/rest/" + TIMEOUT_STATUS_ENDPOINT + "/*", "timeoutStatusServlet");
		context.addServletMappingDecoded("/rest/" + TIMEOUTING_ENDPOINT, "timeoutStatusServlet");
		context.addServletMappingDecoded("/rest/" + TIMEOUTING_ENDPOINT + "/*", "timeoutStatusServlet");
		testTomcats.add(testTomcat);
	} catch (ServletException e) {
		e.printStackTrace();
	}
}
 
开发者ID:DescartesResearch,项目名称:Pet-Supply-Store,代码行数:28,代码来源:LoadBalancerTest.java

示例8: setUpTomcat

import org.apache.catalina.Context; //导入方法依赖的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

示例9: setup

import org.apache.catalina.Context; //导入方法依赖的package包/类
@Before
public void setup() throws ServletException, LifecycleException, InterruptedException, JsonProcessingException {
	webUITomcat = new Tomcat();
	webUITomcat.setPort(3000);
	webUITomcat.setBaseDir(testWorkingDir);
	webUITomcat.enableNaming();
	Context context = webUITomcat.addWebapp(CONTEXT, System.getProperty("user.dir") + File.separator + "src"
			+ File.separator + "main" + File.separator + "webapp");
	ContextEnvironment registryURL = new ContextEnvironment();
	registryURL.setDescription("");
	registryURL.setOverride(false);
	registryURL.setType("java.lang.String");
	registryURL.setName("registryURL");
	registryURL.setValue("http://localhost:9001/tools.descartes.petsupplystore.registry/rest/services/");
	context.getNamingResources().addEnvironment(registryURL);
	webUITomcat.addServlet(CONTEXT, "servlet", getServlet());
	webUITomcat.addServlet(CONTEXT, "index", new IndexServlet());
	webUITomcat.addServlet(CONTEXT, "login", new LoginServlet());
	webUITomcat.addServlet(CONTEXT, "order", new OrderServlet());
	context.addServletMappingDecoded("/test", "servlet");
	context.addServletMappingDecoded("/index", "index");
	context.addServletMappingDecoded("/login", "login");
	context.addServletMappingDecoded("/order", "order");
	context.addWelcomeFile("/index");
	webUITomcat.start();

	// Mock registry
	List<String> strings = new LinkedList<String>();
	strings.add("localhost:9001");
	String json = new ObjectMapper().writeValueAsString(strings);
	wireMockRule.stubFor(get(urlEqualTo(
			"/tools.descartes.petsupplystore.registry/rest/services/" + Service.IMAGE.getServiceName() + "/"))
					.willReturn(okJson(json)));
	wireMockRule.stubFor(get(urlEqualTo(
			"/tools.descartes.petsupplystore.registry/rest/services/" + Service.STORE.getServiceName() + "/"))
					.willReturn(okJson(json)));
	wireMockRule.stubFor(get(urlEqualTo(
			"/tools.descartes.petsupplystore.registry/rest/services/" + Service.PERSISTENCE.getServiceName() + "/"))
					.willReturn(okJson(json)));
	wireMockRule.stubFor(get(urlEqualTo(
			"/tools.descartes.petsupplystore.registry/rest/services/" + Service.RECOMMENDER.getServiceName() + "/"))
					.willReturn(okJson(json)));

	// Mock images
	HashMap<String, String> img = new HashMap<>();
	img.put("andreBauer", "andreBauer");
	img.put("johannesGrohmann", "johannesGrohmann");
	img.put("joakimKistowski", "joakimKistowski");
	img.put("simonEismann", "simonEismann");
	img.put("norbertSchmitt", "norbertSchmitt");
	img.put("descartesLogo", "descartesLogo");
	img.put("icon", "icon");
	mockValidPostRestCall(img, "/tools.descartes.petsupplystore.image/rest/image/getWebImages");
}
 
开发者ID:DescartesResearch,项目名称:Pet-Supply-Store,代码行数:55,代码来源:AbstractUiTest.java

示例10: TomcatTestHandler

import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
 * Create a Tomcat test handler for persistence testing.
 * @param count Number of testing tomcats.
 * @param startPort Port to start with (do not use 0 for auto-assigning).
 * @param wireMockRule Wire mock rule for mocking the registry.The test handler will
 * add all services with respective stubs to the rule.
 * @param endpoints Class objects for the endpoints.
 * @throws ServletException Exception on failure.
 * @throws LifecycleException Exception on failure.
 * @throws JsonProcessingException Exception on failure.
 */
public TomcatTestHandler(int count, int startPort, WireMockRule wireMockRule, Class<?>... endpoints)
		throws ServletException, LifecycleException, JsonProcessingException {
	tomcats = new Tomcat[count];
	EMFManagerInitializer.initializeEMF();
	for (int i = 0; i < count; i++) {
		tomcats[i] = new Tomcat();
		tomcats[i].setPort(startPort + i);
		tomcats[i].setBaseDir(testWorkingDir);
		Context context = tomcats[i].addWebapp(CONTEXT, testWorkingDir);
		//Registry
		if (wireMockRule != null) {
			ContextEnvironment registryURL = new ContextEnvironment();
			registryURL.setDescription("");
			registryURL.setOverride(false);
			registryURL.setType("java.lang.String");
			registryURL.setName("registryURL");
			registryURL.setValue("http://localhost:" + wireMockRule.port()
			+ "/tools.descartes.petsupplystore.registry/rest/services/");
			context.getNamingResources().addEnvironment(registryURL);
			ContextEnvironment servicePort = new ContextEnvironment();
			servicePort.setDescription("");
			servicePort.setOverride(false);
			servicePort.setType("java.lang.String");
		    servicePort.setName("servicePort");
		    servicePort.setValue("" + startPort + i);
			context.getNamingResources().addEnvironment(servicePort);
			context.addApplicationListener(RegistrationDaemon.class.getName());
		}
		//REST endpoints
		ResourceConfig restServletConfig = new ResourceConfig();
		for (Class<?> endpoint: endpoints) {
			restServletConfig.register(endpoint);
		}
		ServletContainer restServlet = new ServletContainer(restServletConfig);
		tomcats[i].addServlet(CONTEXT, "restServlet", restServlet);
		context.addServletMappingDecoded("/rest/*", "restServlet");
		tomcats[i].start();
	}
	if (wireMockRule != null) {
		initializeMockRegistry(wireMockRule, count, startPort);
	}
	System.out.println("Initializing Database with size " + CategoryRepository.REPOSITORY.getAllEntities().size());
}
 
开发者ID:DescartesResearch,项目名称:Pet-Supply-Store,代码行数:55,代码来源:TomcatTestHandler.java

示例11: setup

import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
 * Sets up a store.
 * @throws Throwable Throws uncaught throwables for test to fail.
 */
@Before
public void setup() throws Throwable {
	storeTomcat = new Tomcat();
	storeTomcat.setPort(3000);
	storeTomcat.setBaseDir(testWorkingDir);
	storeTomcat.enableNaming();
	Context context3 = storeTomcat.addWebapp("/tools.descartes.petsupplystore.store", testWorkingDir);
	ContextEnvironment registryURL3 = new ContextEnvironment();
	registryURL3.setDescription("");
	registryURL3.setOverride(false);
	registryURL3.setType("java.lang.String");
	registryURL3.setName("registryURL");
	registryURL3.setValue("http://localhost:18080/tools.descartes.petsupplystore.registry/rest/services/");
	context3.getNamingResources().addEnvironment(registryURL3);
	ContextEnvironment servicePort3 = new ContextEnvironment();
	servicePort3.setDescription("");
	servicePort3.setOverride(false);
	servicePort3.setType("java.lang.String");
    servicePort3.setName("servicePort");
    servicePort3.setValue("3000");
	context3.getNamingResources().addEnvironment(servicePort3);
	ResourceConfig restServletConfig3 = new ResourceConfig();
	restServletConfig3.register(StoreCartREST.class);
	restServletConfig3.register(StoreCategoriesREST.class);
	restServletConfig3.register(StoreProductREST.class);
	restServletConfig3.register(StoreUserActionsREST.class);
	restServletConfig3.register(StoreUserREST.class);
	ServletContainer restServlet3 = new ServletContainer(restServletConfig3);
	storeTomcat.addServlet("/tools.descartes.petsupplystore.store", "restServlet", restServlet3);
	context3.addServletMappingDecoded("/rest/*", "restServlet");
	context3.addApplicationListener(EmptyStoreStartup.class.getName());

	// Mock registry
	List<String> strings = new LinkedList<String>();
	strings.add("localhost:18080");
	String json = new ObjectMapper().writeValueAsString(strings);
	List<String> strings2 = new LinkedList<String>();
	strings2.add("localhost:3000");
	String json2 = new ObjectMapper().writeValueAsString(strings2);
	wireMockRule.stubFor(get(urlEqualTo(
			"/tools.descartes.petsupplystore.registry/rest/services/" + Service.IMAGE.getServiceName() + "/"))
					.willReturn(okJson(json)));
	wireMockRule.stubFor(get(urlEqualTo(
			"/tools.descartes.petsupplystore.registry/rest/services/" + Service.STORE.getServiceName() + "/"))
					.willReturn(okJson(json2)));
	wireMockRule.stubFor(WireMock.put(WireMock.urlMatching(
			"/tools.descartes.petsupplystore.registry/rest/services/" + Service.STORE.getServiceName() + "/.*"))
					.willReturn(okJson(json2)));
	wireMockRule.stubFor(WireMock.delete(WireMock.urlMatching(
			"/tools.descartes.petsupplystore.registry/rest/services/" + Service.STORE.getServiceName() + "/.*"))
					.willReturn(okJson(json2)));
	wireMockRule.stubFor(get(urlEqualTo(
			"/tools.descartes.petsupplystore.registry/rest/services/" + Service.PERSISTENCE.getServiceName() + "/"))
					.willReturn(okJson(json)));
	wireMockRule.stubFor(get(urlEqualTo(
			"/tools.descartes.petsupplystore.registry/rest/services/" + Service.RECOMMENDER.getServiceName() + "/"))
					.willReturn(okJson(json)));

	// Mock images
	HashMap<String, String> img = new HashMap<>();
	img.put("andreBauer", "andreBauer");
	img.put("johannesGrohmann", "johannesGrohmann");
	img.put("joakimKistowski", "joakimKistowski");
	img.put("simonEismann", "simonEismann");
	img.put("norbertSchmitt", "norbertSchmitt");
	img.put("descartesLogo", "descartesLogo");
	img.put("icon", "icon");
	mockValidPostRestCall(img, "/tools.descartes.petsupplystore.image/rest/image/getWebImages");
	
	storeTomcat.start();
}
 
开发者ID:DescartesResearch,项目名称:Pet-Supply-Store,代码行数:76,代码来源:AbstractStoreRestTest.java

示例12: registerServlet

import org.apache.catalina.Context; //导入方法依赖的package包/类
private static <T extends BaseTestServlet> T registerServlet(Context context, T servlet) {
  Tomcat.addServlet(context, servlet.getClass().getSimpleName(), servlet);
  context.addServletMappingDecoded(servlet.getPath(), servlet.getClass().getSimpleName());
  return servlet;
}
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:6,代码来源:TomcatFilterInstrumentationTest.java


注:本文中的org.apache.catalina.Context.addServletMappingDecoded方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。