org.apache.servicemix.nmr.core
Class ChannelImpl

java.lang.Object
  extended by org.apache.servicemix.nmr.core.ChannelImpl
All Implemented Interfaces:
Channel, InternalChannel
Direct Known Subclasses:
ClientChannel

public class ChannelImpl
extends Object
implements InternalChannel

The Channel implementation. The channel uses an Executor (usually a thread pool) to delegate task executions to.

Since:
4.0
Version:
$Revision: $

Constructor Summary
ChannelImpl(InternalEndpoint endpoint, org.apache.servicemix.executors.Executor executor, NMR nmr)
           
 
Method Summary
 void close()
          Closes the channel, freeing up any resources (like sockets, threads etc).
 Exchange createExchange(Pattern pattern)
          Creates a new exchange.
 void deliver(InternalExchange exchange)
          Deliver an exchange to the endpoint using this channel
protected  void dispatch(InternalExchange exchange)
          Dispatch the exchange to the NMR
 InternalEndpoint getEndpoint()
          Access to the endpoint
protected  org.apache.servicemix.executors.Executor getExecutor()
          Provide access to the underlying Executor
 NMR getNMR()
          Access to the bus
protected  void handleFailure(InternalExchange exchange, RuntimeException e, boolean dispatch)
           
 boolean isRunAsSubject()
          Will the endpoint code be invoked on behalf of the 'in' message subject?
 boolean isShouldRunSynchronously()
           
protected  void process(InternalExchange exchange)
          Processes the exchange.
 void send(Exchange exchange)
          An asynchronous invocation of the service
 boolean sendSync(Exchange exchange)
          Synchronously send the exchange, blocking until the exchange is returned.
 boolean sendSync(Exchange exchange, long timeout)
          Synchronously send the exchange
 void setRunAsSubject(boolean runAsSubject)
          Configure whether or not the endpoint will be invoked on behalf of the subject found on the in message or not.
 void setShouldRunSynchronously(boolean shouldRunSynchronously)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChannelImpl

public ChannelImpl(InternalEndpoint endpoint,
                   org.apache.servicemix.executors.Executor executor,
                   NMR nmr)
Method Detail

isShouldRunSynchronously

public boolean isShouldRunSynchronously()

setShouldRunSynchronously

public void setShouldRunSynchronously(boolean shouldRunSynchronously)

isRunAsSubject

public boolean isRunAsSubject()
Will the endpoint code be invoked on behalf of the 'in' message subject?


setRunAsSubject

public void setRunAsSubject(boolean runAsSubject)
Configure whether or not the endpoint will be invoked on behalf of the subject found on the in message or not. Defaults to false.

Parameters:
runAsSubject -

getNMR

public NMR getNMR()
Access to the bus

Specified by:
getNMR in interface Channel
Returns:
the NMR

getEndpoint

public InternalEndpoint getEndpoint()
Access to the endpoint

Returns:
the endpoint for which this channel has been created

createExchange

public Exchange createExchange(Pattern pattern)
Creates a new exchange.

Specified by:
createExchange in interface Channel
Parameters:
pattern - specify the InOnly / InOut / RobustInOnly / RobustInOut
Returns:
a new exchange of the given pattern

send

public void send(Exchange exchange)
An asynchronous invocation of the service

Specified by:
send in interface Channel
Parameters:
exchange - the exchange to send

sendSync

public boolean sendSync(Exchange exchange)
Synchronously send the exchange, blocking until the exchange is returned.

Specified by:
sendSync in interface Channel
Parameters:
exchange - the exchange to send
Returns:
true if the exchange has been processed succesfully

sendSync

public boolean sendSync(Exchange exchange,
                        long timeout)
Synchronously send the exchange

Specified by:
sendSync in interface Channel
Parameters:
exchange - the exchange to send
timeout - time to wait in milliseconds
Returns:
true if the exchange has been processed succesfully

close

public void close()
Closes the channel, freeing up any resources (like sockets, threads etc). Channel that are injected onto Endpoints will be closed automatically by the NMR.

Specified by:
close in interface Channel

deliver

public void deliver(InternalExchange exchange)
Deliver an exchange to the endpoint using this channel

Specified by:
deliver in interface InternalChannel
Parameters:
exchange - the exchange to delivery

process

protected void process(InternalExchange exchange)
Processes the exchange. Delegate to the endpoint for actual processing.

Parameters:
exchange - the exchange to process

dispatch

protected void dispatch(InternalExchange exchange)
Dispatch the exchange to the NMR

Parameters:
exchange - the exchange to dispatch

handleFailure

protected void handleFailure(InternalExchange exchange,
                             RuntimeException e,
                             boolean dispatch)

getExecutor

protected final org.apache.servicemix.executors.Executor getExecutor()
Provide access to the underlying Executor

Returns:
the excecutor instance


Copyright © 2005-2012 FuseSource. All Rights Reserved.