public abstract class BelatedCreator<T,E extends java.lang.Exception>
extends java.lang.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(java.lang.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(java.lang.Class<T> type, int minRetryDelayMillis)
type
- type of object createdminRetryDelayMillis
- minimum milliseconds to wait before retrying
to create object after failure; if negative, never retryjava.lang.IllegalArgumentException
- if type is null or is not an interfacepublic T get(int timeoutMillis) throws E extends java.lang.Exception
timeoutMillis
- maximum time to wait for real object before
returning bogus one; if negative, potentially wait foreverE
- exception thrown from createRealE extends java.lang.Exception
protected abstract T createReal() throws E extends java.lang.Exception
E
- unrecoverable errorE extends java.lang.Exception
protected abstract T createBogus()
protected abstract void timedOutNotification(long timedOutMillis)
timedOutMillis
- milliseconds waited before giving upprotected void createdNotification(T object)
Copyright © 2006-2013 Amazon Technologies, Inc.. All Rights Reserved.