Errai 3.0.1-SNAPSHOT

org.jboss.errai.ioc.client.container
Class SyncToAsyncBeanManagerAdapter

java.lang.Object
  extended by org.jboss.errai.ioc.client.container.SyncToAsyncBeanManagerAdapter
All Implemented Interfaces:
AsyncBeanManager, ClientBeanManager

public class SyncToAsyncBeanManagerAdapter
extends Object
implements AsyncBeanManager

An adapter that makes the asynchronous bean manager API work with a synchronous bean manager.

Author:
Christian Sadilek

Constructor Summary
SyncToAsyncBeanManagerAdapter(SyncBeanManager bm)
           
 
Method Summary
 void addBeanToContext(Object ref, CreationalContext creationalContext)
          Associates a bean instance with a creational context.
 boolean addDestructionCallback(Object beanInstance, DestructionCallback<?> destructionCallback)
          Associates a DestructionCallback with a bean instance.
 void addProxyReference(Object proxyRef, Object realRef)
          Associates the reference to a proxied bean to the underlying bean instance which it is proxying.
 void destroyAllBeans()
          Destroy all beans currently managed by the bean manager.
 void destroyBean(Object ref)
          Destroy a bean and all other beans associated with its creational context in the bean manager.
 void destroyBean(Object ref, Runnable runnable)
          Destroy the bean and all other beans associated with its AsyncCreationalContext.
 Object getActualBeanReference(Object ref)
          Obtains an instance to the actual bean.
 boolean isManaged(Object ref)
          Indicates whether the referenced object is currently a managed bean.
 boolean isProxyReference(Object ref)
          Determines whether the referenced object is itself a proxy to a managed bean.
<T> AsyncBeanDef<T>
lookupBean(Class<T> type, Annotation... qualifiers)
          Looks up a bean reference based on type and qualifiers.
<T> Collection<AsyncBeanDef<T>>
lookupBeans(Class<T> type)
          Looks up all beans of the specified type.
<T> Collection<AsyncBeanDef<T>>
lookupBeans(Class<T> type, Annotation... qualifiers)
          Looks up a bean reference based on type and qualifiers.
 Collection<AsyncBeanDef> lookupBeans(String name)
          Looks up all beans with the specified bean name as specified by Named.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SyncToAsyncBeanManagerAdapter

public SyncToAsyncBeanManagerAdapter(SyncBeanManager bm)
Method Detail

destroyBean

public void destroyBean(Object ref)
Description copied from interface: ClientBeanManager
Destroy a bean and all other beans associated with its creational context in the bean manager.

Specified by:
destroyBean in interface ClientBeanManager
Parameters:
ref - the instance reference of the bean

destroyBean

public void destroyBean(Object ref,
                        Runnable runnable)
Description copied from interface: AsyncBeanManager
Destroy the bean and all other beans associated with its AsyncCreationalContext. Because some destruction activity may be asynchronous, this method accepts a second parameter as a callback to be notified when the destruction of all the beans has been done.

Specified by:
destroyBean in interface AsyncBeanManager
Parameters:
ref - the reference to the bean to be destroyed.
runnable - a runnable callback to be called when all the beans have been destroyed.

isManaged

public boolean isManaged(Object ref)
Description copied from interface: ClientBeanManager
Indicates whether the referenced object is currently a managed bean.

Specified by:
isManaged in interface ClientBeanManager
Parameters:
ref - the reference to the bean
Returns:
returns true if under management

getActualBeanReference

public Object getActualBeanReference(Object ref)
Description copied from interface: ClientBeanManager
Obtains an instance to the actual bean. If the specified reference is a proxy, this method will return an un-proxied reference to the object.

Specified by:
getActualBeanReference in interface ClientBeanManager
Parameters:
ref - the proxied or unproxied reference
Returns:
returns the absolute reference to bean if the specified reference is a proxy. If the specified reference is not a proxy, the same instance passed to the method is returned.
See Also:
ClientBeanManager.isProxyReference(Object)

addProxyReference

