public class AsyncBeanQuery extends Object
AsyncBeanQuery beanQuery = new AsyncBeanQuery();
final AsyncBeanFuture beanAFuture = beanQuery.load(BeanA.class);
final AsyncBeanFuture beanBFuture = beanQuery.load(BeanB.class);
beanQuery.query(new Runnable() {
public void run() {
BeanA beanA = beanAFuture.get();
BeanB beanB = beanBFuture.get();
// do some work.
}
});
In the above example, the Runnable passed to query(Runnable)
will be executed only after
all the beans requested with the previous load(AsyncBeanDef)
calls have been satisfied.Constructor and Description |
---|
AsyncBeanQuery() |
Modifier and Type | Method and Description |
---|---|
void |
cancelQuery()
Cancels the query if it has not yet returned.
|
<T> AsyncBeanFuture<T> |
load(AsyncBeanDef<T> beanDef)
Requests that the bean described by the specified
AsyncBeanDef is loaded. |
<T> AsyncBeanFuture<T> |
load(Class<T> type)
Requests that the specified bean of the specified is loaded.
|
<T> AsyncBeanFuture<T> |
load(Class<T> type,
Annotation... qualifiers)
Requests that the specified bean of the specified and is loaded.
|
<T> AsyncBeanFuture<T> |
loadNew(AsyncBeanDef<T> beanDef)
Requests that a new instance of the bean described by the specified
AsyncBeanDef is loaded. |
<T> AsyncBeanFuture<T> |
loadNew(Class<T> type)
Requests that a new instance specified bean of the specified is loaded.
|
<T> AsyncBeanFuture<T> |
loadNew(Class<T> type,
Annotation... qualifiers)
Requests that a new instance of specified bean of the specified and is loaded.
|
void |
query(Runnable finishCallback)
Initiates the constructed query based on
load(AsyncBeanDef) and loadNew(AsyncBeanDef) calls
made prior to calling this method. |
public <T> AsyncBeanFuture<T> load(Class<T> type)
T
- the type of bean to be loaded.type
- the type of the bean to be loaded. See: AsyncBeanManagerImpl.lookupBean(Class, java.lang.annotation.Annotation...)
AsyncBeanFuture
which will house the instance of the bean once it is loaded.public <T> AsyncBeanFuture<T> load(Class<T> type, Annotation... qualifiers)
T
- the type of bean to be loaded.type
- the type of the bean to be loaded. See: AsyncBeanManagerImpl.lookupBean(Class, java.lang.annotation.Annotation...)
qualifiers
- the qualifiers for the bean to be loaded.AsyncBeanFuture
which will house the instance of the bean once it is loaded.public <T> AsyncBeanFuture<T> load(AsyncBeanDef<T> beanDef)
AsyncBeanDef
is loaded.T
- the type of bean to be loaded.beanDef
- the AsyncBeanDef
describing the bean to be loaded.AsyncBeanFuture
which will house the instance of the bean once it is loaded.public <T> AsyncBeanFuture<T> loadNew(Class<T> type)
T
- the type of bean to be loaded.type
- the type of the bean to be loaded. See: AsyncBeanManagerImpl.lookupBean(Class, java.lang.annotation.Annotation...)
AsyncBeanFuture
which will house the instance of the bean once it is loaded.public <T> AsyncBeanFuture<T> loadNew(Class<T> type, Annotation... qualifiers)
T
- the type of bean to be loaded.type
- the type of the bean to be loaded. See: AsyncBeanManagerImpl.lookupBean(Class, java.lang.annotation.Annotation...)
qualifiers
- the qualifiers for the bean to be loaded.AsyncBeanFuture
which will house the instance of the bean once it is loaded.public <T> AsyncBeanFuture<T> loadNew(AsyncBeanDef<T> beanDef)
AsyncBeanDef
is loaded.T
- the type of bean to be loaded.beanDef
- the AsyncBeanDef
describing the bean to be loaded.AsyncBeanFuture
which will house the instance of the bean once it is loaded.public void query(Runnable finishCallback)
load(AsyncBeanDef)
and loadNew(AsyncBeanDef)
calls
made prior to calling this method. The specified Runnable is invoked only after all the requested
beans have been successfully loaded.finishCallback
- the Runnable to be invoked once all of the request beans have been loaded.public void cancelQuery()
Copyright © 2013-2015 JBoss, a division of Red Hat. All Rights Reserved.