org.apache.servicemix.bean
Class BeanEndpoint

java.lang.Object
  extended by org.apache.servicemix.common.endpoints.AbstractEndpoint
      extended by org.apache.servicemix.common.endpoints.SimpleEndpoint
          extended by org.apache.servicemix.common.endpoints.ProviderEndpoint
              extended by org.apache.servicemix.bean.BeanEndpoint
All Implemented Interfaces:
Endpoint, org.springframework.context.ApplicationContextAware

public class BeanEndpoint
extends ProviderEndpoint
implements org.springframework.context.ApplicationContextAware

Represents a bean endpoint which consists of a together with a MethodInvocationStrategy so that JBI message exchanges can be invoked on the bean.

Version:
$Revision: $

Nested Class Summary
protected  class BeanEndpoint.PojoChannel
           
protected  class BeanEndpoint.PojoContext
           
 
Field Summary
static java.lang.String CORRELATION_ID
          Property name for the correlation id that is being set on exchanges by the BeanEndpoint
 
Fields inherited from class org.apache.servicemix.common.endpoints.SimpleEndpoint
logger
 
Fields inherited from class org.apache.servicemix.common.endpoints.AbstractEndpoint
definition, description, endpoint, interfaceName, service, serviceUnit
 
Constructor Summary
BeanEndpoint()
           
BeanEndpoint(BeanComponent component, javax.jbi.servicedesc.ServiceEndpoint serviceEndpoint)
           
 
Method Summary
protected  void checkEndOfRequest(Request req)
          Checks if the request has ended.
protected  java.lang.Object createBean()
           
protected  MethodInvocationStrategy createMethodInvocationStrategy()
           
protected  void evaluateCallbacks(Request req)
           
 org.springframework.context.ApplicationContext getApplicationContext()
           
 java.lang.Object getBean()
           
 java.lang.String getBeanClassName()
           
 BeanInfo getBeanInfo()
           
 java.lang.String getBeanName()
           
 java.lang.Class<?> getBeanType()
           
protected  java.lang.Object getCorrelation(javax.jbi.messaging.MessageExchange exchange)
           
 org.apache.servicemix.expression.Expression getCorrelationExpression()
           
 MethodInvocationStrategy getMethodInvocationStrategy()
           
protected  Request getOrCreateCurrentRequest(javax.jbi.messaging.MessageExchange exchange)
           
protected  Request getRequest(javax.jbi.messaging.MessageExchange exchange)
           
protected  void injectBean(java.lang.Object target)
          A strategy method to allow implementations to perform some custom JBI based injection of the POJO
protected  void onConsumerExchange(javax.jbi.messaging.MessageExchange exchange)
           
protected  void onProviderExchange(javax.jbi.messaging.MessageExchange exchange)
           
protected  boolean onProviderExchangeDone(javax.jbi.messaging.MessageExchange exchange)
           
 void process(javax.jbi.messaging.MessageExchange exchange)
           
protected  void send(javax.jbi.messaging.MessageExchange me)
           
 java.util.concurrent.Future<javax.jbi.messaging.NormalizedMessage> send(java.lang.String uri, javax.jbi.messaging.NormalizedMessage message)
          Used by POJOs acting as a consumer
 void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
          Set the Spring ApplicationContext where the bean can be found.
 void setBean(java.lang.Object bean)
          Set the bean to be used for handling exchanges
 void setBeanClassName(java.lang.String beanClassName)
          Set the bean class name to be used for handling exchanges.
 void setBeanInfo(BeanInfo beanInfo)
          Set a custom bean info object to define the bean to be used for handling exchanges
 void setBeanName(java.lang.String beanName)
          Set the name of the bean in the application context to be used for handling exchanges
 void setBeanType(java.lang.Class<?> beanType)
          Set the bean class to be used for handling exchanges.
 void setCorrelationExpression(org.apache.servicemix.expression.Expression correlationExpression)
          Set a custom expression to use for correlating exchanges into a single request handled by the same bean instance.
 void setMethodInvocationStrategy(MethodInvocationStrategy methodInvocationStrategy)
          Set a custom invocation strategy to define how the bean is being invoked.
 void start()
           
 void stop()
           
 
Methods inherited from class org.apache.servicemix.common.endpoints.ProviderEndpoint
activate, deactivate, getRole, processInOnly, processInOut
 
Methods inherited from class org.apache.servicemix.common.endpoints.SimpleEndpoint
done, fail, getChannel, getContext, getExchangeFactory, sendSync
 
Methods inherited from class org.apache.servicemix.common.endpoints.AbstractEndpoint
getDefinition, getDescription, getEndpoint, getInterfaceName, getKey, getService, getServiceUnit, isExchangeOkay, prepareExchange, setDefinition, setDescription, setEndpoint, setInterfaceName, setService, setServiceUnit, toString, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CORRELATION_ID

public static final java.lang.String CORRELATION_ID
Property name for the correlation id that is being set on exchanges by the BeanEndpoint

Constructor Detail

BeanEndpoint

public BeanEndpoint()

BeanEndpoint

public BeanEndpoint(BeanComponent component,
                    javax.jbi.servicedesc.ServiceEndpoint serviceEndpoint)
Method Detail

start

public void start()
           throws java.lang.Exception
Specified by:
start in interface Endpoint
Overrides:
start in class SimpleEndpoint
Throws:
java.lang.Exception

stop

public void stop()
          throws java.lang.Exception
