org.curjent.impl.agent
Class CallInfo

java.lang.Object
  extended by org.curjent.impl.agent.CallInfo
All Implemented Interfaces:
CallSite

public final class CallInfo
extends Object
implements CallSite

Information for an agent's call site. This follows the prototype model for agent initialization. Information for each unique interface method is collected and cached when an agent's unique proxy factory is created. Each agent instance receives a copy of this call site for custom configuration on a per instance basis.

See Also:
ProxyFactory.newInstance()

Field Summary
(package private)  CallStateListener<?>[] assigned
          Configured listeners for each CallState.
(package private)  Controller controller
          The controller instance for this call site.
private  Object data
          Client data for this call site.
(package private)  CallStateListener<?>[] effective
          Effective listeners for each CallState based on the hiearchy of general to more specific configured listeners.
(package private)  long expirationNanos
          Call site expirate timeout converted to nanoseconds.
(package private)  long expirationTimeout
          Call site expiration timeout duration.
(package private)  TimeUnit expirationUnit
          Call site expiration timeout unit.
(package private)  boolean future
          true if the agent call is asynchronous and the interface method returns a Future or AgentCall.
(package private)  Method interfaceMethod
          The call site's unique interface method.
(package private)  CallStateListener<?> listener
          Default configured listener for this call site.
(package private)  MarkerType markerType
          Type of Marker.
(package private)  int paramCount
          Number of method parameters.
(package private)  boolean reentrant
          true if the task's method is annotated with Reentrant.
(package private)  boolean synchronous
          true if the call is implicitly or explicitly synchronous.
(package private)  boolean synthetic
          true if this is a non-standard call.
(package private)  Method taskMethod
          The task's method for this call site.
 
Constructor Summary
CallInfo(Controller controller, CallInfo prototype)
          Creates a new instance for a new agent based on the cached prototype.
CallInfo(MethodInfo info)
          Initialization of the cached prototype.
CallInfo(Method interfaceMethod, Method taskMethod, MarkerType markerType)
          Initialization of a cached prototype for a synthetic marker method.
 
Method Summary
 Object getAgent()
          Returns the front-end object of the agent.
 CallStateListener<?> getCallStateListener()
          Returns the default listener for the given call site.
 CallStateListener<?> getCallStateListener(CallState state)
          Returns a call site's listener for a given state.
 Object getData()
          Returns the caller's data associated with this call site.
 long getExpirationTimeout()
          Returns the call site's default expiration timeout.
 TimeUnit getExpirationTimeoutUnit()
          Returns the call site's default expiration timeout unit.
 Method getInterfaceMethod()
          Returns this call site's interface method.
 MarkerType getMarkerType()
          Type of Marker.
 Method getTaskMethod()
          Returns this call site's task method.
 boolean isFuture()
          true if an asynchronous call and the interface returns Future or AgentCall.
 boolean isReentrant()
          true if task method is Reentrant.
 boolean isSynchronous()
          true if an implicitly or explicitly synchronous call.
 boolean isSynthetic()
          true if this is a non-standard call.
 void setCallStateListener(CallState state, CallStateListener<?> listener)
          Sets a call site's listener for a given state and updates its effective listeners.
 void setCallStateListener(CallStateListener<?> listener)
          Sets the default listener for the given call site and updates its effective listeners.
 void setData(Object data)
          Sets the caller's data associated with this call site.
 void setExpirationTimeout(long value, TimeUnit unit)
          Sets the call site's default expiration timeout.
 String toString()
          Returns a description of this call site's interface method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

controller

final Controller controller
The controller instance for this call site. null for the prototype instance saved with the proxy cache. Initialized in the prototype's copy to the owning controller for each agent instance.


interfaceMethod

final Method interfaceMethod
The call site's unique interface method. There is a one-to-one relationship between call sites and interface methods.


taskMethod

final Method taskMethod
The task's method for this call site. Multiple call sites may reference the same task method.


markerType

final MarkerType markerType
Type of Marker. null for a non-marker call.


paramCount

final int paramCount
Number of method parameters.


future

final boolean future
true if the agent call is asynchronous and the interface method returns a Future or AgentCall.


synchronous

final boolean synchronous
true if the call is implicitly or explicitly synchronous.


reentrant

final boolean reentrant
true if the task's method is annotated with Reentrant.


synthetic

final boolean synthetic
true if this is a non-standard call.


expirationTimeout

long expirationTimeout
Call site expiration timeout duration. Initially Long.MAX_VALUE unless and until this call site is annotated with an expiration timeout or configured at runtime.


expirationUnit

