org.apache.mina.statemachine
Class StateMachineProxyBuilder

java.lang.Object
  extended by org.apache.mina.statemachine.StateMachineProxyBuilder

public class StateMachineProxyBuilder
extends Object

Used to create proxies which will forward all method calls on them to a StateMachine.

Version:
$Rev: 664321 $, $Date: 2008-06-07 13:19:55 +0200 (sam, 07 jun 2008) $
Author:
The Apache MINA Project (dev@mina.apache.org)

Constructor Summary
StateMachineProxyBuilder()
           
 
Method Summary
 Object create(Class<?>[] ifaces, StateMachine sm)
          Creates a proxy for the specified interfaces and which uses the specified StateMachine.
<T> T
create(Class<T> iface, StateMachine sm)
          Creates a proxy for the specified interface and which uses the specified StateMachine.
 StateMachineProxyBuilder setClassLoader(ClassLoader cl)
          Sets the class loader to use for instantiating proxies.
 StateMachineProxyBuilder setEventArgumentsInterceptor(EventArgumentsInterceptor interceptor)
          Sets the EventArgumentsInterceptor to be used.
 StateMachineProxyBuilder setEventFactory(EventFactory eventFactory)
          Sets the EventFactory to be used.
 StateMachineProxyBuilder setIgnoreStateContextLookupFailure(boolean b)
          Sets whether the failure to lookup a StateContext corresponding to a method call on the proxy produced by this builder will raise an exception or be silently ignored.
 StateMachineProxyBuilder setIgnoreUnhandledEvents(boolean b)
          Sets whether events which have no handler in the current state will raise an exception or be silently ignored.
 StateMachineProxyBuilder setName(String name)
          Sets the name of the proxy created by this builder.
 StateMachineProxyBuilder setStateContextLookup(StateContextLookup contextLookup)
          Sets the StateContextLookup to be used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StateMachineProxyBuilder

public StateMachineProxyBuilder()
Method Detail

setName

public StateMachineProxyBuilder setName(String name)
Sets the name of the proxy created by this builder. This will be used by the proxies toString() method. If not specified a default auto generated name will be used.

Parameters:
name - the name.
Returns:
this StateMachineProxyBuilder for method chaining.

setStateContextLookup

public StateMachineProxyBuilder setStateContextLookup(StateContextLookup contextLookup)
Sets the StateContextLookup to be used. The default is to use a SingletonStateContextLookup.

Parameters:
contextLookup - the StateContextLookup to use.
Returns:
this StateMachineProxyBuilder for method chaining.

setEventFactory

public StateMachineProxyBuilder setEventFactory(EventFactory eventFactory)
Sets the EventFactory to be used. The default is to use a DefaultEventFactory.

Parameters:
eventFactory - the EventFactory to use.
Returns:
this StateMachineProxyBuilder for method chaining.

setEventArgumentsInterceptor

public StateMachineProxyBuilder setEventArgumentsInterceptor(EventArgumentsInterceptor interceptor)
Sets the EventArgumentsInterceptor to be used. By default no EventArgumentsInterceptor will be used.

Parameters:
interceptor - the EventArgumentsInterceptor to use.
Returns:
this StateMachineProxyBuilder for 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 - true to ignore context lookup failures.
Returns:
this StateMachineProxyBuilder for method chaining.

setIgnoreStateContextLookupFailure

public StateMachineProxyBuilder setIgnoreStateContextLookupFailure(boolean b)
Sets whether the failure to lookup a StateContext corresponding 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 - true to ignore context lookup failures.
Returns:
this StateMachineProxyBuilder for method chaining.

setClassLoader

public StateMachineProxyBuilder setClassLoader(ClassLoader cl)
Sets the class loader to use for instantiating proxies. The default is to use the current threads context ClassLoader as returned by Thread.getContextClassLoader().

Parameters:
cl - the class loader
Returns:
this StateMachineProxyBuilder for method chaining.

create

public <T> T create(Class<T> iface,
                    StateMachine sm)
Creates a proxy for the specified interface and which uses the specified StateMachine.

Parameters:
iface - the interface the proxy will implement.
sm - the StateMachine which will receive the events generated by the method calls on the proxy.
Returns:
the proxy object.

create

public Object create(Class<?>[] ifaces,
                     StateMachine sm)
Creates a proxy for the specified interfaces and which uses the specified StateMachine.

Parameters:
ifaces - the interfaces the proxy will implement.
sm - the StateMachine which will receive the events generated by the method calls on the proxy.
Returns:
the proxy object.


Copyright © 2004-2008 Apache MINA Project. All Rights Reserved.