Specified by:
stop in interface Endpoint
Overrides:
stop in class SimpleEndpoint
Throws:
java.lang.Exception

getApplicationContext

public org.springframework.context.ApplicationContext getApplicationContext()

setApplicationContext

public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
                           throws org.springframework.beans.BeansException
Set the Spring ApplicationContext where the bean can be found. Defaults to the context defined in xbean.xml

Specified by:
setApplicationContext in interface org.springframework.context.ApplicationContextAware
Parameters:
applicationContext -
Throws:
org.springframework.beans.BeansException

getBeanName

public java.lang.String getBeanName()

setBeanName

public void setBeanName(java.lang.String beanName)
Set the name of the bean in the application context to be used for handling exchanges

Parameters:
beanName -

getBean

public java.lang.Object getBean()

setBean

public void setBean(java.lang.Object bean)
Set the bean to be used for handling exchanges

Parameters:
bean -

getBeanType

public java.lang.Class<?> getBeanType()
Returns:
the beanType

setBeanType

public void setBeanType(java.lang.Class<?> beanType)
Set the bean class to be used for handling exchanges. A new instance will be created on the fly for every exchange.

Parameters:
beanType - the beanType to set

getBeanClassName

public java.lang.String getBeanClassName()
Returns:
the beanClassName

setBeanClassName

public void setBeanClassName(java.lang.String beanClassName)
Set the bean class name to be used for handling exchanges. A new instance will be created on the fly for every exchange.

Parameters:
beanClassName - the beanClassName to set

getBeanInfo

public BeanInfo getBeanInfo()

setBeanInfo

public void setBeanInfo(BeanInfo beanInfo)
Set a custom bean info object to define the bean to be used for handling exchanges

Parameters:
beanInfo -

getMethodInvocationStrategy

public MethodInvocationStrategy getMethodInvocationStrategy()

setMethodInvocationStrategy

public void setMethodInvocationStrategy(MethodInvocationStrategy methodInvocationStrategy)
Set a custom invocation strategy to define how the bean is being invoked. The default implementation takes some additional parameter annotations into account.

Parameters:
methodInvocationStrategy - the strategy

process

public void process(javax.jbi.messaging.MessageExchange exchange)
             throws java.lang.Exception
Specified by:
process in interface Endpoint
Overrides:
process in class ProviderEndpoint
Throws:
java.lang.Exception

onProviderExchange

protected void onProviderExchange(javax.jbi.messaging.MessageExchange exchange)
                           throws java.lang.Exception
Throws:
java.lang.Exception

onProviderExchangeDone

protected boolean onProviderExchangeDone(javax.jbi.messaging.MessageExchange exchange)

getOrCreateCurrentRequest

protected Request getOrCreateCurrentRequest(javax.jbi.messaging.MessageExchange exchange)
                                     throws java.lang.ClassNotFoundException,
                                            java.lang.InstantiationException,
                                            java.lang.IllegalAccessException,
                                            javax.jbi.messaging.MessagingException
Throws:
java.lang.ClassNotFoundException
java.lang.InstantiationException
java.lang.IllegalAccessException
javax.jbi.messaging.MessagingException

getRequest

protected Request getRequest(javax.jbi.messaging.MessageExchange exchange)
                      throws javax.jbi.messaging.MessagingException
Throws:
javax.jbi.messaging.MessagingException

onConsumerExchange

protected void onConsumerExchange(javax.jbi.messaging.MessageExchange exchange)
                           throws java.lang.Exception
Throws:
java.lang.Exception

getCorrelation

protected java.lang.Object getCorrelation(javax.jbi.messaging.MessageExchange exchange)
                                   throws javax.jbi.messaging.MessagingException
Throws:
javax.jbi.messaging.MessagingException

createBean

protected java.lang.Object createBean()
                               throws java.lang.ClassNotFoundException,
                                      java.lang.InstantiationException,
                                      java.lang.IllegalAccessException
Throws:
java.lang.ClassNotFoundException
java.lang.InstantiationException
java.lang.IllegalAccessException

createMethodInvocationStrategy

protected MethodInvocationStrategy createMethodInvocationStrategy()

injectBean

protected void injectBean(java.lang.Object target)
A strategy method to allow implementations to perform some custom JBI based injection of the POJO

Parameters:
target - the bean to be injected

evaluateCallbacks

protected void evaluateCallbacks(Request req)

send

public java.util.concurrent.Future<javax.jbi.messaging.NormalizedMessage> send(java.lang.String uri,
                                                                               javax.jbi.messaging.NormalizedMessage message)
Used by POJOs acting as a consumer

Parameters:
uri -
message -
Returns:

send

protected void send(javax.jbi.messaging.MessageExchange me)
             throws javax.jbi.messaging.MessagingException
Overrides:
send in class SimpleEndpoint
Throws:
javax.jbi.messaging.MessagingException

checkEndOfRequest

protected void checkEndOfRequest(Request req)
Checks if the request has ended. If the request has ended,

Parameters:
req - the Request instance to check

getCorrelationExpression

public org.apache.servicemix.expression.Expression getCorrelationExpression()
Returns:
the correlationExpression

setCorrelationExpression

public void setCorrelationExpression(org.apache.servicemix.expression.Expression correlationExpression)
Set a custom expression to use for correlating exchanges into a single request handled by the same bean instance. The default expression uses a correlation ID set on the exchange properties.

Parameters:
correlationExpression - the correlationExpression to set


Copyright © 2005-2015 FuseSource. All Rights Reserved.