diff --git a/jetty-osgi/jetty-osgi-boot/jettyhome/etc/jetty-osgi-nested-default.xml b/jetty-osgi/jetty-osgi-boot/jettyhome/etc/jetty-osgi-nested-default.xml index 48c8c6338da..a732f69a484 100644 --- a/jetty-osgi/jetty-osgi-boot/jettyhome/etc/jetty-osgi-nested-default.xml +++ b/jetty-osgi/jetty-osgi-boot/jettyhome/etc/jetty-osgi-nested-default.xml @@ -14,9 +14,16 @@ - + false 8443 + + + + + + + diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/nested/NestedConnector.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/nested/NestedConnectorListener.java similarity index 82% rename from jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/nested/NestedConnector.java rename to jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/nested/NestedConnectorListener.java index cd672b61d6b..db181a8a9ee 100644 --- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/nested/NestedConnector.java +++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/nested/NestedConnectorListener.java @@ -16,15 +16,18 @@ import java.lang.reflect.Method; import javax.servlet.http.HttpServlet; +import org.eclipse.jetty.nested.NestedConnector; +import org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener; +import org.eclipse.jetty.util.component.LifeCycle; import org.osgi.framework.FrameworkUtil; /** - * Extension of the NestedConnector that manages registering and unregistering with the - * BridgeServlet. + * Listens to the start and stop of the NestedConnector to register and unregister the NestedConnector + * with the BridgeServlet. * All interactions with the BridgeServlet are done via introspection to avoid depending on it directly. * The BridgeServlet lives in the bootstrap-webapp; not inside equinox. */ -public class NestedConnector extends org.eclipse.jetty.nested.NestedConnector +public class NestedConnectorListener extends AbstractLifeCycleListener { /** Name of the BridgeServlet class. By default org.eclipse.equinox.servletbridge.BridgeServlet */ @@ -41,6 +44,11 @@ public class NestedConnector extends org.eclipse.jetty.nested.NestedConnector /** servlet that wraps this NestedConnector and uses the NestedConnector to service the requests. */ private NestedConnectorServletDelegate _servletDelegate; + /** + * The NestedConnector listened to. + */ + private NestedConnector nestedConnector; + /** * @param bridgeServletClassName Name of the class that is the BridgeServlet. * By default org.eclipse.equinox.servletbridge.BridgeServlet @@ -81,28 +89,53 @@ public class NestedConnector extends org.eclipse.jetty.nested.NestedConnector this.unregisterServletDelegateMethodName = unregisterServletDelegateMethodName; } - + /** + * @param nestedConnector The NestedConnector that we are listening to here. + */ + public void setNestedConnector(NestedConnector nestedConnector) + { + this.nestedConnector = nestedConnector; + } + /** + * @return The NestedConnector that we are listening to here. + */ + public NestedConnector getNestedConnector() + { + return this.nestedConnector; + } @Override - protected void doStart() throws Exception - { - super.doStart(); - registerWithBridgeServlet(); - } - + public void lifeCycleStarted(LifeCycle event) + { + try + { + registerWithBridgeServlet(); + } + catch (Exception e) + { + //Logger.getLogger("org.eclipse.jetty.osgi.nested").; + } + } + @Override - protected void doStop() throws Exception - { - unregisterWithBridgeServlet(); - super.doStop(); - } + public void lifeCycleStopping(LifeCycle event) + { + try + { + unregisterWithBridgeServlet(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } /** * Hook into the BridgeServlet */ protected void registerWithBridgeServlet() throws Exception { - _servletDelegate = new NestedConnectorServletDelegate(this); + _servletDelegate = new NestedConnectorServletDelegate(getNestedConnector()); try { invokeStaticMethod(getBridgeServletClassName(), getRegisterServletDelegateMethodName(), diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/nested/NestedConnectorServletDelegate.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/nested/NestedConnectorServletDelegate.java index 063e3cf6d04..9cb26595ddd 100644 --- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/nested/NestedConnectorServletDelegate.java +++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/nested/NestedConnectorServletDelegate.java @@ -19,6 +19,8 @@ import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServlet; +import org.eclipse.jetty.nested.NestedConnector; + /** * Wraps a NestedConnector into a servlet that can be plugged into * BridgeServlet#registerServletDelegate