Package org.apache.mina.statemachine
Class StateMachineProxyBuilder
- java.lang.Object
-
- org.apache.mina.statemachine.StateMachineProxyBuilder
-
public class StateMachineProxyBuilder extends java.lang.ObjectUsed to create proxies which will forward all method calls on them to aStateMachine.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classStateMachineProxyBuilder.MethodInvocationHandler
-
Field Summary
Fields Modifier and Type Field Description private StateContextLookupcontextLookupprivate java.lang.ClassLoaderdefaultClprivate static java.lang.Object[]EMPTY_ARGUMENTSprivate EventFactoryeventFactoryprivate booleanignoreStateContextLookupFailureprivate booleanignoreUnhandledEventsprivate EventArgumentsInterceptorinterceptorprivate static org.slf4j.LoggerLOGGERprivate java.lang.Stringname
-
Constructor Summary
Constructors Constructor Description StateMachineProxyBuilder()Creates a new StateMachineProxyBuilder instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectcreate(java.lang.Class<?>[] ifaces, StateMachine sm)Creates a proxy for the specified interfaces and which uses the specifiedStateMachine.<T> Tcreate(java.lang.Class<T> iface, StateMachine sm)Creates a proxy for the specified interface and which uses the specifiedStateMachine.StateMachineProxyBuildersetClassLoader(java.lang.ClassLoader cl)Sets the class loader to use for instantiating proxies.StateMachineProxyBuildersetEventArgumentsInterceptor(EventArgumentsInterceptor interceptor)Sets theEventArgumentsInterceptorto be used.StateMachineProxyBuildersetEventFactory(EventFactory eventFactory)Sets theEventFactoryto be used.StateMachineProxyBuildersetIgnoreStateContextLookupFailure(boolean b)Sets whether the failure to lookup aStateContextcorresponding to a method call on the proxy produced by this builder will raise an exception or be silently ignored.StateMachineProxyBuildersetIgnoreUnhandledEvents(boolean b)Sets whether events which have no handler in the current state will raise an exception or be silently ignored.StateMachineProxyBuildersetName(java.lang.String name)Sets the name of the proxy created by this builder.StateMachineProxyBuildersetStateContextLookup(StateContextLookup contextLookup)Sets theStateContextLookupto be used.
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
EMPTY_ARGUMENTS
private static final java.lang.Object[] EMPTY_ARGUMENTS
-
contextLookup
private StateContextLookup contextLookup
-
eventFactory
private EventFactory eventFactory
-
interceptor
private EventArgumentsInterceptor interceptor
-
ignoreUnhandledEvents
private boolean ignoreUnhandledEvents
-
ignoreStateContextLookupFailure
private boolean ignoreStateContextLookupFailure
-
name
private java.lang.String name
-
defaultCl
private java.lang.ClassLoader defaultCl
-
-
Method Detail
-
setName
public StateMachineProxyBuilder setName(java.lang.String name)
Sets the name of the proxy created by this builder. This will be used by the proxiestoString()method. If not specified a default auto generated name will be used.- Parameters:
name- the name.- Returns:
- this
StateMachineProxyBuilderfor method chaining.
-
setStateContextLookup
public StateMachineProxyBuilder setStateContextLookup(StateContextLookup contextLookup)
Sets theStateContextLookupto be used. The default is to use aSingletonStateContextLookup.- Parameters:
contextLookup- theStateContextLookupto use.- Returns:
- this
StateMachineProxyBuilderfor method chaining.
-
setEventFactory
public StateMachineProxyBuilder setEventFactory(EventFactory eventFactory)
Sets theEventFactoryto be used. The default is to use aDefaultEventFactory.- Parameters:
eventFactory- theEventFactoryto use.- Returns:
- this
StateMachineProxyBuilderfor method chaining.
-
setEventArgumentsInterceptor
public StateMachineProxyBuilder setEventArgumentsInterceptor(EventArgumentsInterceptor interceptor)
Sets theEventArgumentsInterceptorto be used. By default noEventArgumentsInterceptorwill be used.- Parameters:
interceptor- theEventArgumentsInterceptorto use.- Returns:
- this
StateMachineProxyBuilderfor method chaining.
-
setIgnoreUnhandledEvents
public StateMachineProxyBuilder setIgnoreUnhandledEvents(boolean b)
Sets whether events which have no handler in the current state will raise an exception or be silently ignored. The default is to raise an exception.- Parameters:
b-trueto ignore context lookup failures.- Returns:
- this
StateMachineProxyBuilderfor method chaining.
-
setIgnoreStateContextLookupFailure
public StateMachineProxyBuilder setIgnoreStateContextLookupFailure(boolean b)
Sets whether the failure to lookup aStateContextcorresponding to a method call on the proxy produced by this builder will raise an exception or be silently ignored. The default is to raise an exception.- Parameters:
b-trueto ignore context lookup failures.- Returns:
- this
StateMachineProxyBuilderfor method chaining.
-
setClassLoader
public StateMachineProxyBuilder setClassLoader(java.lang.ClassLoader cl)
Sets the class loader to use for instantiating proxies. The default is to use the current threads contextClassLoaderas returned byThread.getContextClassLoader().- Parameters:
cl- the class loader- Returns:
- this
StateMachineProxyBuilderfor method chaining.
-
create
public <T> T create(java.lang.Class<T> iface, StateMachine sm)Creates a proxy for the specified interface and which uses the specifiedStateMachine.- Type Parameters:
T- The specified interface type- Parameters:
iface- the interface the proxy will implement.sm- theStateMachinewhich will receive the events generated by the method calls on the proxy.- Returns:
- the proxy object.
-
create
public java.lang.Object create(java.lang.Class<?>[] ifaces, StateMachine sm)Creates a proxy for the specified interfaces and which uses the specifiedStateMachine.- Parameters:
ifaces- the interfaces the proxy will implement.sm- theStateMachinewhich will receive the events generated by the method calls on the proxy.- Returns:
- the proxy object.
-
-