bug 341736 Use a lifecyclelistener instead of extending the Connector itself
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@3061 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
a9a192bab5
commit
cab968d649
|
@ -14,9 +14,16 @@
|
|||
|
||||
<Call name="addConnector">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.osgi.nested.NestedConnector">
|
||||
<New id="NestedConnector" class="org.eclipse.jetty.nested.NestedConnector">
|
||||
<Set name="statsOn">false</Set>
|
||||
<Set name="confidentialPort">8443</Set>
|
||||
<Call name="addLifeCycleListener">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.osgi.nested.NestedConnectorListener" id="NestedConnectorListener">
|
||||
<Set name="nestedConnector"><Ref id="NestedConnector"/></Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
|
|
|
@ -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(),
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue