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">
|
<Call name="addConnector">
|
||||||
<Arg>
|
<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="statsOn">false</Set>
|
||||||
<Set name="confidentialPort">8443</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>
|
</New>
|
||||||
</Arg>
|
</Arg>
|
||||||
</Call>
|
</Call>
|
||||||
|
|
|
@ -16,15 +16,18 @@ import java.lang.reflect.Method;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServlet;
|
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;
|
import org.osgi.framework.FrameworkUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extension of the NestedConnector that manages registering and unregistering with the
|
* Listens to the start and stop of the NestedConnector to register and unregister the NestedConnector
|
||||||
* BridgeServlet.
|
* with the BridgeServlet.
|
||||||
* All interactions with the BridgeServlet are done via introspection to avoid depending on it directly.
|
* 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.
|
* 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 */
|
/** 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. */
|
/** servlet that wraps this NestedConnector and uses the NestedConnector to service the requests. */
|
||||||
private NestedConnectorServletDelegate _servletDelegate;
|
private NestedConnectorServletDelegate _servletDelegate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The NestedConnector listened to.
|
||||||
|
*/
|
||||||
|
private NestedConnector nestedConnector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bridgeServletClassName Name of the class that is the BridgeServlet.
|
* @param bridgeServletClassName Name of the class that is the BridgeServlet.
|
||||||
* By default org.eclipse.equinox.servletbridge.BridgeServlet
|
* By default org.eclipse.equinox.servletbridge.BridgeServlet
|
||||||
|
@ -81,28 +89,53 @@ public class NestedConnector extends org.eclipse.jetty.nested.NestedConnector
|
||||||
this.unregisterServletDelegateMethodName = unregisterServletDelegateMethodName;
|
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
|
@Override
|
||||||
protected void doStart() throws Exception
|
public void lifeCycleStarted(LifeCycle event)
|
||||||
{
|
{
|
||||||
super.doStart();
|
try
|
||||||
registerWithBridgeServlet();
|
{
|
||||||
}
|
registerWithBridgeServlet();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
//Logger.getLogger("org.eclipse.jetty.osgi.nested").;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doStop() throws Exception
|
public void lifeCycleStopping(LifeCycle event)
|
||||||
{
|
{
|
||||||
unregisterWithBridgeServlet();
|
try
|
||||||
super.doStop();
|
{
|
||||||
}
|
unregisterWithBridgeServlet();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook into the BridgeServlet
|
* Hook into the BridgeServlet
|
||||||
*/
|
*/
|
||||||
protected void registerWithBridgeServlet() throws Exception
|
protected void registerWithBridgeServlet() throws Exception
|
||||||
{
|
{
|
||||||
_servletDelegate = new NestedConnectorServletDelegate(this);
|
_servletDelegate = new NestedConnectorServletDelegate(getNestedConnector());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
invokeStaticMethod(getBridgeServletClassName(), getRegisterServletDelegateMethodName(),
|
invokeStaticMethod(getBridgeServletClassName(), getRegisterServletDelegateMethodName(),
|
|
@ -19,6 +19,8 @@ import javax.servlet.ServletRequest;
|
||||||
import javax.servlet.ServletResponse;
|
import javax.servlet.ServletResponse;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.nested.NestedConnector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wraps a NestedConnector into a servlet that can be plugged into
|
* Wraps a NestedConnector into a servlet that can be plugged into
|
||||||
* BridgeServlet#registerServletDelegate
|
* BridgeServlet#registerServletDelegate
|
||||||
|
|
Loading…
Reference in New Issue