org.axonframework.commandhandling.gateway
Class CommandGatewayFactoryBean<T>

java.lang.Object
  extended by org.axonframework.commandhandling.gateway.CommandGatewayFactoryBean<T>
Type Parameters:
T - The type of gateway to be created by this factory bean. Note that the correct interface must also be set using setGatewayInterface(Class). Failure to do so may result in class cast exceptions.
All Implemented Interfaces:
org.springframework.beans.factory.FactoryBean<T>, org.springframework.beans.factory.InitializingBean

public class CommandGatewayFactoryBean<T>
extends Object
implements org.springframework.beans.factory.FactoryBean<T>, org.springframework.beans.factory.InitializingBean

FactoryBean that creates a gateway instance for any given (compatible) interface. If no explicit interface is provided, the CommandGateway interface is assumed.

For details about the structure of compatible interfaces, see GatewayProxyFactory.

Since:
2.0
Author:
Allard Buijze
See Also:
GatewayProxyFactory

Constructor Summary
CommandGatewayFactoryBean()
           
 
Method Summary
 void afterPropertiesSet()
           
 T getObject()
           
 Class<?> getObjectType()
           
 boolean isSingleton()
           
 void setCommandBus(CommandBus commandBus)
          Sets the command bus on which the Gateway must dispatch commands.
 void setCommandCallbacks(List<CommandCallback<?>> commandCallbacks)
          Registers the commandCallbacks, which are invoked for each sent command, unless Axon is able to detect that the result of the command does not match the type accepted by that callback.
 void setCommandDispatchInterceptors(CommandDispatchInterceptor... commandDispatchInterceptors)
          Sets the interceptors that should be invoked before a command is dispatched the the Command Bus.
 void setCommandDispatchInterceptors(List<CommandDispatchInterceptor> commandDispatchInterceptors)
          Sets the interceptors that should be invoked before a command is dispatched the the Command Bus.
 void setGatewayInterface(Class<T> gatewayInterface)
          Sets the interface that describes the gateway instance to describe.
 void setRetryScheduler(RetryScheduler retryScheduler)
          Sets the RetryScheduler that will be invoked when a command fails execution.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandGatewayFactoryBean

public CommandGatewayFactoryBean()
Method Detail

getObject

public T getObject()
            throws Exception
Specified by:
getObject in interface org.springframework.beans.factory.FactoryBean<T>
Throws:
Exception

getObjectType

public Class<?> getObjectType()
Specified by:
getObjectType in interface org.springframework.beans.factory.FactoryBean<T>

isSingleton

public boolean isSingleton()
Specified by:
isSingleton in interface org.springframework.beans.factory.FactoryBean<T>

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
Exception

setCommandBus

public void setCommandBus(CommandBus commandBus)
Sets the command bus on which the Gateway must dispatch commands. This property is required.

Parameters:
commandBus - the command bus on which the Gateway must dispatch commands

setRetryScheduler

public void setRetryScheduler(RetryScheduler retryScheduler)
Sets the RetryScheduler that will be invoked when a command fails execution. If no scheduler is provided, commands will report the failure immediately.

Parameters:
retryScheduler - the RetryScheduler that will be invoked when a command fails execution

setGatewayInterface

public void setGatewayInterface(Class<T> gatewayInterface)
Sets the interface that describes the gateway instance to describe. If no interface is provided, it defaults to CommandGateway.

Parameters:
gatewayInterface - The interface describing the gateway
Throws:
IllegalArgumentException - if the given gatewayInterface is null or not an interface.

setCommandDispatchInterceptors

public void setCommandDispatchInterceptors(CommandDispatchInterceptor... commandDispatchInterceptors)
Sets the interceptors that should be invoked before a command is dispatched the the Command Bus.

Note that these interceptors will be specific to this Gateway instance. Messages dispatched through other gateways or directly to the command bus will not pass through these interceptors.

Parameters:
commandDispatchInterceptors - the interceptors that should be invoked before a command is dispatched the the Command Bus

setCommandDispatchInterceptors

public void setCommandDispatchInterceptors(List<CommandDispatchInterceptor> commandDispatchInterceptors)
Sets the interceptors that should be invoked before a command is dispatched the the Command Bus.

Note that these interceptors will be specific to this Gateway instance. Messages dispatched through other gateways or directly to the command bus will not pass through these interceptors.

Parameters:
commandDispatchInterceptors - the interceptors that should be invoked before a command is dispatched the the Command Bus

setCommandCallbacks

public void setCommandCallbacks(List<CommandCallback<?>> commandCallbacks)
Registers the commandCallbacks, which are invoked for each sent command, unless Axon is able to detect that the result of the command does not match the type accepted by that callback.

Axon will check the signature of the onSuccess() method and only invoke the callback if the actual result of the command is an instance of that type. If Axon is unable to detect the type, the callback is always invoked, potentially causing ClassCastException.

Parameters:
commandCallbacks - The callbacks to register


Copyright © 2010-2016. All Rights Reserved.