|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.cojen.util.BelatedCreator<T,E>
public abstract class BelatedCreator<T,E extends Exception>
Generic one-shot factory which supports late object creation. If the object creation results in an exception or is taking too long, the object produced instead is a bogus one. After retrying, if the real object is created, then the bogus object turns into a wrapper to the real object.
Note: If a bogus object is created, the wrapper cannot always be a drop-in replacement for the real object. If the wrapper is cloned, it won't have the same behavior as cloning the real object. Also, synchronizing on the wrapper will not synchronize the real object.
| Constructor Summary | |
|---|---|
protected |
BelatedCreator(Class<T> type,
int minRetryDelayMillis)
|
| Method Summary | |
|---|---|
protected abstract T |
createBogus()
Create instance of bogus object. |
protected void |
createdNotification(T object)
Notification that createReal has produced the real object. |
protected abstract T |
createReal()
Create instance of real object. |
T |
get(int timeoutMillis)
Returns real or bogus object. |
protected abstract void |
timedOutNotification(long timedOutMillis)
Notification that createReal is taking too long. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected BelatedCreator(Class<T> type,
int minRetryDelayMillis)
type - type of object createdminRetryDelayMillis - minimum milliseconds to wait before retrying
to create object after failure; if negative, never retry
IllegalArgumentException - if type is null or is not an interface| Method Detail |
|---|
public T get(int timeoutMillis)
throws E extends Exception
timeoutMillis - maximum time to wait for real object before
returning bogus one; if negative, potentially wait forever
E - exception thrown from createReal
E extends Exception
protected abstract T createReal()
throws E extends Exception
E - unrecoverable error
E extends Exceptionprotected abstract T createBogus()
protected abstract void timedOutNotification(long timedOutMillis)
timedOutMillis - milliseconds waited before giving upprotected void createdNotification(T object)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||