public abstract class BelatedCreator<T,E extends Exception> extends 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.
Modifier | Constructor and Description |
---|---|
protected |
BelatedCreator(Class<T> type,
int minRetryDelayMillis) |
Modifier and Type | Method and Description |
---|---|
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.
|
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 retryIllegalArgumentException
- if type is null or is not an interfacepublic T get(int timeoutMillis) throws E extends Exception
protected abstract T createReal() throws E extends Exception
protected abstract T createBogus()
protected abstract void timedOutNotification(long timedOutMillis)
timedOutMillis
- milliseconds waited before giving upprotected void createdNotification(T object)
Copyright © 2004-2015 Cojen. All Rights Reserved.