RequestT
- The type of the request to execute.RequestResultT
- The type of the result to return.public class JCoTransaction<RequestT extends AbstractRemoteFunctionRequest<RequestT,RequestResultT>,RequestResultT extends AbstractRemoteFunctionRequestResult<RequestT,RequestResultT>> extends Object implements Transaction<RequestT,RequestResultT>
Transaction
interface to be used for JCo queries.Constructor and Description |
---|
JCoTransaction(String destinationName,
Supplier<RequestResultT> requestResultFactory)
Constructs a
JCoTransaction for the given destinationName and requestResultFactory . |
Modifier and Type | Method and Description |
---|---|
void |
after()
This method gets called *in any case* after the transactional calls are done.
|
void |
before(Destination destination,
RequestT request)
This method gets called before anything else gets called in the
RemoteFunctionRequestExecutor . |
void |
commit(Destination destination,
RequestT request)
If
Transaction.execute(Destination, AbstractRemoteFunctionRequest) succeeded, this method is called to actually
commit the changes. |
RequestResultT |
execute(Destination destination,
RequestT request)
The actual logic to be executed.
|
protected List<com.sap.cloud.sdk.s4hana.connectivity.rfc.AbstractRemoteFunctionRequestResult.Result> |
getReturnParameterResults(RequestResultT result) |
void |
rollback(Destination destination,
RequestT request)
If there was a problem with
Transaction.execute(Destination, AbstractRemoteFunctionRequest) or
Transaction.commit(Destination, AbstractRemoteFunctionRequest) this method will get called to rollback any unwanted
changes. |
public JCoTransaction(@Nonnull String destinationName, @Nonnull Supplier<RequestResultT> requestResultFactory) throws RemoteFunctionException
JCoTransaction
for the given destinationName
and requestResultFactory
.destinationName
- Name of the destination to be used.requestResultFactory
- Provider to be used to create a RequestResultT
object.RemoteFunctionException
- If there was an error while getting the actual destionation for the given destinationName
.public void before(@Nonnull Destination destination, @Nonnull RequestT request)
Transaction
RemoteFunctionRequestExecutor
.before
in interface Transaction<RequestT extends AbstractRemoteFunctionRequest<RequestT,RequestResultT>,RequestResultT extends AbstractRemoteFunctionRequestResult<RequestT,RequestResultT>>
destination
- The Destination
of this call.request
- The AbstractRemoteFunctionRequest
going to be executed.@Nonnull public RequestResultT execute(@Nonnull Destination destination, @Nonnull RequestT request) throws RemoteFunctionException
Transaction
execute
in interface Transaction<RequestT extends AbstractRemoteFunctionRequest<RequestT,RequestResultT>,RequestResultT extends AbstractRemoteFunctionRequestResult<RequestT,RequestResultT>>
destination
- The Destination
of this call.request
- The AbstractRemoteFunctionRequest
going to execute.AbstractRemoteFunctionRequestResult
created by the request.RemoteFunctionException
protected List<com.sap.cloud.sdk.s4hana.connectivity.rfc.AbstractRemoteFunctionRequestResult.Result> getReturnParameterResults(RequestResultT result)
public void commit(@Nonnull Destination destination, @Nonnull RequestT request) throws RequestExecutionException
Transaction
Transaction.execute(Destination, AbstractRemoteFunctionRequest)
succeeded, this method is called to actually
commit the changes.commit
in interface Transaction<RequestT extends AbstractRemoteFunctionRequest<RequestT,RequestResultT>,RequestResultT extends AbstractRemoteFunctionRequestResult<RequestT,RequestResultT>>
destination
- The Destination
of this call.request
- The AbstractRemoteFunctionRequest
that was executed.RequestExecutionException
- If an exception occurred during the commit
implementation.public void rollback(@Nonnull Destination destination, @Nonnull RequestT request) throws RequestSerializationException, RequestExecutionException
Transaction
Transaction.execute(Destination, AbstractRemoteFunctionRequest)
or
Transaction.commit(Destination, AbstractRemoteFunctionRequest)
this method will get called to rollback any unwanted
changes.rollback
in interface Transaction<RequestT extends AbstractRemoteFunctionRequest<RequestT,RequestResultT>,RequestResultT extends AbstractRemoteFunctionRequestResult<RequestT,RequestResultT>>
destination
- The Destination
of this call.request
- The AbstractRemoteFunctionRequest
that was executed.RequestExecutionException
- If an exception occurred during the rollback
implementation.RequestSerializationException
public void after() throws RemoteFunctionException
Transaction
after
in interface Transaction<RequestT extends AbstractRemoteFunctionRequest<RequestT,RequestResultT>,RequestResultT extends AbstractRemoteFunctionRequestResult<RequestT,RequestResultT>>
RemoteFunctionException
- If an exception occurred during the after
implementation.Copyright © 2020 SAP SE. All rights reserved.