org.apache.synapse.endpoints
Class AddressEndpoint

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

public class AddressEndpoint
extends FaultHandler
implements Endpoint

This class represents an actual endpoint to send the message. It is resposible for sending the message, performing reries if a failure occured and informing the parent endpoint if a failure couldn't be recovered.


Constructor Summary
AddressEndpoint()
           
 
Method Summary
 EndpointDefinition getEndpoint()
           
 java.lang.String getName()
          Returns the name of the endpoint.
 long getSuspendOnFailDuration()
           
 boolean isActive(MessageContext synMessageContext)
          Checks if the endpoint is active (failed or not).
 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 occured within the Synapse environment.
 void send(MessageContext synCtx)
          Sends the message through this endpoint.
 void setActive(boolean active, MessageContext synMessageContext)
          Sets if endpoint active or not.
 void setEndpoint(EndpointDefinition endpoint)
           
 void setName(java.lang.String name)
          Sets the name of the endpoint.
 void setParentEndpoint(Endpoint parentEndpoint)
          Sets the parent endpoint for the current endpoint.
 void setSuspendOnFailDuration(long suspendOnFailDuration)
           
 
Methods inherited from class org.apache.synapse.FaultHandler
handleFault, handleFault
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AddressEndpoint

public AddressEndpoint()
Method Detail

getEndpoint

public EndpointDefinition getEndpoint()

setEndpoint

public void setEndpoint(EndpointDefinition endpoint)

getName

public java.lang.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(java.lang.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)
Checks if the endpoint is active (failed or not). If endpoint is in failed state and suspendOnFailDuration has elapsed, it will be set to active.

Specified by:
isActive in interface Endpoint
Parameters:
synMessageContext - MessageContext of the current message. This is not used here.
Returns:
true if endpoint is active. false otherwise.

setActive

public void setActive(boolean active,
                      MessageContext synMessageContext)
Sets if endpoint active or not. if endpoint is set as failed (active = false), the recover on time is calculated so that it will be activated after the recover on time.

Specified by:
setActive in interface Endpoint
Parameters:
active - true if active. false otherwise.
synMessageContext - MessageContext of the current message. This is not used here.

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 upto 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.

getSuspendOnFailDuration

public long getSuspendOnFailDuration()

setSuspendOnFailDuration

public void setSuspendOnFailDuration(long suspendOnFailDuration)

onFault

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

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


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