jetty-9 more lifecycle fixes

This commit is contained in:
Greg Wilkins 2012-09-21 16:41:05 +10:00
parent f5af05f0cc
commit 9ee8ef7423
8 changed files with 27 additions and 8 deletions

View File

@ -39,6 +39,11 @@
<artifactId>jetty-jmx</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.spdy</groupId>
<artifactId>spdy-http-server</artifactId>

View File

@ -53,8 +53,8 @@ public class LikeJettyXml
Server server = new Server(threadPool);
server.manage(threadPool);
server.setDumpAfterStart(true);
server.setDumpBeforeStop(true);
server.setDumpAfterStart(false);
server.setDumpBeforeStop(false);
// Setup JMX
MBeanContainer mbContainer=new MBeanContainer(ManagementFactory.getPlatformMBeanServer());

View File

@ -54,16 +54,19 @@ public abstract class ScanningAppProvider extends AbstractLifeCycle implements A
/* ------------------------------------------------------------ */
private final Scanner.DiscreteListener _scannerListener = new Scanner.DiscreteListener()
{
@Override
public void fileAdded(String filename) throws Exception
{
ScanningAppProvider.this.fileAdded(filename);
}
@Override
public void fileChanged(String filename) throws Exception
{
ScanningAppProvider.this.fileChanged(filename);
}
@Override
public void fileRemoved(String filename) throws Exception
{
ScanningAppProvider.this.fileRemoved(filename);

View File

@ -73,6 +73,8 @@ public abstract class AbstractHandler extends ContainerLifeCycle implements Hand
@Override
public void setServer(Server server)
{
if (_server==server)
return;
if (isStarted())
throw new IllegalStateException(STARTED);
_server=server;

View File

@ -84,7 +84,8 @@ public class HandlerCollection extends AbstractHandlerContainer
if (handlers!=null)
for (Handler handler:handlers)
handler.setServer(getServer());
if (handler.getServer()!=getServer())
handler.setServer(getServer());
updateBeans(_handlers, handlers);
_handlers = handlers;

View File

@ -103,6 +103,9 @@ public class HandlerWrapper extends AbstractHandlerContainer
@Override
public void setServer(Server server)
{
if (server==getServer())
return;
if (isStarted())
throw new IllegalStateException(STARTED);

View File

@ -224,10 +224,10 @@ public abstract class AbstractLifeCycle implements LifeCycle
public static abstract class AbstractLifeCycleListener implements LifeCycle.Listener
{
public void lifeCycleFailure(LifeCycle event, Throwable cause) {}
public void lifeCycleStarted(LifeCycle event) {}
public void lifeCycleStarting(LifeCycle event) {}
public void lifeCycleStopped(LifeCycle event) {}
public void lifeCycleStopping(LifeCycle event) {}
@Override public void lifeCycleFailure(LifeCycle event, Throwable cause) {}
@Override public void lifeCycleStarted(LifeCycle event) {}
@Override public void lifeCycleStarting(LifeCycle event) {}
@Override public void lifeCycleStopped(LifeCycle event) {}
@Override public void lifeCycleStopping(LifeCycle event) {}
}
}

View File

@ -25,6 +25,8 @@ import java.util.Collections;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.annotation.ManagedOperation;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@ -45,6 +47,7 @@ import org.eclipse.jetty.util.log.Logger;
* 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.
*/
@ManagedObject("Implementation of Container and LifeCycle")
public class ContainerLifeCycle extends AbstractLifeCycle implements Container, Destroyable, Dumpable
{
private static final Logger LOG = Log.getLogger(ContainerLifeCycle.class);
@ -470,6 +473,7 @@ public class ContainerLifeCycle extends AbstractLifeCycle implements Container,
* Dumps to {@link System#err}.
* @see #dump()
*/
@ManagedOperation("Dump the object to stderr")
public void dumpStdErr()
{
try
@ -483,6 +487,7 @@ public class ContainerLifeCycle extends AbstractLifeCycle implements Container,
}
@Override
@ManagedOperation("Dump the object to a string")
public String dump()
{
return dump(this);