You design and implement a post-processing class to handle information retrieved from scheduled processes once they have been initiated.
Your class must implement the initiatedProcess() callback method of the IGPScheduledInitiationPostProcessingInterface 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.
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.
See: Scheduling Process Initiation Using the GP API
● Deployed the post-processing class on the server before you can use it at runtime.
...
1. Create a post-processing class and implement the IGPScheduledInitiationPostProcessingInterface interface.
The class may be located in a different development component (DC). Make sure you specify its name and location when creating the process schedule.
2. Implement the initiatedProcess()method.
Retrieve the process initiation context and perform all relevant operations or mappings.
3. 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.
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.
The additional isNotificationSentOut() method is designed to check the status of due notifications.
...
Post-Processing Class Implementation |
package com.sap.test.caf.test.eu.gp.api.schedinst.postproc;
import java.util.Locale; import javax.naming.InitialContext; import javax.naming.NamingException; import com.sap.caf.eu.gp.model.svc.IGPService; import com.sap.caf.eu.gp.scheduling.api.IGPInitiationContext; import com.sap.caf.eu.gp.scheduling.api.IGPScheduledInitiationPostProcessingInterface;
public class ScheduledInitiationCallback implements IGPScheduledInitiationPostProcessingInterface {
// notification sent flag public static boolean notificationSentOut = false;
// implement the initiatedProcess() method public void initiatedProcess(IGPInitiationContext initiationcontext) { IGPService gpService = null; try { // get initial process context InitialContext ctxt = new InitialContext(); 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 public static boolean isNotificationSentOut() { return notificationSentOut; } }
|
In your application, you use the isNotificationSentOut()method to receive information about the notification status:
Calling a Post-Processing Class Method from an Application |
import com.sap.test.caf.test.eu.gp.api.schedinst.postproc.ScheduledInitiationCallback;
// check if notification is sent or not boolean sentOut = ScheduledInitiationCallback.isNotificationSentOut();
|