|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.mit.jverbnet.util.AbstractHasLifecycle
public abstract class AbstractHasLifecycle
Abstract implementation of an object that has a lifecycle. This class's
methods are thread safe.
Subclasses should put their actual lifecycle code in the doOpen()
,
doIsOpen()
, and doClose()
methods. Synchronization happens
in the abstract class, so subclasses do not need to worry about that.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface edu.mit.jverbnet.util.IHasLifecycle |
---|
IHasLifecycle.ObjectClosedException |
Constructor Summary | |
---|---|
AbstractHasLifecycle()
|
Method Summary | |
---|---|
protected void |
checkOpen()
Throws an exception if the object is closed |
void |
close()
This closes the object by disposing of data backing objects or connections. |
protected abstract void |
doClose()
Subclasses should put tear-down, closing code in this method. |
protected abstract boolean |
doIsOpen()
Subclasses should put code that determines whether the object is open in here. |
protected abstract boolean |
doOpen()
Subclasses should put initialization code in this method. |
boolean |
isOpen()
Returns true if the object is open, that is, ready to
be used; returns false otherwise |
boolean |
open()
This opens the object by performing any required initialization steps. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AbstractHasLifecycle()
Method Detail |
---|
protected final void checkOpen()
public final boolean open() throws java.io.IOException
IHasLifecycle
false
, then subsequent calls to
IHasLifecycle.isOpen()
will return false
.
open
in interface IHasLifecycle
true
if there were no errors in initialization;
false
otherwise.
java.io.IOException
- if there was IO error while performing initializationpublic final boolean isOpen()
IHasLifecycle
true
if the object is open, that is, ready to
be used; returns false
otherwise
isOpen
in interface IHasLifecycle
true
if the object is open; false
otherwisepublic final void close()
IHasLifecycle
close
in interface IHasLifecycle
protected abstract boolean doOpen() throws java.io.IOException
false
or throw an exception. The abstract
lifecycle object takes care of calling the doClose()
method if
initialization fails.
true
if initialization succeeds; false
otherwise
java.io.IOException
- if there is an IO error while initializingprotected abstract boolean doIsOpen()
true
if the object is open; false
otherwise.
true
if the object is open; false
otherwise.protected abstract void doClose()
open()
the
object.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |