org.apache.servicemix.components.util
Class PojoSupport

java.lang.Object
  extended by org.apache.servicemix.jbi.management.BaseLifeCycle
      extended by org.apache.servicemix.components.util.PojoSupport
All Implemented Interfaces:
javax.jbi.component.ComponentLifeCycle, javax.jbi.management.LifeCycleMBean, MBeanInfoProvider
Direct Known Subclasses:
ComponentSupport, ReceiverPojo, SenderPojo

public abstract class PojoSupport
extends BaseLifeCycle
implements javax.jbi.component.ComponentLifeCycle

A useful base class for a POJO based JBI component which contains most of the basic plumbing

Version:
$Revision: 2153 $

Field Summary
protected  Log logger
           
 
Fields inherited from class org.apache.servicemix.jbi.management.BaseLifeCycle
currentState, INITIALIZED, listener
 
Fields inherited from interface javax.jbi.management.LifeCycleMBean
SHUTDOWN, STARTED, STOPPED, UNKNOWN
 
Constructor Summary
protected PojoSupport()
           
protected PojoSupport(QName service, String endpoint)
           
 
Method Summary
 void answer(javax.jbi.messaging.MessageExchange exchange, javax.jbi.messaging.NormalizedMessage answer)
          A helper method to indicate that the message exchange should be continued with the given response and send the message on the delivery channel.
 void done(javax.jbi.messaging.MessageExchange exchange)
          A helper method to indicate that the message exchange is complete which will set the status to ExchangeStatus.DONE and send the message on the delivery channel.
 void fail(javax.jbi.messaging.MessageExchange exchange, Exception error)
          A helper method which fails and completes the given exchange with the specified error
 void fail(javax.jbi.messaging.MessageExchange exchange, javax.jbi.messaging.Fault fault)
          A helper method which fails and completes the given exchange with the specified fault
 Object getBody(javax.jbi.messaging.NormalizedMessage message)
          A helper method to return the body of the message as a POJO which could be a bean or some DOMish model of the body.
 javax.jbi.component.ComponentContext getContext()
           
 javax.jbi.messaging.DeliveryChannel getDeliveryChannel()
           
 String getDescription()
          Get the description
 String getEndpoint()
           
 javax.jbi.messaging.MessageExchangeFactory getExchangeFactory()
          Provide access to the default message exchange exchangeFactory, lazily creating one.
 ObjectName getExtensionMBeanName()
           
 QName getService()
           
protected  void init()
          A helper method to allow a component to initialise prior to the endpoint being activated but after the component context has been configured.
 void init(javax.jbi.component.ComponentContext cc)
          Called when the Component is initialized
protected  boolean isInAndOut(javax.jbi.messaging.MessageExchange exchange)
          A helper method which will return true if the exchange is capable of both In and Out such as InOut, InOptionalOut etc.
 void send(javax.jbi.messaging.MessageExchange exchange)
           
 boolean sendSync(javax.jbi.messaging.MessageExchange exchange)
           
 boolean sendSync(javax.jbi.messaging.MessageExchange exchange, long timeMillis)
           
 void setBody(javax.jbi.messaging.NormalizedMessage message, Object body)
          Sets the body of the message as a POJO
 void setEndpoint(String endpoint)
           
 void setExtensionMBeanName(ObjectName extensionMBeanName)
           
 void setService(QName service)
           
 void shutDown()
          Shut down the item.
 
Methods inherited from class org.apache.servicemix.jbi.management.BaseLifeCycle
firePropertyChanged, getAttributeInfos, getCurrentState, getName, getObjectToManage, getOperationInfos, getSubType, getType, isInitialized, isShutDown, isStarted, isStopped, isUnknown, setCurrentState, setPropertyChangeListener, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.jbi.component.ComponentLifeCycle
start, stop
 

Field Detail

logger

protected Log logger
Constructor Detail

PojoSupport

protected PojoSupport()

PojoSupport

protected PojoSupport(QName service,
                      String endpoint)
Method Detail

getDescription

public String getDescription()
Get the description

Specified by:
getDescription in interface MBeanInfoProvider
Returns:
the description

init

public void init(javax.jbi.component.ComponentContext cc)
          throws javax.jbi.JBIException
Called when the Component is initialized

Specified by:
init in interface javax.jbi.component.ComponentLifeCycle
Parameters:
cc -
Throws:
javax.jbi.JBIException

shutDown

public void shutDown()
              throws javax.jbi.JBIException
