org.beanlet
Interface BeanletReference<T>


public interface BeanletReference<T>

Represents a reference to a beanlet.

Beanlets references are used to uniquely identify the underlying beanlet and to control the lifecycle of the beanlet.

Invocations made on a beanlet proxy that points to a stateful beanlet are always performed on the same beanlet instance. In case of a stateless beanlet, it is not specified which beanlet instance is used to execute the invocation.

Beanlet references can be removed, either explicitly by calling invalidate() or alternatively, once it is no longer stronly reachable, by the garbage collector. Beanlet references that have been removed can no longer be used to perform calls on the underlying beanlet. Such calls will result in an unchecked exception thrown by the application container. The isRemoved() method can be used to check whether a reference has been removed.


Method Summary
 Object execute(Event event)
          Executes the specified event.
 Object getBeanlet()
          Returns the beanlet.
 BeanletMetaData<T> getBeanletMetaData()
          Returns meta data for the underlying beanlet.
 T getTypedBeanlet()
          Returns the beanlet if this object is an instance of the beanlet type as specified by BeanletMetaData.getType().
 void invalidate()
          Causes this reference to be invalidated and removed.
 boolean isExecutable(Event event)
          Returns true if specified event is supported by this reference.
 boolean isRemoved()
          Returns true if this reference has been removed, it can no longer execute events, false otherwise.
 boolean isValid()
          Returns true if this reference if valid.
 void remove()
          Remove the reference immediately.
 

Method Detail

getBeanletMetaData

BeanletMetaData<T> getBeanletMetaData()
Returns meta data for the underlying beanlet.


getBeanlet

Object getBeanlet()
Returns the beanlet.

Returns:
the beanlet.

getTypedBeanlet

T getTypedBeanlet()
                  throws BeanletNotOfRequiredTypeException
Returns the beanlet if this object is an instance of the beanlet type as specified by BeanletMetaData.getType(). This might not always be the case, for example for proxy beanlets. In this case a BeanletNotOfRequiredTypeException exception is thrown.

Returns:
the beanlet.
Throws:
BeanletNotOfRequiredTypeException - if beanlet is not an instance of beanlet type.

isExecutable

boolean isExecutable(Event event)
Returns true if specified event is supported by this reference.


execute

Object execute(Event event)
               throws BeanletEventException
Executes the specified event.

Throws:
BeanletEventException - result of event execution.

invalidate

void invalidate()
Causes this reference to be invalidated and removed. As a result, isValid returns false. Events can still be executed while the reference is being invalidated. This method is idempotent.


isValid

boolean isValid()
Returns true if this reference if valid. If false is returned, the reference is being destroyed and finally removed, resulting in isRemoved to return true.

Returns:
true if this reference is valid, false otherwise.

remove

void remove()
Remove the reference immediately. The reference is not being invalidated.


isRemoved

boolean isRemoved()
Returns true if this reference has been removed, it can no longer execute events, false otherwise.

Returns:
true if this reference is removed, false otherwise.


Copyright © 2006-2012. All Rights Reserved.