org.apache.synapse.endpoints
Class DefaultEndpoint

java.lang.Object
  extended by org.apache.synapse.FaultHandler
      extended by org.apache.synapse.endpoints.DefaultEndpoint
All Implemented Interfaces:
Endpoint
Direct Known Subclasses:
AddressEndpoint

public class DefaultEndpoint
extends FaultHandler
implements Endpoint

This class represents an endpoint with epr as addressing to header of the message. It is responsible for sending the message to the epr specified in the message To header, performing retries if a failure occurred and informing the parent endpoint if a failure couldn't be recovered.


Field Summary
protected  org.apache.commons.logging.Log log
           
protected static org.apache.commons.logging.Log trace
           
 
Constructor Summary
DefaultEndpoint()
           
 
Method Summary
 EndpointDefinition getEndpoint()
           
 String getName()
          Returns the name of the endpoint.
 boolean isActive(MessageContext synMessageContext)
          This will always return true, because the endpoint epr is dependent on the message being processed
protected  boolean isTraceOn(MessageContext msgCtx)
          Should this mediator perform tracing? True if its explicitly asked to trace, or its parent has been asked to trace and it does not reject it
protected  boolean isTraceOrDebugOn(boolean isTraceOn)
          Is tracing or debug logging on?
 void onChildEndpointFail(Endpoint endpoint, MessageContext synMessageContext)
          Endpoints that contain other endpoints should implement this method.
 void onFault(MessageContext synCtx)
          This will be executed to handle any Exceptions occurred within the Synapse environment.
 void send(MessageContext synCtx)
          Sends the message through this endpoint.
 void setActive(boolean active, MessageContext synMessageContext)
          since this is a virtual representation of an endpoint and the epr changes from message to message setting active state doesn't have a meaning
 void setEndpoint(EndpointDefinition endpoint)
           
 void setName(String name)
          Sets the name of the endpoint.
 void setParentEndpoint(Endpoint parentEndpoint)
          Sets the parent endpoint for the current endpoint.
protected  void traceOrDebug(boolean traceOn, String msg)
          Perform Trace and Debug logging of a message @INFO (trace) and DEBUG (log)
 
Methods inherited from class org.apache.synapse.FaultHandler
getStackTrace, handleFault, handleFault
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected org.apache.commons.logging.Log log

trace

protected static final org.apache.commons.logging.Log trace
Constructor Detail

DefaultEndpoint

public DefaultEndpoint()
Method Detail

getEndpoint

public EndpointDefinition getEndpoint()

setEndpoint

public void setEndpoint(EndpointDefinition endpoint)

getName

public String getName()
Description copied from interface: Endpoint
Returns the name of the endpoint.

Specified by:
getName in interface Endpoint
Returns:
Endpoint name.

setName

public void setName(String name)
Description copied from interface: Endpoint
Sets the name of the endpoint. Local registry use this name as the key for storing the endpoint.

Specified by:
setName in interface Endpoint
Parameters:
name - Name for the endpoint.

isActive

public boolean isActive(MessageContext synMessageContext)
This will always return true, because the endpoint epr is dependent on the message being processed

Specified by:
isActive in interface Endpoint
Parameters:
synMessageContext - not being used
Returns:
true

setActive

public void setActive(boolean active,
                      MessageContext synMessageContext)
since this is a virtual representation of an endpoint and the epr changes from message to message setting active state doesn't have a meaning

Specified by:
setActive in interface Endpoint
Parameters:
active - not being used
synMessageContext - not being used

send

public void send(MessageContext synCtx)
Sends the message through this endpoint. This method just handles statistics related functions and gives the message to the Synapse environment to send. It does not add any endpoint specific details to the message context. These details are added only to the cloned message context by the Axis2FlexibleMepClient. So that we can reuse the original message context for resending through different endpoints.

Specified by:
send in interface Endpoint
Parameters:
synCtx - MessageContext sent by client to Synapse

onChildEndpointFail

public void onChildEndpointFail(Endpoint endpoint,
                                MessageContext synMessageContext)
Description copied from interface: Endpoint
Endpoints that contain other endpoints should implement this method. It will be called if a child endpoint causes an exception. Action to be taken on such failure is up to the implementation. But it is good practice to first try addressing the issue. If it can't be addressed propagate the exception to parent endpoint by calling parent endpoint's onChildEndpointFail(...) method.

Specified by:
onChildEndpointFail in interface Endpoint
Parameters:
endpoint - The child endpoint which caused the exception.
synMessageContext - MessageContext that was used in the failed attempt.

setParentEndpoint

public void setParentEndpoint(Endpoint parentEndpoint)
Description copied from interface: Endpoint
Sets the parent endpoint for the current endpoint.

Specified by:
setParentEndpoint in interface Endpoint
Parameters:
parentEndpoint - parent endpoint containing this endpoint. It should handle the onChildEndpointFail(...) callback.

onFault

public void onFault(MessageContext synCtx)
Description copied from class: FaultHandler
This will be executed to handle any Exceptions occurred within the Synapse environment.

Specified by:
onFault in class FaultHandler
Parameters:
synCtx - SynapseMessageContext of which the fault occured message comprises

isTraceOn

protected boolean isTraceOn(MessageContext msgCtx)
Should this mediator perform tracing? True if its explicitly asked to trace, or its parent has been asked to trace and it does not reject it

Parameters:
msgCtx - the current message
Returns:
true if tracing should be performed

isTraceOrDebugOn

protected boolean isTraceOrDebugOn(boolean isTraceOn)
Is tracing or debug logging on?

Parameters:
isTraceOn - is tracing known to be on?
Returns:
true, if either tracing or debug logging is on

traceOrDebug

protected void traceOrDebug(boolean traceOn,
                            String msg)
Perform Trace and Debug logging of a message @INFO (trace) and DEBUG (log)

Parameters:
traceOn - is runtime trace on for this message?
msg - the message to log/trace


Copyright © 2005-2008 Apache Software Foundation. All Rights Reserved.