Bind certain Web-Applications to specific HttpConnectors II

With Pax-Web 3.0.0 it’s now also possible to bind web-applications to certain httpConnectors via the whiteboard extender, if you want to know how it’s done with a published war take a look at the previous post about this.

Assuming you do use the extended configuration for jetty as described in Bind certain Web-Applications to specific HttpConnectors, let’s move on to the actual work to bind your application to a specific HttpConnector vie WhiteBoard-Extender.

props.put( ExtenderConstants.PROPERTY_HTTP_CONTEXT_ID, "extended" );
HashMap<String,String> contextMappingParams = new HashMap<String,String>();
contextMappingParams.put(ExtenderConstants.PROPERTY_HTTP_VIRTUAL_HOSTS, "localhost");
contextMappingParams.put(ExtenderConstants.PROPERTY_HTTP_CONNECTORS, "jettyConn1");
m_httpContextMappingReg = bundleContext.registerService( HttpContextMapping.class, new WhiteboardHttpContextMapping("extended", "foo", contextMappingParams), props );

So how does this actually work? First of all you need to register a HttpContextMapping as a Service. Therefore you create a new Map containing the HTTP_VIRTUAL_HOSTS and PROPERTY_CONNECTORS after that you register this map as the first HTTP_CONTEXT_ID. This will give you the first configuration for a connecting to a new virtual hosting environment extended. Now you just need to bind your Servlets to this context.

props = new Hashtable<String, String>();
props.put( ExtenderConstants.PROPERTY_ALIAS, "/whiteboard" );
props.put( ExtenderConstants.PROPERTY_HTTP_CONTEXT_ID, "extended" );
m_servletReg = bundleContext.registerService( Servlet.class, new WhiteboardServlet( "/whiteboard" ), props );

Registering your Servlet is straight forward, you just need to make sure you’re connecting to the right HTTP_CONTEXT_ID, in this case it’s the extended one.

Again, I have to thank a lot the community to actively help Pax-Web to be where it is today.

Beitrag veröffentlicht


, ,




Eine Antwort zu „Bind certain Web-Applications to specific HttpConnectors II“

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert


Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.