Class JCoConnectionImpl
- java.lang.Object
-
- de.hybris.platform.sap.core.jco.connection.impl.JCoConnectionImpl
-
- All Implemented Interfaces:
JCoConnection
- Direct Known Subclasses:
JCoConnectionStateful,JCoConnectionStateless
public class JCoConnectionImpl extends java.lang.Object implements JCoConnection
Base class for a managed connection.
-
-
Field Summary
Fields Modifier and Type Field Description protected JCoConnectionParametersconnectionParametersConnection parameters.protected booleandestroyedIndicator that connections has already been destroyed.protected JCoManagedConnectionContainerjcoManagedConnectionContainerJCoManagedConnectionContainer.protected java.util.PropertiespropertiesProperties filled by spring definition in constructor.protected RFCDestinationServicerfcDestinationServiceRFCDestinationService.-
Fields inherited from interface de.hybris.platform.sap.core.jco.connection.JCoConnection
JCO_DESTINATION, JCO_LANG, JCO_SCOPE_TYPE
-
-
Constructor Summary
Constructors Constructor Description JCoConnectionImpl(java.util.Properties properties)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckInternalStatus()Checks internal status of the connection.voidexecute(com.sap.conn.jco.JCoFunction function)This method is used to execute a JCoFunction on behalf of this connection.protected voidexecuteCachedFunction(com.sap.conn.jco.JCoDestination destination, JCoManagedFunction function)Executes function on cache result.java.lang.StringgetCallerId()Getter for caller id.protected com.sap.conn.jco.JCoCustomDestinationgetDestination()Getter for destination.com.sap.conn.jco.JCoFunctiongetFunction(java.lang.String functionName)Returns a JCoFunction object for the given function name.protected java.lang.StringgetReplacedFunctionModuleName(java.lang.String functionName)Replaces origin function name with function name defined in connection parameters.protected RFCDestinationgetRFCDestination(java.lang.String destinationName)Returns the RFC Destination for the requested name.java.lang.StringgetScopeType()Getter for scope type.protected voidhandleCommunicationExceptionAndDestroyConnection(java.lang.Exception e)Handles the Communication JCoException and destroy Stateful connection.voidinit()Init method called by spring init method definition.booleanisBackendAvailable()Returnstrueif the backend is available the connection is connected to.booleanisBackendOffline()Returnstrueif the backend is switched offline the connection is connected to.booleanisFunctionAvailable(java.lang.String functionName)Returnstrueif the JCo Function is available on the SAP system the connection is connected to.protected booleanisFunctionCached(JCoManagedFunction managedFunction)Checks if function result is cached.protected booleanisStateful()Check if the destination is stateful.protected voidpostProcessingExecute(JCoManagedFunction function)Called after JCO execution.protected voidpreProcessingExecute(JCoManagedFunction function)Called before JCO execution.voidsetCallerId(java.lang.String callerID)Sets the caller id.voidsetConnectionParameters(JCoConnectionParameters connectionParameters)Setter for connection parameters.voidsetDestroyed()Destroy method which cleans up the object.voidsetJcoManagedConnectionContainer(JCoManagedConnectionContainer jcoManagedConnectionContainer)Setter for JCo Managed Connection Container.voidsetRfcDestinationService(RFCDestinationService rfcDestinationService)Injection setter forRFCDestinationService.voidsetScopeType(java.lang.String scopeType)Setter for scope type.
-
-
-
Field Detail
-
properties
protected java.util.Properties properties
Properties filled by spring definition in constructor.
-
connectionParameters
protected JCoConnectionParameters connectionParameters
Connection parameters.
-
destroyed
protected boolean destroyed
Indicator that connections has already been destroyed.
-
jcoManagedConnectionContainer
protected JCoManagedConnectionContainer jcoManagedConnectionContainer
JCoManagedConnectionContainer.
-
rfcDestinationService
protected RFCDestinationService rfcDestinationService
RFCDestinationService.
-
-
Constructor Detail
-
JCoConnectionImpl
public JCoConnectionImpl(java.util.Properties properties)
Constructor.- Parameters:
properties- properties for this instance with the following keysJCoConnection.JCO_DESTINATION(destination)JCoConnection.JCO_SCOPE_TYPE(jcoScopeType)JCoConnection.JCO_LANG(jco.client.lang)
-
-
Method Detail
-
setConnectionParameters
public void setConnectionParameters(JCoConnectionParameters connectionParameters)
Setter for connection parameters.- Parameters:
connectionParameters- connection parameters.
-
setJcoManagedConnectionContainer
public void setJcoManagedConnectionContainer(JCoManagedConnectionContainer jcoManagedConnectionContainer)
Setter for JCo Managed Connection Container.- Parameters:
jcoManagedConnectionContainer- JCo Managed Connection Container
-
setRfcDestinationService
public void setRfcDestinationService(RFCDestinationService rfcDestinationService)
Injection setter forRFCDestinationService.- Parameters:
rfcDestinationService-RFCDestinationService
-
init
public void init() throws BackendExceptionInit method called by spring init method definition.- Throws:
BackendException- Exception in case of failure.
-
setDestroyed
public void setDestroyed()
Destroy method which cleans up the object.
-
getFunction
public com.sap.conn.jco.JCoFunction getFunction(java.lang.String functionName) throws BackendExceptionDescription copied from interface:JCoConnectionReturns a JCoFunction object for the given function name.- Specified by:
getFunctionin interfaceJCoConnection- Parameters:
functionName- name of remote callable function module on the SAP system- Returns:
- JCoFunction
- Throws:
BackendException- when something goes wrong while retrieving meta data
-
getReplacedFunctionModuleName
protected java.lang.String getReplacedFunctionModuleName(java.lang.String functionName)
Replaces origin function name with function name defined in connection parameters.- Parameters:
functionName- origin function name- Returns:
- replaced function name
-
execute
public void execute(com.sap.conn.jco.JCoFunction function) throws BackendExceptionDescription copied from interface:JCoConnectionThis method is used to execute a JCoFunction on behalf of this connection.- Specified by:
executein interfaceJCoConnection- Parameters:
function- a JCoFunction which should be executed- Throws:
BackendException- thrown if something goes wrong in the EAI layer or if an JCoException is thrown by the SAP Java Connector.
-
isFunctionCached
protected boolean isFunctionCached(JCoManagedFunction managedFunction)
Checks if function result is cached.- Parameters:
managedFunction- requested function- Returns:
- true, if result is cached
-
executeCachedFunction
protected void executeCachedFunction(com.sap.conn.jco.JCoDestination destination, JCoManagedFunction function) throws BackendExceptionExecutes function on cache result.- Parameters:
destination- rfc destinationfunction- rfc function- Throws:
BackendException-BackendException
-
preProcessingExecute
protected void preProcessingExecute(JCoManagedFunction function)
Called before JCO execution. Calls event listeners and tracing.
This method is only called if parameters are defined for that function.- Parameters:
function- function which is called.
-
postProcessingExecute
protected void postProcessingExecute(JCoManagedFunction function)
Called after JCO execution. Calls event listeners and tracing.
This method is only called if parameters are defined for that function.- Parameters:
function- function which is called.
-
isFunctionAvailable
public boolean isFunctionAvailable(java.lang.String functionName) throws BackendExceptionDescription copied from interface:JCoConnectionReturnstrueif the JCo Function is available on the SAP system the connection is connected to.- Specified by:
isFunctionAvailablein interfaceJCoConnection- Parameters:
functionName- function name- Returns:
trueif the JCo Function is available, otherwisefalse- Throws:
BackendException-BackendException
-
isStateful
protected boolean isStateful() throws BackendExceptionCheck if the destination is stateful.- Returns:
- true if stateful, false otherwise.
- Throws:
BackendException- BackendException
-
getDestination
protected com.sap.conn.jco.JCoCustomDestination getDestination()
Getter for destination.- Returns:
- the destination
-
checkInternalStatus
protected void checkInternalStatus() throws BackendExceptionChecks internal status of the connection.
After the object is destroyed the destination is set to null. No more function execution is possible. Throws BackendRuntimeException in case of object was already destroyed.- Throws:
BackendException-BackendException
-
setCallerId
public void setCallerId(java.lang.String callerID)
Description copied from interface:JCoConnectionSets the caller id.- Specified by:
setCallerIdin interfaceJCoConnection- Parameters:
callerID- caller id.
-
getCallerId
public java.lang.String getCallerId()
Getter for caller id.- Returns:
- caller id
-
getScopeType
public java.lang.String getScopeType()
Getter for scope type.- Returns:
- the scopeType
-
setScopeType
public void setScopeType(java.lang.String scopeType)
Setter for scope type.- Parameters:
scopeType- the scopeType to set
-
isBackendAvailable
public boolean isBackendAvailable() throws BackendExceptionDescription copied from interface:JCoConnectionReturnstrueif the backend is available the connection is connected to.- Specified by:
isBackendAvailablein interfaceJCoConnection- Returns:
trueif the backend is available, otherwisefalse- Throws:
BackendException-BackendException
-
isBackendOffline
public boolean isBackendOffline() throws BackendExceptionDescription copied from interface:JCoConnectionReturnstrueif the backend is switched offline the connection is connected to.- Specified by:
isBackendOfflinein interfaceJCoConnection- Returns:
trueif the backend is switched offline, otherwisefalse- Throws:
BackendException-BackendException
-
handleCommunicationExceptionAndDestroyConnection
protected void handleCommunicationExceptionAndDestroyConnection(java.lang.Exception e)
Handles the Communication JCoException and destroy Stateful connection.- Parameters:
e- JCoException
-
getRFCDestination
protected RFCDestination getRFCDestination(java.lang.String destinationName)
Returns the RFC Destination for the requested name.- Parameters:
destinationName- destination name- Returns:
RFCDestination
-
-