org.apache.synapse.endpoints
Interface Endpoint

All Known Implementing Classes:
AddressEndpoint, DefaultEndpoint, FailoverEndpoint, IndirectEndpoint, LoadbalanceEndpoint, SALoadbalanceEndpoint, WSDLEndpoint

public interface Endpoint

Endpoint defines the behavior common to all Synapse endpoints. Synapse endpoints should be able to send the given Synapse message context, rather than just providing the information for sending the message. The task a particular endpoint does in its send(...) method is specific to the endpoint. For example a loadbalance endpoint may choose another endpoint using its load balance policy and call its send(...) method while an address endpoint (leaf level) may send the message to an actual endpoint url. Endpoints may contain zero or more endpoints in them and build up a hierarchical structure of endpoints.


Method Summary
 String getName()
          Returns the name of the endpoint.
 boolean isActive(MessageContext synMessageContext)
          Returns if the endpoint is currently active or not.
 void onChildEndpointFail(Endpoint endpoint, MessageContext synMessageContext)
          Endpoints that contain other endpoints should implement this method.
 void send(MessageContext synMessageContext)
          Sends the message context according to an endpoint specific behavior.
 void setActive(boolean active, MessageContext synMessageContext)
          Sets the endpoint as active or inactive.
 void setName(String name)
          Sets the name of the endpoint.
 void setParentEndpoint(Endpoint parentEndpoint)
          Sets the parent endpoint for the current endpoint.
 

Method Detail

send

void send(MessageContext synMessageContext)
Sends the message context according to an endpoint specific behavior.

Parameters:
synMessageContext - MessageContext to be sent.

onChildEndpointFail

void onChildEndpointFail(Endpoint endpoint,
                         MessageContext synMessageContext)
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.

Parameters:
endpoint - The child endpoint which caused the exception.
synMessageContext - MessageContext that was used in the failed attempt.

setParentEndpoint

void setParentEndpoint(Endpoint parentEndpoint)
Sets the parent endpoint for the current endpoint.

Parameters:
parentEndpoint - parent endpoint containing this endpoint. It should handle the onChildEndpointFail(...) callback.

getName

String getName()
Returns the name of the endpoint.

Returns:
Endpoint name.

setName

void setName(String name)
Sets the name of the endpoint. Local registry use this name as the key for storing the endpoint.

Parameters:
name - Name for the endpoint.

isActive

boolean isActive(MessageContext synMessageContext)
Returns if the endpoint is currently active or not. Messages should not be sent to inactive endpoints.

Parameters:
synMessageContext - MessageContext for the current message. This is required for IndirectEndpoints where the actual endpoint is retrieved from the MessageContext. Other Endpoint implementations may ignore this parameter.
Returns:
true if the endpoint is in active state. false otherwise.

setActive

void setActive(boolean active,
               MessageContext synMessageContext)
Sets the endpoint as active or inactive. If an endpoint is detected as failed, it should be set as inactive. But endpoints may be eventually set as active by the endpoint refresher to avoid ignoring endpoints forever.

Parameters:
active - true if active. false otherwise.
synMessageContext - MessageContext for the current message. This is required for IndirectEndpoints where the actual endpoint is retrieved from the MessageContext. Other Endpoint implementations may ignore this parameter.


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