public void addProxyReference(Object proxyRef,
                              Object realRef)
Description copied from interface: ClientBeanManager
Associates the reference to a proxied bean to the underlying bean instance which it is proxying.

Specified by:
addProxyReference in interface ClientBeanManager
Parameters:
proxyRef - the reference to the proxy
realRef - the reference to the bean being proxied.

isProxyReference

public boolean isProxyReference(Object ref)
Description copied from interface: ClientBeanManager
Determines whether the referenced object is itself a proxy to a managed bean.

Specified by:
isProxyReference in interface ClientBeanManager
Parameters:
ref - the reference to check
Returns:
returns true if the specified reference is itself a proxy.
See Also:
ClientBeanManager.getActualBeanReference(Object)

addDestructionCallback

public boolean addDestructionCallback(Object beanInstance,
                                      DestructionCallback<?> destructionCallback)
Description copied from interface: ClientBeanManager
Associates a DestructionCallback with a bean instance. If the bean manager cannot find a valid CreationalContext to associate with the bean, or the bean is no longer considered active, the method returns false. Otherwise, the method returns true, indicating the callback is now registered and will be called when the bean is destroyed.

Specified by:
addDestructionCallback in interface ClientBeanManager
Parameters:
beanInstance - the bean instance to associate the callback to.
destructionCallback - the instance of the DestructionCallback.
Returns:
true if the DestructionCallback is successfully registered against a valid CreationalContext and false if not.

addBeanToContext

public void addBeanToContext(Object ref,
                             CreationalContext creationalContext)
Description copied from interface: ClientBeanManager
Associates a bean instance with a creational context.

Specified by:
addBeanToContext in interface ClientBeanManager
Parameters:
ref - the reference to the bean
creationalContext - the CreationalContext instance to associate the bean instance with.

destroyAllBeans

public void destroyAllBeans()
Description copied from interface: ClientBeanManager
Destroy all beans currently managed by the bean manager. Don't do this.

Specified by:
destroyAllBeans in interface ClientBeanManager

lookupBeans

public Collection<AsyncBeanDef> lookupBeans(String name)
Description copied from interface: AsyncBeanManager
Looks up all beans with the specified bean name as specified by Named.

Specified by:
lookupBeans in interface AsyncBeanManager
Parameters:
name - the name of bean to lookup
Returns:
and unmodifiable list of all beans with the specified name.

lookupBeans

public <T> Collection<AsyncBeanDef<T>> lookupBeans(Class<T> type)
Description copied from interface: AsyncBeanManager
Looks up all beans of the specified type.

Specified by:
lookupBeans in interface AsyncBeanManager
Parameters:
type - The type of the bean
Returns:
An unmodifiable list of all the beans that match the specified type. Returns an empty list if there is no matching type.

lookupBeans

public <T> Collection<AsyncBeanDef<T>> lookupBeans(Class<T> type,
                                                   Annotation... qualifiers)
Description copied from interface: AsyncBeanManager
Looks up a bean reference based on type and qualifiers. Returns null if there is no type associated with the specified

Specified by:
lookupBeans in interface AsyncBeanManager
Parameters:
type - The type of the bean
qualifiers - qualifiers to match
Returns:
An unmodifiable list of all beans which match the specified type and qualifiers. Returns an empty list if no beans match.

lookupBean

public <T> AsyncBeanDef<T> lookupBean(Class<T> type,
                                      Annotation... qualifiers)
Description copied from interface: AsyncBeanManager
Looks up a bean reference based on type and qualifiers. Returns null if there is no type associated with the specified

Specified by:
lookupBean in interface AsyncBeanManager
Type Parameters:
T - The type of the bean
Parameters:
type - The type of the bean
qualifiers - qualifiers to match
Returns:
An instance of the IOCSingletonBean for the matching type and qualifiers. Throws an IOCResolutionException if there is a matching type but none of the qualifiers match or if more than one bean matches.

Errai 3.0.1-SNAPSHOT

Copyright © 2013-2014 JBoss, a division of Red Hat. All Rights Reserved.