TimeUnit expirationUnit
Call site expiration timeout unit. Initially TimeUnit.NANOSECONDS unless and until this call site is annotated with an expiration timeout or configured at runtime.


expirationNanos

long expirationNanos
Call site expirate timeout converted to nanoseconds. Set to Expirations.NIL unless and until the expiration is configured via an annotation or configuration call.


listener

CallStateListener<?> listener
Default configured listener for this call site. Initially null.


assigned

final CallStateListener<?>[] assigned
Configured listeners for each CallState. Each is initially null. Not used in the cached prototype instance.


effective

final CallStateListener<?>[] effective
Effective listeners for each CallState based on the hiearchy of general to more specific configured listeners. Each is initially null. Not used in the cached prototype instance.


data

private Object data
Client data for this call site. Not used in the cached prototype instance.

Constructor Detail

CallInfo

CallInfo(MethodInfo info)
Initialization of the cached prototype.


CallInfo

CallInfo(Method interfaceMethod,
         Method taskMethod,
         MarkerType markerType)
Initialization of a cached prototype for a synthetic marker method.


CallInfo

CallInfo(Controller controller,
         CallInfo prototype)
Creates a new instance for a new agent based on the cached prototype.

Method Detail

getAgent

public Object getAgent()
Returns the front-end object of the agent.

Specified by:
getAgent in interface CallSite
See Also:
Agent.newInstance(AgentLoader, Class[], AgentTasks, Class)

getInterfaceMethod

public Method getInterfaceMethod()
Returns this call site's interface method.

Specified by:
getInterfaceMethod in interface CallSite

getTaskMethod

public Method getTaskMethod()
Returns this call site's task method.

Specified by:
getTaskMethod in interface CallSite

isFuture

public boolean isFuture()
true if an asynchronous call and the interface returns Future or AgentCall.

Specified by:
isFuture in interface CallSite

isSynchronous

public boolean isSynchronous()
true if an implicitly or explicitly synchronous call.

Specified by:
isSynchronous in interface CallSite

getMarkerType

public MarkerType getMarkerType()
Type of Marker. null for non-marker calls.

Specified by:
getMarkerType in interface CallSite

isReentrant

public boolean isReentrant()
true if task method is Reentrant.

Specified by:
isReentrant in interface CallSite

isSynthetic

public boolean isSynthetic()
true if this is a non-standard call.

Specified by:
isSynthetic in interface CallSite

getExpirationTimeout

public long getExpirationTimeout()
Returns the call site's default expiration timeout.

Specified by:
getExpirationTimeout in interface CallSite
See Also:
Expirations.getExpirationTimeout(CallInfo)

getExpirationTimeoutUnit

public TimeUnit getExpirationTimeoutUnit()
Returns the call site's default expiration timeout unit.

Specified by:
getExpirationTimeoutUnit in interface CallSite
See Also:
Expirations.getExpirationTimeoutUnit(CallInfo)

setExpirationTimeout

public void setExpirationTimeout(long value,
                                 TimeUnit unit)
Sets the call site's default expiration timeout.

Specified by:
setExpirationTimeout in interface CallSite
See Also:
Expirations.setExpirationTimeout(CallInfo, long, TimeUnit)

getCallStateListener

public CallStateListener<?> getCallStateListener()
Returns the default listener for the given call site.

Specified by:
getCallStateListener in interface CallSite
See Also:
CallSite.getCallStateListener()

setCallStateListener

public void setCallStateListener(CallStateListener<?> listener)
Sets the default listener for the given call site and updates its effective listeners.

Specified by:
setCallStateListener in interface CallSite
See Also:
CallSite.setCallStateListener(CallStateListener)

getCallStateListener

public CallStateListener<?> getCallStateListener(CallState state)
Returns a call site's listener for a given state.

Specified by:
getCallStateListener in interface CallSite
See Also:
CallSite.getCallStateListener(CallState)

setCallStateListener

public void setCallStateListener(CallState state,
                                 CallStateListener<?> listener)
Sets a call site's listener for a given state and updates its effective listeners.

Specified by:
setCallStateListener in interface CallSite
See Also:
CallSite.setCallStateListener(CallStateListener)

getData

public Object getData()
Returns the caller's data associated with this call site.

Specified by:
getData in interface CallSite
See Also:
CallSite.setData(Object)

setData

public void setData(Object data)
Sets the caller's data associated with this call site.

Specified by:
setData in interface CallSite
See Also:
AgentConfig.setData(Object), AgentCall.setData(Object)

toString

public String toString()
Returns a description of this call site's interface method.

Overrides:
toString in class Object


Copyright 2009-2011 Tom Landon
Apache License 2.0