|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.curjent.impl.agent.Config
final class Config
Returned on behalf of the controller to avoid synchronization conflicts on the controller. This also keeps clients from casually casting and using the controller directly.
Field Summary | |
---|---|
(package private) CallInfo[] |
calls
Call site state, metadata, and configuration. |
private Controller |
controller
Agent's configured controller. |
private Object |
data
Value of AgentConfig.setData(Object) . |
private static ExceptionHandler |
DEFAULT_EXCEPTION_HANDLER
Default handler for unhandled exceptions. |
(package private) ExceptionHandler |
exceptions
Handler for unhandled exceptions. |
private List<Class<?>> |
interfaces
Interfaces used to create this agent. |
private Object |
key
Required key to configure the agent. |
private AgentLoader |
loader
Loader used to create this agent. |
(package private) Proxy |
proxy
Proxy object returned to the caller of newInstance . |
private HashMap<CallKey,CallInfo> |
sites
Map of interface method keys to call sites. |
private Class<?> |
taskType
Task class used to create this agent. |
Constructor Summary | |
---|---|
Config(Controller controller,
AgentLoader loader,
Class<?>[] interfaces,
Class<?> taskType)
Manages many of the controller's configuration requirements directly. |
Method Summary | |
---|---|
int |
getAcceptedCapacity()
Returns the current maximum for accepted messages. |
AgentLoader |
getAgentLoader()
Returns the loader used to create the agent. |
AgentTasks |
getAgentTasks()
Returns the tasks used to create the agent. |
CallSite |
getCallSite(String method,
Class<?> result,
Class<?>... params)
Returns configuration settings for an agent's method. |
CallStateListener<?> |
getCallStateListener()
Returns the agent's default listener. |
CallStateListener<?> |
getCallStateListener(CallState state)
Returns the default listener for a specific state. |
Object |
getData()
Returns the data previously associated with this agent. |
long |
getDeadcheckTimeout()
Returns the length of time synchronous calls wait before checking if the caller's thread has deadlocked. |
TimeUnit |
getDeadcheckTimeoutUnit()
Returns the time unit for getDeadcheckTimeout() . |
Executor |
getExecutor()
Returns the agent's executor. |
long |
getExpirationTimeout()
Returns the agent's default expiration timeout value. |
TimeUnit |
getExpirationTimeoutUnit()
Returns the agent's default expiration timeout unit. |
List<Class<?>> |
getInterfaces()
Returns a read-only list of the interfaces used to create the agent. |
int |
getPendingCapacity()
Returns the current maximum for pending messages. |
long |
getPendingTimeout()
Returns the current maximum amount of time a caller waits for the agent to accept its call. |
TimeUnit |
getPendingTimeoutUnit()
Returns the time unit for getPendingCapacity() . |
Class<?> |
getTaskType()
Returns the task type used to create the agent. |
ExceptionHandler |
getUnhandledExceptionHandler()
Returns the agent's handler for unhandled exceptions. |
(package private) void |
init(CallInfo[] calls)
Finishes initialization. |
void |
setAcceptedCapacity(int value)
Updates the current maximum for accepted messages. |
void |
setCallStateListener(CallState state,
CallStateListener<?> listener)
Sets the default listener for a specific state and updates the call sites' effective listeners. |
void |
setCallStateListener(CallStateListener<?> listener)
Sets the agent's default listener and updates the call sites' effective listeners. |
void |
setData(Object data)
Associates data with this agent. |
void |
setDeadcheckTimeout(long value,
TimeUnit unit)
Sets the length of time synchronous calls wait before checking if the caller's thread has deadlocked. |
void |
setExecutor(Executor executor)
Changes the agent's executor. |
void |
setExpirationTimeout(long value,
TimeUnit unit)
Sets the agent's default expiration. |
void |
setPendingCapacity(int value)
Updates the current maximum for pending messages. |
void |
setPendingTimeout(long value,
TimeUnit unit)
Updates the current maximum amount of time a caller waits for the agent to accept its call. |
void |
setUnhandledExceptionHandler(ExceptionHandler handler)
Changes the agent's handler for unhandled exceptions. |
String |
toString()
Returns the list of interfaces. |
(package private) void |
updateKey(Object oldKey,
Object newKey)
Attempts to update the configuration key. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private final Controller controller
private final AgentLoader loader
newInstance
call and the one returned by
AgentConfig.getAgentLoader()
. This may differ from the loader
used to create the generated proxy and message classes. This can occur
when newInstance
is called with different
AgentLoader
s that have the same ClassLoader
.
Agent.newInstance(AgentLoader, Class[], AgentTasks, Class)
,
AgentConfig.getAgentLoader()
private final List<Class<?>> interfaces
Agent.newInstance(AgentLoader, Class[], AgentTasks, Class)
,
AgentConfig.getInterfaces()
,
Collections.unmodifiableList(List)
private final Class<?> taskType
Agent.newInstance(AgentLoader, Class[], AgentTasks, Class)
,
AgentConfig.getTaskType()
volatile Proxy proxy
newInstance
. From the
caller's perspective, this is "the agent."
There is a circular dependency between the proxy and controller. The
controller is created first. This means we have to initialize the
controller's reference to the proxy later in a non-final field. Since it
is non-final, we are obligated to provide concurrency control. This field
never changes after initialization, so volatile
is
sufficient. JVM memory semantics makes even this overkill with today's
agent implementation, but the agent implementation may change in subtle
ways, and there is no performance concern, so explicit concurrency
control is safer.
Agent.newInstance(AgentLoader, Class[], AgentTasks, Class)
,
CallSite.getAgent()
CallInfo[] calls
calls
array is equal to the number of interface methods
implemented by this agent. This array and its elements are created as
unique new instances for each agent created by
Agent.newInstance
.
AgentConfig.getCallSite(String, Class, Class...)
,
AgentCall.getCallSite()
private HashMap<CallKey,CallInfo> sites
getCallSite
.
AgentConfig.getCallSite(String, Class, Class...)
volatile ExceptionHandler exceptions
org.curjent.agent
.
private static final ExceptionHandler DEFAULT_EXCEPTION_HANDLER
exceptions
private Object key
Agent.getConfig(Object, Object, Object)
private Object data
AgentConfig.setData(Object)
.
Constructor Detail |
---|
Config(Controller controller, AgentLoader loader, Class<?>[] interfaces, Class<?> taskType)
Method Detail |
---|
void init(CallInfo[] calls)
void updateKey(Object oldKey, Object newKey)
ConfigLockedException
- Invalid oldKey
Agent.getConfig(Object, Object, Object)
public AgentTasks getAgentTasks()
getAgentTasks
in interface AgentConfig
AgentConfig.getAgentTasks()
public CallSite getCallSite(String method, Class<?> result, Class<?>... params)
getCallSite
in interface AgentConfig
method
- The name of the method.result
- The method's return type. For methods returning objects,
use the object's class, such as myObject.getClass()
. For
primitives, use the primitive's class, such as int.class
.
For void, use void.class
.params
- The method's parameter types. May be empty or
null
for methods without parameters.AgentConfig.getCallSite(String, Class, Class...)
public int getAcceptedCapacity()
getAcceptedCapacity
in interface AgentConfig
AgentConfig.getPendingCapacity()
,
Capacity
public void setAcceptedCapacity(int value)
setAcceptedCapacity
in interface AgentConfig
AgentConfig.setPendingCapacity(int)
,
Capacity
public int getPendingCapacity()
getPendingCapacity
in interface AgentConfig
AgentConfig.getAcceptedCapacity()
,
AgentConfig.getPendingTimeout()
,
Capacity
public void setPendingCapacity(int value)
setPendingCapacity
in interface AgentConfig
AgentConfig.setAcceptedCapacity(int)
,
AgentConfig.setPendingTimeout(long, TimeUnit)
,
Capacity
public long getPendingTimeout()
getPendingTimeout
in interface AgentConfig
AgentConfig.getPendingTimeoutUnit()
,
AgentConfig.getAcceptedCapacity()
,
Capacity
public TimeUnit getPendingTimeoutUnit()
getPendingCapacity()
.
getPendingTimeoutUnit
in interface AgentConfig
AgentConfig.getPendingTimeout()
,
Capacity
public void setPendingTimeout(long value, TimeUnit unit)
Messages.setPendingTimeout(long, TimeUnit)
.
setPendingTimeout
in interface AgentConfig
AgentConfig.setPendingCapacity(int)
,
Capacity
public long getDeadcheckTimeout()
getDeadcheckTimeout
in interface AgentConfig
public TimeUnit getDeadcheckTimeoutUnit()
getDeadcheckTimeout()
.
getDeadcheckTimeoutUnit
in interface AgentConfig
AgentConfig.getDeadcheckTimeout()
public void setDeadcheckTimeout(long value, TimeUnit unit)
Messages.setDeadcheckTimeout(long, TimeUnit)
.
setDeadcheckTimeout
in interface AgentConfig
AgentConfig.getDeadcheckTimeout()
public Object getData()
getData
in interface AgentConfig
AgentConfig.setData(Object)
public void setData(Object data)
setData
in interface AgentConfig
AgentConfig.getData()
,
CallSite.setData(Object)
,
AgentCall.setData(Object)
public AgentLoader getAgentLoader()
getAgentLoader
in interface AgentConfig
AgentConfig.getAgentLoader()
public List<Class<?>> getInterfaces()
getInterfaces
in interface AgentConfig
AgentConfig.getInterfaces()
public Class<?> getTaskType()
getTaskType
in interface AgentConfig
AgentConfig.getTaskType()
public CallStateListener<?> getCallStateListener()
getCallStateListener
in interface AgentConfig
AgentConfig.getCallStateListener()
public CallStateListener<?> getCallStateListener(CallState state)
getCallStateListener
in interface AgentConfig
AgentConfig.getCallStateListener(CallState)
public void setCallStateListener(CallStateListener<?> listener)
setCallStateListener
in interface AgentConfig
AgentConfig.setCallStateListener(CallStateListener)
public void setCallStateListener(CallState state, CallStateListener<?> listener)
setCallStateListener
in interface AgentConfig
AgentConfig.setCallStateListener(CallState, CallStateListener)
public Executor getExecutor()
getExecutor
in interface AgentConfig
Agent.getDefaultExecutor()
public void setExecutor(Executor executor)
setExecutor
in interface AgentConfig
public ExceptionHandler getUnhandledExceptionHandler()
getUnhandledExceptionHandler
in interface AgentConfig
AgentConfig.getUnhandledExceptionHandler()
public void setUnhandledExceptionHandler(ExceptionHandler handler)
setUnhandledExceptionHandler
in interface AgentConfig
AgentConfig.setUnhandledExceptionHandler(ExceptionHandler)
public long getExpirationTimeout()
getExpirationTimeout
in interface AgentConfig
AgentConfig.getExpirationTimeout()
,
getExpirationTimeoutUnit()
public TimeUnit getExpirationTimeoutUnit()
getExpirationTimeoutUnit
in interface AgentConfig
AgentConfig.getExpirationTimeoutUnit()
,
getExpirationTimeout()
public void setExpirationTimeout(long value, TimeUnit unit)
setExpirationTimeout
in interface AgentConfig
AgentConfig.setExpirationTimeout(long, TimeUnit)
public String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |