Replies: 14 comments
-
Good question and the short answer is: no. The problem is - what do you want to achieve?
with just Configuration Admin ( what do you mean by webcontainer? |
Beta Was this translation helpful? Give feedback.
-
So in pax-web 7 we had 2 config admin sets of properties with an instance uri property that could be filtered on to decide servlet by servlet which webcontainer to deploy them on. Now I wasn't originally involved with that development and there was forked code that now we're trying to get away from. But I don't see anything in that forked code that would seem to change this specific functionality. It seemed like before you could register a factory pid for each webcontainer you wanted to instantiate.abd then in the tracker yoi could look at properties to decide what to do when the specific webcontainer was registered. |
Beta Was this translation helpful? Give feedback.
-
Hmm, I'd have to see this multi configuration with factory PIDs... |
Beta Was this translation helpful? Give feedback.
-
Here was config for container 1: and this is for container 2: And then a filter like following would wait for the relavent container |
Beta Was this translation helpful? Give feedback.
-
So Pax Web 7 handles Are you using some custom version of Pax Web? Any other OSGi/web frameworks? |
Beta Was this translation helpful? Give feedback.
-
I'm sorry.. I pasted wrong versions where i was trying to get it to work after copying stuff from chat gpt.. service.factoryPid=org.ops4j.pax.web and service.factoryPid=org.ops4j.pax.web |
Beta Was this translation helpful? Give feedback.
-
`/* Copyright 2007 Niclas Hedhman.
import static org.ops4j.pax.web.service.WebContainerConstants.PID; import java.io.File; import org.apache.commons.logging.Log; @SuppressWarnings({ "java:S116" })
} |
Beta Was this translation helpful? Give feedback.
-
Here is the activator class we have. Not sure what version it forked from but it does look like the activator was modified to support the multiple instances. I see org.ops4j.pax.web.service.internal.Activator.WebContainerInstance and org.ops4j.pax.web.service.internal.Activator.WebServiceFactory which don't appear to be in the original code at least in version 7 which I thought I had. So I guess the question becomes.. How best to implement what we had before so we have multiple instance of webcontainer OR if there is some better way to implement the same thing. Alternatively is it something you can incoorporate into a release if there is no other way to do it.. i.e: only certain filters and servlets etc on an instance of webcontainer.. |
Beta Was this translation helpful? Give feedback.
-
Without simply backporting your changes to Pax Web there's no way you can have factory PIDs for multiple instances of services like: ServerModel, Jetty Server, Tomcat Server, etc. I agree that it'd be a great enhancement, but I never had time to implement it. All you can do is to specify You'd have to then configure actual virtual hosts which are supported by all 3 runtimes (Jetty, Tomcat and Undertow). You could check this whiteboard sample: that registers 4 different contexts for the combination of connectors and virtual hosts. But that's all we have for now. |
Beta Was this translation helpful? Give feedback.
-
So there is nothing which would be specific to port correct? It would have to be an entirely different ip address (virtual host)? |
Beta Was this translation helpful? Give feedback.
-
Not quite - we can target a Whiteboard component to specific named connector without using virtual hosts. So if you have a connector named "special" on non-default port, say, 8082, we can tell Pax Web that given servlet or other web element should be available only through this connector. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
This is the test that uses this example: https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.31/pax-web-itest/pax-web-itest-container/pax-web-itest-container-common/src/main/java/org/ops4j/pax/web/itest/container/whiteboard/AbstractWhiteboardVirtualHostsIntegrationTest.java This test first installs fragment bundles which configure Jetty, Tomcat and Undertow to use additional connector/listener/virtual-host. For example for Jetty we have this extra configuration: <Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.ServerConnector">
<Arg name="server">
<Ref refid="Server" />
</Arg>
<Arg name="factories">
<Array type="org.eclipse.jetty.server.ConnectionFactory">
<Item>
<New class="org.eclipse.jetty.server.HttpConnectionFactory">
<Arg name="config">
<Ref refid="httpConfig" />
</Arg>
</New>
</Item>
</Array>
</Arg>
<Set name="host">
<Property name="jetty.host" default="localhost" />
</Set>
<Set name="port">
<Property name="jetty.port" default="8282" />
</Set>
<Set name="idleTimeout">
<Property name="http.timeout" default="30000" />
</Set>
<Set name="name">custom</Set>
</New>
</Arg>
</Call> The above connector is named For Tomcat we have: <Connector name="custom" port="8282" protocol="HTTP/1.1" redirectPort="8443" /> and for Undertow: <subsystem xmlns="urn:jboss:domain:undertow:12.0">
<server name="default">
<http-listener name="default" socket-binding="http" />
<http-listener name="custom" socket-binding="http-second" />
</server>
</subsystem>
<interface name="default">
<w:inet-address value="0.0.0.0" />
</interface>
<socket-binding name="http" interface="default" port="${org.osgi.service.http.port}" />
<socket-binding name="http-second" interface="default" port="8282" /> So you can see native (dedicated for selected runtime) configuration of additional connectors within single server. I don't remember exactly what was involved, but these comments from the integration test should show which scenarios are tested: // contexts | path | virtual host | connectors
// ----------+------+--------------+--------------
// extended1 | /foo | localhost | custom(*)
// extended2 | /bar | <all> | default
// extended3 | / | 127.0.0.1 | custom(*)
// extended4 | /baz | <all> | custom(*)
//
// (*) means that this config is externally specified
// org.eclipse.jetty.server.handler.ContextHandler.checkVirtualHost() is the canonical implementation
// of virtual host + connector name handling.
//
// If Jetty has "localhost" host and "@default" connector configured, connector is checked in two cases:
// 1) host@connnector - both must match
// 2) @connector - only a connector matching is enough - even if "Host" header doesn't match ANY context's host |
Beta Was this translation helpful? Give feedback.
-
This is very helpful. I was looking at test case but I don't see how the connectors are actually configured. Also.. Is there a way to create a connector dynamically because I want the port number to be controlled by a configadmin property cause that's how things worked before when our custom code instantiated multiple WebContainers. in this someone seems to say it was possible near the end but I can't find the document he's referring to: #1060 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Can I direct, via configadmin, multiple webcontainers to start with each on different ports and with a differentiating property to determine instance?
Beta Was this translation helpful? Give feedback.
All reactions