com.tibco.bw.poa.runtime
Class Advice<I,U,N extends I,A extends I,S,T,X>


java.lang.Object

  extended by com.tibco.bw.poa.runtime.Advice<I,U,N,A,S,T,X>

Direct Known Subclasses:
AsyncAdvice, SyncAdvice

public abstract class Advice<I,U,N extends I,A extends I,S,T,X>
extends java.lang.Object

The base runtime class of all Java advice implementations that execute in BusinessWorks. An advice implementation must not extend this class directly. Instead, an advice implementation must extend one of the two extensions of this class, described bellow.

There are two flavors of advice implementations:

The Advice class is extended by two classes, SyncAdvice and AsyncAdvice, which are the base classes of all advice implementations that are deployed in BusinessWorks. An advice implementation must extend one of these two classes.

An advice implementation Java class must have the AdviceImpl annotation defined at the class level. The BusinessWorks engine throws an exception at runtime if it finds an advice implemented with a class that is not properly annotated. Here is an example of a properly annotated advice implementation java class:

                @AdviceImpl
                public class MyAdviceImplementation ... {
                }
 

At runtime, the BusinessWorks engine instantiates an advice implementation class based on the scope parameter specified in the AdviceImpl annotation.

Since:
1.0
See Also:
SyncAdvice, AsyncAdvice, AdviceImpl

Constructor Summary
Advice()
           
 
Method Summary
 void destroy(AdviceContext<I,U,N,A,S,T,X> context)
          Destroys the advice instance.
 AdviceContext<I,U,N,A,S,T,X> getAdviceContext()
          Returns the context associated with this advice instance.
 void init(AdviceContext<I,U,N,A,S,T,X> context)
          Initializes the advice instance.
abstract  boolean isSynchronous()
          Returns true if the advice is executed synchronously on the job thread.
 N resumeFromHibernate(N input, AspectProcessContext<I,U,N,A,S,T,X> context)
          This method is called when a job is resumed from the hibernate state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Advice


public Advice()
Method Detail

isSynchronous


public abstract boolean isSynchronous()
Returns true if the advice is executed synchronously on the job thread. A synchronous advice always blocks the job thread until it finishes executing. An advice that spawns a thread and runs its business logic on it is not synchronous and therefore returns false.

Returns:
true if the advice implementation is synchronous; false otherwise.

init


public void init(AdviceContext<I,U,N,A,S,T,X> context)

          throws AspectException
Initializes the advice instance. An advice implementation can override this method in order to customize its initialization.

The BusinessWorks engine can call this method multiple times, once for each advice instance that is associated with this advice implementation java object. This happens when two or more advices share the same implementation and the implementation class is stateful (i.e. is configured with scope APPLICATION). The engine never calls this method concurrently, though.

This method is always called right after the advice instance has been configured and before the advice instance is executed. An advice implementation must call super.init() if it overrides this method.

Parameters:
context - the context of the advice instance that is being initialized
Throws:
AspectException

getAdviceContext


public AdviceContext<I,U,N,A,S,T,X> getAdviceContext()
Returns the context associated with this advice instance.

A stateful advice implementation cannot use this method to get access to the advice context. It must use AspectProcessContext.getCurrentRunningAdviceContext() instead.

Returns:
the context associated with this advice instance

resumeFromHibernate


public N resumeFromHibernate(N input,

                             AspectProcessContext<I,U,N,A,S,T,X> context)

                                throws AspectException
This method is called when a job is resumed from the hibernate state. By implementing this method, the advice implementation gets the chance to react to this event. This method is not called by the engine unless the advice implementation advertises that it takes advantage of the Hibernate/Resume feature.

Any exception thrown by the advice implementation in this method will not be propagated back to the job that is about to be resumed.

This method is called by the engine only on the advice instance that has triggered the hibernation.

An advice implementation that receives this event cannot interact with the engine in an asynchronous way. The AspectProcessContext does not have an AdviceController that could be used to interact with the engine.

Parameters:
input - the XML document that was available in the join point where hibernate was triggered, just before the process instance was hibernated
context - the context associated with the process instance that is about to be resumed
Returns:
the XML document that will be passed to the activity that follows the join point where the hibernate was triggered. An advice implementation that does not change the XML document should return the input XML document.
Throws:
AspectException

destroy


public void destroy(AdviceContext<I,U,N,A,S,T,X> context)

             throws AspectException
Destroys the advice instance. An advice implementation can override this method in order to customize its destruction.

This method is always called by the engine before the advice instance is destroyed, in order to give it the opportunity to react to the destroy event.

Parameters:
context - the context of the advice instance that is being destroyed
Throws:
AspectException


Copyright @ 2010, TIBCO Softwares (Inc). All right reserved