Internal Custom Java Automator
A basic internal custom Java automator has the following characteristics:
-
The name of the custom automation package. For example:
package com.mslv.oms.sample.atm_frame;
-
Import statements required for this custom automation plug-in. For example:
import com.mslv.oms.automation.plugin.*; import com.mslv.oms.automation.*; import java.rmi.*;
-
An arbitrary class name that extends AbstractAutomator. For the automation framework to call an internal custom Java automator, the plug-in must extend the AbstractAutomator class. This class resides in the com.mslv.automation.plugin package. For example:
public class MyPlugin extends AbstractAutomator {
-
The required run method, as dictated by the parent class, AbstractAutomator
protected void run(String inputXML, AutomationContext context) throws com.mslv.oms.automation.AutomationException {
-
Cast the AutomationContext object to the TaskContext object. This example assumes that the custom automation plug-in is triggered by an automated task, so the code is expecting the context input an argument to be an instance of the TaskContext object.
TaskContext taskContext = (TaskContext)context;
Note:
You can use the TaskContext object to do many things, such as complete the task, suspend it, and so on. For more information about this class, see the OSM Javadocs.
-
Call a method on the TaskContext object to retrieve the task name.
String taskName = taskContext.getTaskMnemonic();
-
Add any require business logic.
this.performAutomation(taskname);
The following example shows the minimal amount of code required for a custom automation plug-in to run. This example assumes that it is triggered by an automated task.
package com.mslv.oms.sample.atm_frame; import com.mslv.oms.automation.plugin.*; import com.mslv.oms.automation.*; import java.rmi.*; public class MyPlugin extends AbstractAutomator { protected void run(String inputXML, AutomationContext context) throws com.mslv.oms.automation.AutomationException { try { TaskContext taskContext = (TaskContext)context; String taskName = taskContext.getTaskMnemonic(); this.performAutomation(taskname); catch(RemoteException ex) { throw new AutomationException(ex); } catch(AutomationException x) { throw x; } } }