Implementing a Post-Processing Class with Callback
Use
You design and implement a post-processing class to handle information retrieved from scheduled processes once they have been initiated.
initiatedProcess() IGPScheduledInitiationPostProcessingInterfacecallback method of the interface. The method is called to deliver information about the process initiation context, such as template ID, version number, input parameters and so on.
Apart from that, the class implementation is custom and must be tailored to your application requirements. For example, once you have retrieved process details, you can map them to your own objects or process them in an application-specific way.
Prerequisites
To be able to use the post-processing class, you must have:
- Specified the name of the post-processing class during the creation of the process schedule at design time.
- Deployed the post-processing class on the server before you can use it at runtime.
Procedure
- Create a post-processing class and implement the
IGPScheduledInitiationPostProcessingInterface
interface. - Implement the
initiatedProcess()
method.Retrieve the process initiation context and perform all relevant operations or mappings.
- Implement the custom methods required for your application logic.
These are methods that you call from your application to retrieve information after it has been processed by the post-processing class.
Example
In the example, the initiated process is designed to send notifications if they are due.
The callback method of the post-processing class retrieves the initiation context of the process once it has been started. It also sets a notification flag to indicate that a notification was sent out.
isNotificationSentOut()method is designed to check the status of due notifications.
| Post-Processing Class Implementation |
|---|
packagecom.sap.test.caf.test.eu.gp.api.schedinst.postproc; importjava.util.Locale; importjavax.naming.InitialContext; importjavax.naming.NamingException; importcom.sap.caf.eu.gp.model.svc.IGPService; importcom.sap.caf.eu.gp.scheduling.api.IGPInitiationContext; importcom.sap.caf.eu.gp.scheduling.api.IGPScheduledInitiationPostProcessingInterface; publicclassScheduledInitiationCallbackimplementsIGPScheduledInitiationPostProcessingInterface {
// notification sent flag publicstaticbooleannotificationSentOut =false; // implement the initiatedProcess() method publicvoidinitiatedProcess(IGPInitiationContext initiationcontext) {
IGPService gpService =null; try{
// get initial process context InitialContext ctxt =newInitialContext(); gpService = (IGPService) ctxt.lookup( IGPService.JNDI_REGISTRY_NAME ); }catch(NamingException e) {
} // indicate that notification is sent out notificationSentOut =true; } // a custom method that checks if notification is sent out publicstaticbooleanisNotificationSentOut() {
returnnotificationSentOut; } } |
isNotificationSentOut()method to receive information about the notification status:
| Calling a Post-Processing Class Method from an Application |
|---|
importcom.sap.test.caf.test.eu.gp.api.schedinst.postproc.ScheduledInitiationCallback; // check if notification is sent or not booleansentOut = ScheduledInitiationCallback.isNotificationSentOut(); |