Package org.apache.synapse.endpoints
Class AbstractEndpoint
- java.lang.Object
-
- org.apache.synapse.FaultHandler
-
- org.apache.synapse.endpoints.AbstractEndpoint
-
- All Implemented Interfaces:
Endpoint,ManagedLifecycle,Nameable,PropertyInclude,SynapseArtifact
- Direct Known Subclasses:
AddressEndpoint,ClassEndpoint,DefaultEndpoint,FailoverEndpoint,HTTPEndpoint,IndirectEndpoint,LoadbalanceEndpoint,RecipientListEndpoint,ResolvingEndpoint,TemplateEndpoint,WSDLEndpoint
public abstract class AbstractEndpoint extends FaultHandler implements Endpoint, PropertyInclude
An abstract base class for all Endpoint implementations
-
-
Field Summary
Fields Modifier and Type Field Description protected booleananonymousprotected StringartifactContainerNamestatic StringCHILDREN_JSON_ATTprotected StringerrorHandlerThe Sequence name associated with the endpointprotected StringfileNameThe name of the file where this endpoint is definedprotected booleaninitializedHas this endpoint been initialized ?protected BooleanisClusteringEnabledIs clustering enabledprotected org.apache.commons.logging.Loglogstatic StringNAME_JSON_ATTAttributes for json representationprotected static org.apache.commons.logging.Logtracestatic StringTYPE_JSON_ATT
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractEndpoint()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddProperties(Collection<MediatorProperty> mediatorProperties)Add all the properties to the endpointvoidaddProperty(MediatorProperty property)Add a property to the endpoint.protected abstract voidcreateJsonRepresentation()voiddestroy()This method should implement the destroying of the implemented parts of the configuration.protected voidevaluateProperties(MessageContext synCtx)Evaluates the endpoint properties based on the current message context and set the properties to the message context appropriatelyvoidexecuteEpTypeSpecificFunctions(MessageContext synCtx)StringgetArtifactContainerName()Get the car File name which this endpoint deployed fromList<Endpoint>getChildren()Get the children of this endpointList<String>getCommentsList()EndpointContextgetContext()Get the EndpointContext that has the run-time state of this endpointEndpointDefinitiongetDefinition()StringgetDescription()Retrieves the description of the artifactprotected org.json.JSONArraygetEndpointChildrenAsJson(List<Endpoint> children)StringgetErrorHandler()Get the MessageStore name associated with the EndpointStringgetFileName()Get the filename from which this endpoint is loaded,nullif it is an anonymous endpointbooleangetIsEdited()Get the edit state of the endpointorg.json.JSONObjectgetJsonRepresentation()Get the json representation of the endpoint.EndpointViewgetMetricsMBean()Get a reference to the metrics MBean for this endpointStringgetName()Get the name of an abstractionEndpointgetParentEndpoint()Collection<MediatorProperty>getProperties()Return theCollectionof properties specifiedMediatorPropertygetProperty(String name)Get a property with the given nameStringgetReportingName()ObjectgetValue()protected voidhandleException(String msg)Helper methods to handle errors.protected voidhandleException(String msg, Exception e)Helper methods to handle errors.protected voidhandleException(String msg, Exception e, MessageContext msgCtx)Helper methods to handle errors.protected voidinformFailure(MessageContext synCtx, int errorCode, String errorMsg)voidinit(SynapseEnvironment synapseEnvironment)This method should implement the initialization of the implemented parts of the configuration.booleanisAnonymous()booleanisInitialized()Has this Endpoint initialized?booleanisLeafEndpoint()Is this a leaf level endpoint? or parent endpoint that has children?protected booleanisRetry(MessageContext synCtx)protected booleanisSuspendFault(MessageContext synCtx)Is this a fault that should put the endpoint on SUSPEND? or is this a fault to ignore?protected booleanisTimeout(MessageContext synCtx)Is this [fault] message a timeout?protected booleanisTraceOn(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 itprotected booleanisTraceOrDebugOn(boolean isTraceOn)Is tracing or debug logging on?protected voidlogOnChildEndpointFail(Endpoint endpoint, MessageContext synMessageContext)voidlogSetter()voidonChildEndpointFail(Endpoint endpoint, MessageContext synMessageContext)Endpoints that contain other endpoints should implement this method.voidonFault(MessageContext synCtx)On a fault, propagate to parent if any, or call into the fault handlervoidonSuccess()The SynapseCallback Receiver notifies an endpoint, if a message was successfully processed to give it a chance to clear up or reset its state to activeprotected voidprepareForEndpointStatistics(MessageContext synCtx)Process statistics for this messagebooleanreadyToSend()Returns true to indicate that the endpoint is ready to service requestsMediatorPropertyremoveProperty(String name)Remove a property with the given namevoidsend(MessageContext synCtx)Sends the message context according to an endpoint specific behavior.protected voidsetAdvancedProperties()Set advanced properties of the endpoint to json object.voidsetAnonymous(boolean anonymous)voidsetArtifactContainerName(String name)Set the car File name which this endpoint deployed fromvoidsetChildren(List<Endpoint> children)voidsetCommentsList(List<String> commentsList)voidsetComponentStatisticsId(ArtifactHolder holder)voidsetContentAware(boolean contentAware)voidsetDefinition(EndpointDefinition definition)voidsetDescription(String description)Set the description of the artifactvoidsetEnableMBeanStats(boolean flag)set whether this endpoint needs to be registered for JMX MBeans.voidsetErrorHandler(String errorHandler)Set the Message Store name associated with the Endpointprotected voidsetErrorOnMessage(MessageContext synCtx, Integer errorCode, String errorMsg)voidsetFileName(String fileName)Set the filename from which the endpoint is loadedvoidsetForceBuildMC(boolean forceBuildMC)voidsetIsEdited(boolean isEdited)Set the edit state of the endpointvoidsetName(String endpointName)Set the name of an abstractionvoidsetParentEndpoint(Endpoint parentEndpoint)Sets the parent endpoint for the current endpoint.voidsetValue(Object value)Set the value of the registry entry of an endpointStringtoString()protected voidtraceOrDebug(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
executeExtendedSynapseHandlerOnFault, getStackTrace, handleFault, handleFault
-
-
-
-
Field Detail
-
log
protected org.apache.commons.logging.Log log
-
trace
protected static final org.apache.commons.logging.Log trace
-
initialized
protected volatile boolean initialized
Has this endpoint been initialized ?
-
isClusteringEnabled
protected Boolean isClusteringEnabled
Is clustering enabled
-
fileName
protected String fileName
The name of the file where this endpoint is defined
-
anonymous
protected boolean anonymous
-
errorHandler
protected String errorHandler
The Sequence name associated with the endpoint
-
artifactContainerName
protected String artifactContainerName
-
NAME_JSON_ATT
public static final String NAME_JSON_ATT
Attributes for json representation- See Also:
- Constant Field Values
-
TYPE_JSON_ATT
public static final String TYPE_JSON_ATT
- See Also:
- Constant Field Values
-
CHILDREN_JSON_ATT
public static final String CHILDREN_JSON_ATT
- See Also:
- Constant Field Values
-
-
Method Detail
-
getMetricsMBean
public EndpointView getMetricsMBean()
Description copied from interface:EndpointGet a reference to the metrics MBean for this endpoint- Specified by:
getMetricsMBeanin interfaceEndpoint- Returns:
- EndpointView instance
-
getContext
public EndpointContext getContext()
Description copied from interface:EndpointGet the EndpointContext that has the run-time state of this endpoint- Specified by:
getContextin interfaceEndpoint- Returns:
- the runtime context
-
getName
public String getName()
Description copied from interface:NameableGet the name of an abstraction
-
getValue
public Object getValue()
-
isInitialized
public boolean isInitialized()
Description copied from interface:EndpointHas this Endpoint initialized?- Specified by:
isInitializedin interfaceEndpoint- Returns:
- true if the endpoint is initialized
-
getDefinition
public EndpointDefinition getDefinition()
-
setDefinition
public void setDefinition(EndpointDefinition definition)
-
getParentEndpoint
public Endpoint getParentEndpoint()
-
setParentEndpoint
public void setParentEndpoint(Endpoint parentEndpoint)
Description copied from interface:EndpointSets the parent endpoint for the current endpoint.- Specified by:
setParentEndpointin interfaceEndpoint- Parameters:
parentEndpoint- parent endpoint containing this endpoint. It should handle the onChildEndpointFail(...) callback.
-
getChildren
public List<Endpoint> getChildren()
Description copied from interface:EndpointGet the children of this endpoint- Specified by:
getChildrenin interfaceEndpoint- Returns:
- the child endpoints
-
getFileName
public String getFileName()
Description copied from interface:EndpointGet the filename from which this endpoint is loaded,nullif it is an anonymous endpoint- Specified by:
getFileNamein interfaceEndpoint- Returns:
- String file name
-
setFileName
public void setFileName(String fileName)
Description copied from interface:EndpointSet the filename from which the endpoint is loaded- Specified by:
setFileNamein interfaceEndpoint- Parameters:
fileName- from which the endpoint is loaded
-
isAnonymous
public boolean isAnonymous()
-
setAnonymous
public void setAnonymous(boolean anonymous)
-
setDescription
public void setDescription(String description)
Description copied from interface:SynapseArtifactSet the description of the artifact- Specified by:
setDescriptionin interfaceSynapseArtifact- Parameters:
description- tobe set to the artifact
-
getDescription
public String getDescription()
Description copied from interface:SynapseArtifactRetrieves the description of the artifact- Specified by:
getDescriptionin interfaceSynapseArtifact- Returns:
- description of the artifact
-
setName
public void setName(String endpointName)
Description copied from interface:NameableSet the name of an abstraction
-
setValue
public void setValue(Object value)
Set the value of the registry entry of an endpoint- Parameters:
value-
-
setArtifactContainerName
public void setArtifactContainerName(String name)
Set the car File name which this endpoint deployed from- Specified by:
setArtifactContainerNamein interfaceEndpoint- Parameters:
name-
-
getArtifactContainerName
public String getArtifactContainerName()
Get the car File name which this endpoint deployed from- Specified by:
getArtifactContainerNamein interfaceEndpoint- Returns:
- artifactContainerName
-
getIsEdited
public boolean getIsEdited()
Get the edit state of the endpoint- Specified by:
getIsEditedin interfaceEndpoint- Returns:
-
setIsEdited
public void setIsEdited(boolean isEdited)
Set the edit state of the endpoint- Specified by:
setIsEditedin interfaceEndpoint- Parameters:
isEdited-
-
setEnableMBeanStats
public void setEnableMBeanStats(boolean flag)
set whether this endpoint needs to be registered for JMX MBeans. some endpoints may not need to register under MBean and setting false will cut the additional overhead.- Parameters:
flag- set true/false
-
init
public void init(SynapseEnvironment synapseEnvironment)
Description copied from interface:ManagedLifecycleThis method should implement the initialization of the implemented parts of the configuration.- Specified by:
initin interfaceManagedLifecycle- Parameters:
synapseEnvironment- SynapseEnvironment to be used for initialization
-
readyToSend
public boolean readyToSend()
Description copied from interface:EndpointReturns true to indicate that the endpoint is ready to service requests- Specified by:
readyToSendin interfaceEndpoint- Returns:
- true if endpoint is ready to service requests
-
send
public void send(MessageContext synCtx)
Description copied from interface:EndpointSends the message context according to an endpoint specific behavior.
-
isLeafEndpoint
public boolean isLeafEndpoint()
Is this a leaf level endpoint? or parent endpoint that has children?- Returns:
- true if there is no children - a leaf endpoint
-
onChildEndpointFail
public void onChildEndpointFail(Endpoint endpoint, MessageContext synMessageContext)
Description copied from interface:EndpointEndpoints 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:
onChildEndpointFailin interfaceEndpoint- Parameters:
endpoint- The child endpoint which caused the exception.synMessageContext- MessageContext that was used in the failed attempt.
-
executeEpTypeSpecificFunctions
public void executeEpTypeSpecificFunctions(MessageContext synCtx)
-
isTimeout
protected boolean isTimeout(MessageContext synCtx)
Is this [fault] message a timeout?- Parameters:
synCtx- the current fault message- Returns:
- true if this is defined as a timeout
-
isRetry
protected boolean isRetry(MessageContext synCtx)
-
isSuspendFault
protected boolean isSuspendFault(MessageContext synCtx)
Is this a fault that should put the endpoint on SUSPEND? or is this a fault to ignore?- Parameters:
synCtx- the current fault message- Returns:
- true if this fault should suspend the endpoint
-
onFault
public void onFault(MessageContext synCtx)
On a fault, propagate to parent if any, or call into the fault handler- Specified by:
onFaultin classFaultHandler- Parameters:
synCtx- the message at hand
-
onSuccess
public void onSuccess()
The SynapseCallback Receiver notifies an endpoint, if a message was successfully processed to give it a chance to clear up or reset its state to active
-
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
-
prepareForEndpointStatistics
protected void prepareForEndpointStatistics(MessageContext synCtx)
Process statistics for this message- Parameters:
synCtx- the current message
-
handleException
protected void handleException(String msg)
Helper methods to handle errors.- Parameters:
msg- The error message
-
handleException
protected void handleException(String msg, Exception e)
Helper methods to handle errors.- Parameters:
msg- The error messagee- The exception
-
handleException
protected void handleException(String msg, Exception e, MessageContext msgCtx)
Helper methods to handle errors.- Parameters:
msg- The error messagee- The exceptionmsgCtx- The message context
-
logOnChildEndpointFail
protected void logOnChildEndpointFail(Endpoint endpoint, MessageContext synMessageContext)
-
informFailure
protected void informFailure(MessageContext synCtx, int errorCode, String errorMsg)
-
setErrorOnMessage
protected void setErrorOnMessage(MessageContext synCtx, Integer errorCode, String errorMsg)
-
destroy
public void destroy()
Description copied from interface:ManagedLifecycleThis method should implement the destroying of the implemented parts of the configuration.- Specified by:
destroyin interfaceManagedLifecycle
-
addProperty
public void addProperty(MediatorProperty property)
Add a property to the endpoint.- Specified by:
addPropertyin interfacePropertyInclude- Parameters:
property- property to be added
-
getProperty
public MediatorProperty getProperty(String name)
Get a property with the given name- Specified by:
getPropertyin interfacePropertyInclude- Parameters:
name- name of the property- Returns:
- a property with the given name
-
getProperties
public Collection<MediatorProperty> getProperties()
Return theCollectionof properties specified- Specified by:
getPropertiesin interfacePropertyInclude- Returns:
Collectionof properties
-
removeProperty
public MediatorProperty removeProperty(String name)
Remove a property with the given name- Specified by:
removePropertyin interfacePropertyInclude- Parameters:
name- name of the property to be removed- Returns:
- the remove property or
nullif a property doesn't exists
-
addProperties
public void addProperties(Collection<MediatorProperty> mediatorProperties)
Add all the properties to the endpoint- Specified by:
addPropertiesin interfacePropertyInclude- Parameters:
mediatorProperties-Collectionof properties to be added
-
getErrorHandler
public String getErrorHandler()
Description copied from interface:EndpointGet the MessageStore name associated with the Endpoint- Specified by:
getErrorHandlerin interfaceEndpoint- Returns:
- String message store name
-
setErrorHandler
public void setErrorHandler(String errorHandler)
Description copied from interface:EndpointSet the Message Store name associated with the Endpoint- Specified by:
setErrorHandlerin interfaceEndpoint- Parameters:
errorHandler- , name of the message store
-
setContentAware
public void setContentAware(boolean contentAware)
-
setForceBuildMC
public void setForceBuildMC(boolean forceBuildMC)
-
evaluateProperties
protected void evaluateProperties(MessageContext synCtx)
Evaluates the endpoint properties based on the current message context and set the properties to the message context appropriately- Parameters:
synCtx- the current message context
-
logSetter
public void logSetter()
-
getReportingName
public String getReportingName()
-
setComponentStatisticsId
public void setComponentStatisticsId(ArtifactHolder holder)
- Specified by:
setComponentStatisticsIdin interfaceEndpoint
-
setAdvancedProperties
protected void setAdvancedProperties()
Set advanced properties of the endpoint to json object.
-
getEndpointChildrenAsJson
protected org.json.JSONArray getEndpointChildrenAsJson(List<Endpoint> children)
-
getJsonRepresentation
public org.json.JSONObject getJsonRepresentation()
Description copied from interface:EndpointGet the json representation of the endpoint.- Specified by:
getJsonRepresentationin interfaceEndpoint- Returns:
- JSONObject
-
createJsonRepresentation
protected abstract void createJsonRepresentation()
-
-