415194 Deployer gives management of context to context collection

This commit is contained in:
Greg Wilkins 2013-08-16 11:40:23 +10:00
parent e34ba252a2
commit 2761abb658
3 changed files with 25 additions and 8 deletions

View File

@ -25,18 +25,22 @@ import org.eclipse.jetty.server.handler.ContextHandler;
public class StandardStarter implements AppLifeCycle.Binding
{
@Override
public String[] getBindingTargets()
{
return new String[]
{ "starting" };
}
@Override
public void processBinding(Node node, App app) throws Exception
{
ContextHandler handler = app.getContextHandler();
if (!handler.isStarted())
{
// start the handler
handler.start();
}
// After starting let the context manage state
app.getDeploymentManager().getContexts().manage(handler);
}
}

View File

@ -25,18 +25,22 @@ import org.eclipse.jetty.server.handler.ContextHandler;
public class StandardStopper implements AppLifeCycle.Binding
{
@Override
public String[] getBindingTargets()
{
return new String[]
{ "stopping" };
}
@Override
public void processBinding(Node node, App app) throws Exception
{
ContextHandler handler = app.getContextHandler();
if (!handler.isStopped())
{
// Before stopping, take back management from the context
app.getDeploymentManager().getContexts().unmanage(handler);
// Stop it
handler.stop();
}
}
}

View File

@ -46,6 +46,15 @@ import org.eclipse.jetty.util.log.Logger;
* <p>
* If adding a bean that is shared between multiple {@link ContainerLifeCycle} instances, then it should be started before being added, so it is unmanaged, or
* the API must be used to explicitly set it as unmanaged.
* <p>
* This class also provides utility methods to dump deep structures of objects. It the dump, the following symbols are used to indicate the type of contained object:
* <pre>
* SomeContainerLifeCycleInstance
* +- contained POJO instance
* += contained MANAGED object, started and stopped with this instance
* +~ referenced UNMANAGED object, with separate lifecycle
* +? referenced AUTO object that could become MANAGED or UNMANAGED.
* </pre>
*/
@ManagedObject("Implementation of Container and LifeCycle")
public class ContainerLifeCycle extends AbstractLifeCycle implements Container, Destroyable, Dumpable