@Tracked(value=TRACE) public abstract class TextAdapterActivity extends DefaultActivityImpl implements AdapterActivity, AdapterInvocationError, TextAdapter
DISABLED, GROOVY, JAVA_EL, JAVASCRIPT, logger, OUTPUTDOCS
COMPCODE_AUTO_RETRY, DEFAULT_STUBBER_PORT, DEFAULT_STUBBER_TIMEOUT, DO_LOGGING, MAKE_ACTUAL_CALL, PROP_MAX_TRIES, PROP_RETRY_INTERVAL, PROP_SYNCHRONOUS_RESPONSE, PROP_TIMEOUT, REQUEST_VARIABLE, REQUEST_XSD, RESPONSE_VARIABLE, RESPONSE_XSD
Constructor and Description |
---|
TextAdapterActivity() |
Modifier and Type | Method and Description |
---|---|
protected abstract boolean |
canBeAsynchronous() |
protected abstract boolean |
canBeSynchronous() |
Response |
directInvoke(java.lang.String request,
int timeout,
java.util.Map<java.lang.String,java.lang.String> meta_data)
This method is used for directly invoke the adapter activity
from code, rather than as part of process execution flow.
|
Response |
doInvoke(java.lang.Object connection,
Request request,
int timeout,
java.util.Map<java.lang.String,java.lang.String> headers)
This method performs the real invocation of external system service.
|
protected boolean |
doLogging()
Determines if external requests/responses should
be logged into adapter instance table.
|
void |
execute()
Subclasses do not normally override this method.
|
protected void |
executePostScript()
Executes a script, after completing the invocation of the system.
|
protected java.lang.Object |
executePreScript(java.lang.Object requestData)
Executes a script, before invoking the system.
|
protected java.lang.String |
filterStubResponse(java.lang.String unfiltered,
java.lang.Object request)
TODO implements this for simulation response
|
java.lang.String |
getAdapterInvocationErrorMessage()
This method allows the concrete adapters to define whatever they need for
a decent error message.
|
protected java.lang.String |
getAttribute(java.lang.String name,
java.lang.String defval,
boolean isSmart)
Returns the value of attribute.
|
protected int |
getErrorCode(java.lang.Throwable ex) |
protected int |
getMaxTries()
Retrieves the maximum retries allowed for the activity
This is only used by activities, not connection pools
|
protected java.lang.String |
getRequestData()
The method overrides the one from the super class and perform the followings:
It gets the value of the variable with the name specified in the attribute
REQUEST_VARIABLE.
|
protected java.util.Map<java.lang.String,java.lang.String> |
getRequestHeaders()
Override to return protocol-specific headers to be included on the request.
|
protected org.json.JSONObject |
getRequestMeta() |
protected Response |
getResponse(java.lang.Object connection,
java.lang.String responseString)
Override to set protocol response status/message.
|
protected java.util.Map<java.lang.String,java.lang.String> |
getResponseHeaders()
Protocol adapter must call setResponseHeaders() with appropriate values extracted from the response.
|
protected org.json.JSONObject |
getResponseMeta() |
protected int |
getRetryInterval()
Retrieves the interval between activity retries
This is only used by activities, not connection pools
|
protected Response |
getStubbedResponse(java.lang.String requestData) |
protected AdapterStubRequest |
getStubRequest(java.lang.String requestContent) |
protected java.lang.String |
getStubResponse(java.lang.String requestData)
Deprecated.
|
protected int |
getTimeoutForResponse()
Timeout value for waiting for responses.
|
protected void |
handleConnectionException(int errorCode,
java.lang.Throwable originalCause)
Typically you should not override this method.
|
protected void |
handleException(java.lang.Throwable errorCause)
The method is used to handle the exception thrown from the execute method.
|
protected void |
handleRetry(int errorCode,
java.lang.Throwable originalCause)
Added so retry in executed for certain exceptions.
|
protected boolean |
hasPostScript()
Checks if the adapter is configured with a post script.
|
protected boolean |
hasPreScript()
Checks if the adapter is configured with a pre script.
|
boolean |
isRetryable(java.lang.Throwable ex)
Default behavior returns true if Throwable is included in RETRY_EXCEPTIONS
attribute (if declared).
|
protected boolean |
isStubMode() |
boolean |
isSynchronous()
The method is used to determine if the current usage is synchronous (waiting for response) or not.
|
protected java.lang.Long |
logRequest(Request request) |
protected java.lang.Long |
logRequest(java.lang.String message)
Deprecated.
|
protected java.lang.Long |
logResponse(Response response)
Populates response into document and document_content table
|
protected java.lang.Long |
logResponse(java.lang.String message)
Deprecated.
|
java.lang.String |
onFailure(java.lang.Throwable errorCause)
The method is invoked on the failure of each try.
|
void |
onSuccess(java.lang.String response)
The method is invoked when the external system interaction is a success.
|
void |
populateResponseVariable(java.lang.String response) |
protected void |
setResponseHeaders(java.util.Map<java.lang.String,java.lang.String> headers) |
execute
createDocument, createDocument, createDocument, createDocument, evaluateExpression, executeScript, getActivityId, getActivityInstance, getActivityInstanceId, getActivityName, getAttribute, getAttribute, getAttribute, getAttribute, getAttributes, getAttributeValue, getAttributeValueSmart, getDocument, getDocumentContent, getDocumentForUpdate, getDocumentType, getEngine, getExternalEventInstanceDetails, getLogger, getMainProcessDefinition, getMasterRequestId, getOutputDocuments, getPackage, getParameterId, getParameters, getParameterStringValue, getParameterType, getParameterValue, getPerformanceLevel, getProcessDefinition, getProcessId, getProcessInstance, getProcessInstanceId, getProcessInstanceOwner, getProcessInstanceOwnerId, getProperty, getRequiredAttribute, getRequiredVariableValue, getReturnCode, getReturnMessage, getRuntimeContext, getScriptEvaluator, getScriptExecClassName, getScriptExecutor, getValue, getValues, getValueSmart, getVariableInstance, getVariableValue, getVariableValueSmart, getWorkTransitionInstanceId, initialize, isDisabled, isLogDebugEnabled, isLogInfoEnabled, isOutputDocument, lockActivityInstance, lockProcessInstance, logdebug, logDebug, logError, logError, logexception, loginfo, logInfo, logsevere, logwarn, logWarn, prepare, setOutputDocuments, setParameterValue, setParameterValueAsDocument, setParameterValues, setProcessInstanceCompletionCode, setReturnCode, setReturnMessage, setValue, setVariableValue, setVariableValue, startTransaction, stopTransaction, translatePlaceHolder, updateDocumentContent, updateDocumentInfo, updateDocumentInfo, valueIsJavaExpression, valueIsVariable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
execute
closeConnection, init, invoke, openConnection
protected int getTimeoutForResponse()
protected abstract boolean canBeSynchronous()
protected abstract boolean canBeAsynchronous()
protected java.lang.String getRequestData() throws ActivityException
ActivityException
public boolean isSynchronous()
isSynchronous
in interface AdapterActivity
public void onSuccess(java.lang.String response) throws ActivityException, ConnectionException, AdapterException
onSuccess
in interface TextAdapter
response
- response message from the external systemConnectionException
- this exception indicates a system connection
failure (most likely between the direct interfacing system to down
stream systems, as direct connection failure will not some to this method).
The exception is auto-retriable.AdapterException
- thrown when the external system responded but
the response needs to be handled as a non-auto-retriable error.ActivityException
- thrown when the post processing
logic hits an exception that needs to fail the activity.
This error is not auto-retriable, either.public void populateResponseVariable(java.lang.String response) throws ActivityException
ActivityException
public java.lang.String onFailure(java.lang.Throwable errorCause) throws AdapterException, ConnectionException
onFailure
in interface TextAdapter
errorCause
- the exception receivedAdapterException
- when no retry is expectedConnectionException
- when retry is expectedprotected int getMaxTries() throws ActivityException
ActivityException
protected int getRetryInterval() throws ActivityException
ActivityException
public void execute() throws ActivityException
execute
in interface GeneralActivity
execute
in class DefaultActivityImpl
ActivityException
protected AdapterStubRequest getStubRequest(java.lang.String requestContent) throws AdapterException
AdapterException
protected int getErrorCode(java.lang.Throwable ex)
protected void handleRetry(int errorCode, java.lang.Throwable originalCause) throws ActivityException
errorCode
- ActivityException
protected void handleConnectionException(int errorCode, java.lang.Throwable originalCause) throws ActivityException
errorCode
- ActivityException
protected void handleException(java.lang.Throwable errorCause) throws ActivityException
errorCause
- the exception capturedActivityException
public boolean isRetryable(java.lang.Throwable ex)
protected boolean doLogging()
protected java.lang.Long logRequest(Request request)
@Deprecated protected java.lang.Long logRequest(java.lang.String message)
protected java.lang.Long logResponse(Response response)
@Deprecated protected java.lang.Long logResponse(java.lang.String message)
protected org.json.JSONObject getRequestMeta() throws java.lang.Exception
java.lang.Exception
protected org.json.JSONObject getResponseMeta() throws java.lang.Exception
java.lang.Exception
protected boolean isStubMode()
protected java.lang.String filterStubResponse(java.lang.String unfiltered, java.lang.Object request)
unfiltered
- request
- protected Response getStubbedResponse(java.lang.String requestData)
@Deprecated protected java.lang.String getStubResponse(java.lang.String requestData)
getStubbedResponse
public Response directInvoke(java.lang.String request, int timeout, java.util.Map<java.lang.String,java.lang.String> meta_data) throws AdapterException, ConnectionException
request
- request messagetimeout
- value for waiting for responses.meta_data
- AdapterException
ConnectionException
protected java.lang.String getAttribute(java.lang.String name, java.lang.String defval, boolean isSmart) throws AdapterException
AdapterException
protected boolean hasPreScript()
protected java.lang.Object executePreScript(java.lang.Object requestData) throws ActivityException
requestData
- incoming request data.ActivityException
protected boolean hasPostScript()
protected void executePostScript() throws ActivityException
ActivityException
public Response doInvoke(java.lang.Object connection, Request request, int timeout, java.util.Map<java.lang.String,java.lang.String> headers) throws AdapterException, ConnectionException
doInvoke
in interface TextAdapter
connection
- request
- headers
- AdapterException
- Adapter exception may or
may not be retriable, which you can set in the
exception itself. Default is not retriable.ConnectionException
- certain protocol may also
throw ConnectionException here. ConnectionException
can be retried.protected Response getResponse(java.lang.Object connection, java.lang.String responseString) throws java.io.IOException
java.io.IOException
protected java.util.Map<java.lang.String,java.lang.String> getRequestHeaders()
protected java.util.Map<java.lang.String,java.lang.String> getResponseHeaders()
protected void setResponseHeaders(java.util.Map<java.lang.String,java.lang.String> headers)
public java.lang.String getAdapterInvocationErrorMessage()
This method allows the concrete adapters to define whatever they need for a decent error message. For instance they can include endpoint urls etc
getAdapterInvocationErrorMessage
in interface AdapterInvocationError
Copyright © 2019 CenturyLink, Inc.