org.mule.transport.jcr
Class JcrMessageDispatcher

java.lang.Object
  extended by org.mule.transport.AbstractTransportMessageHandler
      extended by org.mule.transport.AbstractMessageDispatcher
          extended by org.mule.transport.jcr.JcrMessageDispatcher
All Implemented Interfaces:
org.mule.api.lifecycle.Disposable, org.mule.api.lifecycle.Initialisable, org.mule.api.lifecycle.Lifecycle, org.mule.api.lifecycle.LifecycleStateEnabled, org.mule.api.lifecycle.Startable, org.mule.api.lifecycle.Stoppable, org.mule.api.processor.MessageProcessor, org.mule.api.transport.Connectable, org.mule.api.transport.MessageDispatcher

public class JcrMessageDispatcher
extends org.mule.transport.AbstractMessageDispatcher

A dispatcher for writing to a JCR container.

Author:
David Dossot (david@dossot.net)

Field Summary
 
Fields inherited from class org.mule.transport.AbstractMessageDispatcher
defaultOutboundTransformers, defaultResponseTransformers
 
Fields inherited from class org.mule.transport.AbstractTransportMessageHandler
connected, connector, endpoint, lifecycleManager, logger, muleMessageFactory, retryTemplate
 
Fields inherited from interface org.mule.api.transport.MessageDispatcher
RECEIVE_NO_WAIT, RECEIVE_WAIT_INDEFINITELY
 
Fields inherited from interface org.mule.api.lifecycle.Initialisable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Startable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Stoppable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Disposable
PHASE_NAME
 
Constructor Summary
JcrMessageDispatcher(org.mule.api.endpoint.OutboundEndpoint endpoint)
           
 
Method Summary
 void doConnect()
           
 void doDisconnect()
           
 void doDispatch(org.mule.api.MuleEvent event)
           
 void doDispose()
           
 org.mule.api.MuleMessage doSend(org.mule.api.MuleEvent event)
           Sends content to the configured JCR endpoint, using optional event properties to define the target repository item and the node type name to use.
 javax.jcr.Session getSession()
           
 
Methods inherited from class org.mule.transport.AbstractMessageDispatcher
applyOutboundTransformers, applyResponseTransformers, createLifecycleManager, getDispatcherName, getEndpoint, getWorkManager, process, returnResponse, returnResponse
 
Methods inherited from class org.mule.transport.AbstractTransportMessageHandler
activate, connect, createMuleMessage, createMuleMessage, createMuleMessage, createMuleMessageFactory, createNullMuleMessage, disconnect, dispose, disposeAndLogException, doInitialise, doStart, doStop, getConnectEventId, getConnectionDescription, getConnector, getLifecycleState, initialise, initializeMessageFactory, initializeRetryPolicy, isConnected, isDoThreading, isStarted, isStarting, isStopping, passivate, setEndpoint, start, stop, toString, validate, validateConnection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mule.api.transport.MessageDispatcher
activate, createMuleMessage, createMuleMessage, getConnector, passivate, validate
 
Methods inherited from interface org.mule.api.transport.Connectable
connect, disconnect, getConnectionDescription, isConnected, validateConnection
 
Methods inherited from interface org.mule.api.lifecycle.Initialisable
initialise
 
Methods inherited from interface org.mule.api.lifecycle.Startable
start
 
Methods inherited from interface org.mule.api.lifecycle.Stoppable
stop
 
Methods inherited from interface org.mule.api.lifecycle.Disposable
dispose
 
Methods inherited from interface org.mule.api.lifecycle.LifecycleStateEnabled
getLifecycleState
 

Constructor Detail

JcrMessageDispatcher

public JcrMessageDispatcher(org.mule.api.endpoint.OutboundEndpoint endpoint)
Method Detail

getSession

public javax.jcr.Session getSession()

doConnect

public void doConnect()
               throws Exception
Overrides:
doConnect in class org.mule.transport.AbstractTransportMessageHandler
Throws:
Exception

doDisconnect

public void doDisconnect()
                  throws Exception
Overrides:
doDisconnect in class org.mule.transport.AbstractTransportMessageHandler
Throws:
Exception

doDispose

public void doDispose()
Overrides:
doDispose in class org.mule.transport.AbstractTransportMessageHandler

doDispatch

public void doDispatch(org.mule.api.MuleEvent event)
                throws Exception
Specified by:
doDispatch in class org.mule.transport.AbstractMessageDispatcher
Throws:
Exception
See Also:
doSend

doSend

public org.mule.api.MuleMessage doSend(org.mule.api.MuleEvent event)
                                throws Exception

Sends content to the configured JCR endpoint, using optional event properties to define the target repository item and the node type name to use.

Unless the creation of child nodes is forced by an event or endpoint property ( JcrConnector.JCR_ALWAYS_CREATE_CHILD_NODE), the target item where content will be stored will determined the same way as explained in the doReceive method.

If an existing target item is found and is a node, the appropriate NodeTypeHandler will be used to convert the MuleMessage payload into valid JCR content (nodes and properties).

If an existing target item is found and is a property, the MuleMessage payload will be directly written to it, using a simple conversion mechanism. Note that if the payload is a Collection, the property will be multi-valued.

If no existing target item is found or if the creation of a new node is forced (see first paragraph), a new node will be created, under the absolute path defined by the endpoint URI, with a content extracted from the MuleMessage payload and stored according to the type defined in the event or connector property ( JcrConnector.JCR_NODE_TYPE_NAME ). If the endpoint URI points to a property and not a node, an exception will be raised.

Specified by:
doSend in class org.mule.transport.AbstractMessageDispatcher
Returns:
the source MuleMessage.
Throws:
Exception
See Also:
Property names constants


Copyright © 2011. All Rights Reserved.