Shut down the item. The releases resources, preparing to uninstall

Specified by:
shutDown in interface javax.jbi.component.ComponentLifeCycle
Specified by:
shutDown in interface javax.jbi.management.LifeCycleMBean
Overrides:
shutDown in class BaseLifeCycle
Throws:
javax.jbi.JBIException - if the item fails to shut down.

getBody

public Object getBody(javax.jbi.messaging.NormalizedMessage message)
               throws javax.jbi.messaging.MessagingException
A helper method to return the body of the message as a POJO which could be a bean or some DOMish model of the body.

Parameters:
message - the message on which to extract the body
Returns:
the body of the message as a POJO or DOM object
Throws:
javax.jbi.messaging.MessagingException

setBody

public void setBody(javax.jbi.messaging.NormalizedMessage message,
                    Object body)
             throws javax.jbi.messaging.MessagingException
Sets the body of the message as a POJO

Parameters:
message - the message on which to set the body
body - the POJO or DOMish model to set
Throws:
javax.jbi.messaging.MessagingException

getExtensionMBeanName

public ObjectName getExtensionMBeanName()
Specified by:
getExtensionMBeanName in interface javax.jbi.component.ComponentLifeCycle

setExtensionMBeanName

public void setExtensionMBeanName(ObjectName extensionMBeanName)

getContext

public javax.jbi.component.ComponentContext getContext()

getService

public QName getService()

setService

public void setService(QName service)

getEndpoint

public String getEndpoint()

setEndpoint

public void setEndpoint(String endpoint)

getExchangeFactory

public javax.jbi.messaging.MessageExchangeFactory getExchangeFactory()
                                                              throws javax.jbi.messaging.MessagingException
Provide access to the default message exchange exchangeFactory, lazily creating one.

Throws:
javax.jbi.messaging.MessagingException

getDeliveryChannel

public javax.jbi.messaging.DeliveryChannel getDeliveryChannel()
                                                       throws javax.jbi.messaging.MessagingException
Throws:
javax.jbi.messaging.MessagingException

init

protected void init()
             throws javax.jbi.JBIException
A helper method to allow a component to initialise prior to the endpoint being activated but after the component context has been configured.

Overrides:
init in class BaseLifeCycle
Throws:
javax.jbi.JBIException

done

public void done(javax.jbi.messaging.MessageExchange exchange)
          throws javax.jbi.messaging.MessagingException
A helper method to indicate that the message exchange is complete which will set the status to ExchangeStatus.DONE and send the message on the delivery channel.

Parameters:
exchange -
Throws:
javax.jbi.messaging.MessagingException

send

public void send(javax.jbi.messaging.MessageExchange exchange)
          throws javax.jbi.messaging.MessagingException
Throws:
javax.jbi.messaging.MessagingException

sendSync

public boolean sendSync(javax.jbi.messaging.MessageExchange exchange)
                 throws javax.jbi.messaging.MessagingException
Throws:
javax.jbi.messaging.MessagingException

sendSync

public boolean sendSync(javax.jbi.messaging.MessageExchange exchange,
                        long timeMillis)
                 throws javax.jbi.messaging.MessagingException
Throws:
javax.jbi.messaging.MessagingException

answer

public void answer(javax.jbi.messaging.MessageExchange exchange,
                   javax.jbi.messaging.NormalizedMessage answer)
            throws javax.jbi.messaging.MessagingException
A helper method to indicate that the message exchange should be continued with the given response and send the message on the delivery channel.

Parameters:
exchange -
Throws:
javax.jbi.messaging.MessagingException

fail

public void fail(javax.jbi.messaging.MessageExchange exchange,
                 javax.jbi.messaging.Fault fault)
          throws javax.jbi.messaging.MessagingException
A helper method which fails and completes the given exchange with the specified fault

Throws:
javax.jbi.messaging.MessagingException

fail

public void fail(javax.jbi.messaging.MessageExchange exchange,
                 Exception error)
          throws javax.jbi.messaging.MessagingException
A helper method which fails and completes the given exchange with the specified error

Throws:
javax.jbi.messaging.MessagingException

isInAndOut

protected boolean isInAndOut(javax.jbi.messaging.MessageExchange exchange)
A helper method which will return true if the exchange is capable of both In and Out such as InOut, InOptionalOut etc.

Parameters:
exchange -
Returns:
true if the exchange can handle both input and output


Copyright © 2005-2010 The Apache Software Foundation. All Rights Reserved.