Java Code Examples for org.apache.catalina.Context#addParameter()
The following examples show how to use
org.apache.catalina.Context#addParameter() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Starter.java From micro-integrator with Apache License 2.0 | 6 votes |
public void startPeopleService() throws Exception { final File base = createBaseDirectory(); log.info("Using base folder: " + base.getAbsolutePath()); final Tomcat tomcat = new Tomcat(); tomcat.setPort(8080); tomcat.setBaseDir(base.getAbsolutePath()); Context context = tomcat.addContext("/", base.getAbsolutePath()); Tomcat.addServlet(context, "CXFServlet", new CXFServlet()); context.addServletMapping("/rest/*", "CXFServlet"); context.addApplicationListener(ContextLoaderListener.class.getName()); context.setLoader(new WebappLoader(Thread.currentThread().getContextClassLoader())); context.addParameter("contextClass", AnnotationConfigWebApplicationContext.class.getName()); context.addParameter("contextConfigLocation", AppConfig.class.getName()); tomcat.start(); tomcat.getServer().await(); }
Example 2
Source File: Server.java From micro-integrator with Apache License 2.0 | 6 votes |
public static void main(final String[] args) throws Exception { final File base = createBaseDirectory(); log.info("Using base folder: " + base.getAbsolutePath()); final Tomcat tomcat = new Tomcat(); tomcat.setPort(8080); tomcat.setBaseDir(base.getAbsolutePath()); Context context = tomcat.addContext("/", base.getAbsolutePath()); Tomcat.addServlet(context, "CXFServlet", new CXFServlet()); context.addServletMapping("/rest/*", "CXFServlet"); context.addApplicationListener(ContextLoaderListener.class.getName()); context.setLoader(new WebappLoader(Thread.currentThread().getContextClassLoader())); context.addParameter("contextClass", AnnotationConfigWebApplicationContext.class.getName()); context.addParameter("contextConfigLocation", MusicConfig.class.getName()); tomcat.start(); tomcat.getServer().await(); }
Example 3
Source File: Starter.java From product-ei with Apache License 2.0 | 6 votes |
public void startPeopleService() throws Exception { final File base = createBaseDirectory(); log.info("Using base folder: " + base.getAbsolutePath()); final Tomcat tomcat = new Tomcat(); tomcat.setPort(8080); tomcat.setBaseDir(base.getAbsolutePath()); Context context = tomcat.addContext("/", base.getAbsolutePath()); Tomcat.addServlet(context, "CXFServlet", new CXFServlet()); context.addServletMapping("/rest/*", "CXFServlet"); context.addApplicationListener(ContextLoaderListener.class.getName()); context.setLoader(new WebappLoader(Thread.currentThread().getContextClassLoader())); context.addParameter("contextClass", AnnotationConfigWebApplicationContext.class.getName()); context.addParameter("contextConfigLocation", AppConfig.class.getName()); tomcat.start(); tomcat.getServer().await(); }
Example 4
Source File: Server.java From product-ei with Apache License 2.0 | 6 votes |
public static void main(final String[] args) throws Exception { final File base = createBaseDirectory(); log.info("Using base folder: " + base.getAbsolutePath()); final Tomcat tomcat = new Tomcat(); tomcat.setPort(8080); tomcat.setBaseDir( base.getAbsolutePath() ); Context context = tomcat.addContext( "/", base.getAbsolutePath() ); Tomcat.addServlet( context, "CXFServlet", new CXFServlet() ); context.addServletMapping( "/rest/*", "CXFServlet" ); context.addApplicationListener( ContextLoaderListener.class.getName() ); context.setLoader( new WebappLoader( Thread.currentThread().getContextClassLoader() ) ); context.addParameter( "contextClass", AnnotationConfigWebApplicationContext.class.getName() ); context.addParameter( "contextConfigLocation", MusicConfig.class.getName() ); tomcat.start(); tomcat.getServer().await(); }
Example 5
Source File: WebappAuthenticationValveTest.java From carbon-device-mgt with Apache License 2.0 | 6 votes |
/** * To create a request with the given authorization header * * @param authorizationHeader Authorization header * @return the relevant request. * @throws IllegalAccessException Illegal Access Exception. * @throws NoSuchFieldException No Such Field Exception. */ private Request createRequest(String authorizationHeader) throws IllegalAccessException, NoSuchFieldException { Request request = new TestRequest("", ""); Context context = new StandardContext(); context.addParameter("basicAuth", "true"); context.addParameter("managed-api-enabled", "true"); context.setPath("carbon1"); context.addParameter("doAuthentication", String.valueOf(true)); request.setContext(context); MimeHeaders mimeHeaders = new MimeHeaders(); MessageBytes bytes = mimeHeaders.addValue(BaseWebAppAuthenticatorFrameworkTest.AUTHORIZATION_HEADER); bytes.setString(authorizationHeader); Field headersField = org.apache.coyote.Request.class.getDeclaredField("headers"); headersField.setAccessible(true); org.apache.coyote.Request coyoteRequest = new org.apache.coyote.Request(); headersField.set(coyoteRequest, mimeHeaders); request.setCoyoteRequest(coyoteRequest); return request; }
Example 6
Source File: WebappAuthenticationValveTest.java From carbon-device-mgt with Apache License 2.0 | 5 votes |
@Test(description = "This method tests the behaviour of the invoke method of WebAuthenticationValve when " + "un-secured endpoints are invoked.") public void testInvokeUnSecuredEndpoints() { Request request = new TestRequest("", "test"); Context context = new StandardContext(); context.setPath("carbon1"); context.addParameter("doAuthentication", String.valueOf(true)); context.addParameter("nonSecuredEndPoints", "test, test1"); CompositeValve compositeValve = Mockito.mock(CompositeValve.class); Mockito.doNothing().when(compositeValve).continueInvocation(Mockito.any(), Mockito.any()); request.setContext(context); webappAuthenticationValve.invoke(request, null, compositeValve); }