public abstract class LifecycleManager extends Object
Provides ability of executing events in Warp lifecycle from outside of Arquillian extensions.
Lifecycle manager can execute either:
WarpLifecycleEvent events - these will cause executing lifecycle verification methods in all associated
Inspections
LifecycleManager can be retrieved from arbitrary objects associated with current request using LifecycleManagerStore.
Example:
// having reference to request
ServletRequest request = ...;
LifecycleManager manager = LifecycleManagerStore.get(ServletRequest.class, request);
manager.fireEvent(new CustomLifecycleEvent());
with following implementation of CustomLifecycleEvent
public class CustomLifecycleEvent extends WarpLifecycleEvent {
public Annotation getAnnotation() {
return new CustomAnnotation() {
public Class extends Annotation> annotationType() {
return CustomAnnotation.class;
}
};
}
}
and following implementation of CustomAnnotation
@Retention(RUNTIME)
@Target(ElementType.METHOD)
public @interface CustomAnnotation {
}
This will cause executing following method in associated user-defined Inspection:
@CustomAnnotation
public void verifyCustomBehavior() {
...
}
For more details how to implement CustomLifecycleEvent, see WarpLifecycleEvent.
For more info on how to retrieve LifecycleManagerStore, see LifecycleManagerStore.get(Class, Object).
| Constructor and Description |
|---|
LifecycleManager() |
| Modifier and Type | Method and Description |
|---|---|
<T> void |
bindTo(Class<T> clazz,
T object)
Binds the current
LifecycleManager with given object of given class. |
<T> void |
checkUnbound()
Verifies that there is no object bound with this
LifecycleManager. |
abstract void |
fireEvent(Object event)
Executes either:
|
<T> void |
unbindFrom(Class<T> clazz,
T object)
Unbinds the
LifecycleManager from given class and given object. |
public abstract void fireEvent(Object event)
Executes either:
WarpLifecycleEvent events - these will cause executing lifecycle verification methods in all associated
Inspectionsevent - any Arquillian event or specifically WarpLifecycleEventpublic final <T> void bindTo(Class<T> clazz, T object) throws ObjectAlreadyAssociatedException
LifecycleManager with given object of given class.clazz - the class to be boundobject - the object to be boundObjectAlreadyAssociatedException - when there is already object bound with LifecycleManager for given
class.public final <T> void unbindFrom(Class<T> clazz, T object) throws ObjectNotAssociatedException
LifecycleManager from given class and given object.clazz - the bound classobject - the bound classObjectNotAssociatedException - when no object bound with LifecycleManager.public final <T> void checkUnbound()
throws StoreHasAssociatedObjectsException
LifecycleManager.StoreHasAssociatedObjectsException - when there is object bound with this LifecycleManager.Copyright © 2014 JBoss by Red Hat. All rights reserved.