org.mortbay.util
Class Container

java.lang.Object
  extended by org.mortbay.util.Container
All Implemented Interfaces:
java.io.Serializable, EventProvider, LifeCycle
Direct Known Subclasses:
HttpContext, HttpServer, ServletHandler

public abstract class Container
extends java.lang.Object
implements LifeCycle, EventProvider, java.io.Serializable

Abstract Container. Provides base handling for LifeCycle and Component events.

Version:
$Id: Container.java,v 1.5 2007/07/02 01:21:59 gregwilkins Exp $
Author:
Greg Wilkins (gregw)
See Also:
Serialized Form

Constructor Summary
Container()
           
 
Method Summary
protected  void addComponent(java.lang.Object o)
           
 void addEventListener(java.util.EventListener listener)
          Add a server event listener.
 void destroy()
          Destroy a stopped server.
protected abstract  void doStart()
          Do start operations.
protected abstract  void doStop()
          Do stop operations.
 java.util.Collection getComponents()
           
 boolean isFailed()
           
 boolean isStarted()
           
protected  boolean isStarting()
           
protected  boolean isStopping()
           
protected  void removeComponent(java.lang.Object o)
           
 void removeEventListener(java.util.EventListener listener)
           
 void start()
          Start the server.
 void stop()
          Stop the container.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Container

public Container()
Method Detail

start

public final void start()
                 throws java.lang.Exception
Start the server. Generate LifeCycleEvents for starting and started either side of a call to doStart

Specified by:
start in interface LifeCycle
Throws:
java.lang.Exception - An arbitrary exception may be thrown.

doStart

protected abstract void doStart()
                         throws java.lang.Exception
Do start operations. This abstract method is called by start to perform the actual start operations.

Throws:
java.lang.Exception

isStarted

public boolean isStarted()
Specified by:
isStarted in interface LifeCycle
Returns:
True if the LifeCycle has been started.

isFailed

public boolean isFailed()

isStarting

protected boolean isStarting()

isStopping

protected boolean isStopping()

stop

public final void stop()
                throws java.lang.InterruptedException
Stop the container. Generate LifeCycleEvents for stopping and stopped either side of a call to doStop

Specified by:
stop in interface LifeCycle
Throws:
java.lang.InterruptedException - Stopping a lifecycle is rarely atomic and may be interrupted by another thread. If this happens InterruptedException is throw and the component will be in an indeterminant state and should probably be discarded.

doStop

protected abstract void doStop()
                        throws java.lang.Exception
Do stop operations. This abstract method is called by stop to perform the actual stop operations.

Throws:
java.lang.Exception

addComponent

protected void addComponent(java.lang.Object o)

removeComponent

protected void removeComponent(java.lang.Object o)

addEventListener

public void addEventListener(java.util.EventListener listener)
                      throws java.lang.IllegalArgumentException
Add a server event listener.

Specified by:
addEventListener in interface EventProvider
Parameters:
listener - ComponentEventListener or LifeCycleEventListener
Throws:
java.lang.IllegalArgumentException - If the EventListener type is not supported.

removeEventListener

public void removeEventListener(java.util.EventListener listener)
Specified by:
removeEventListener in interface EventProvider

destroy

public void destroy()
Destroy a stopped server. Remove all components and send notifications to all event listeners. The HttpServer must be stopped before it can be destroyed.


getComponents

public java.util.Collection getComponents()


Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.