|
Errai 3.0.1-SNAPSHOT | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.errai.ioc.client.container.async.AsyncBeanQuery
public class AsyncBeanQuery
An AsyncBeanQuery is used for querying more than one bean at a time, and then orchestrating a unit of work to happen only after all of the beans in the query have been successfully loaded.
For instance, you may need to load two or more beans dynamically from the bean manager in order to accomplish some task. Instead of chaining a series of callbacks, which can become difficult to understand and maintain, you can instead construct a query for the set of beans you need. Example:
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 Summary | |
---|---|
AsyncBeanQuery()
|
Method Summary | ||
---|---|---|
void |
cancelQuery()
Cancels the query if it has not yet returned. |
|
|
load(AsyncBeanDef<T> beanDef)
Requests that the bean described by the specified AsyncBeanDef is loaded. |
|
|
load(Class<T> type)
Requests that the specified bean of the specified is loaded. |
|
|
load(Class<T> type,
Annotation... qualifiers)
Requests that the specified bean of the specified and is loaded. |
|
|
loadNew(AsyncBeanDef<T> beanDef)
Requests that a new instance of the bean described by the specified AsyncBeanDef is loaded. |
|
|
loadNew(Class<T> type)
Requests that a new instance specified bean of the specified is loaded. |
|
|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AsyncBeanQuery()
Method Detail |
---|
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()
|
Errai 3.0.1-SNAPSHOT | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |