Development Using Java

Java Beans

Java beans are dragged from the Process Tree Pane and dropped into the GUI Design Pane (in the Process Studio window) to create the process definition file (.pmt). While executing the process in the Process Manager client, the Process Manager engine will instantiate all of the beans that are specified in the .pmt file.

A Java bean is very similar to any other Java class. A BeanInfo class is also required, in addition to the actual class. The BeanInfo class will expose the selected properties, methods, and fired events of the actual class.

Java beans can be made to utilize the rich set of APIs provided by the Process Manager Framework. All of the APIs provided by the Framework are encapsulated in the interface IHWMFrameWork. To make use of the Framework APIs, the Java beans must implement an interface called com.altair.hwm.interfaces.IHWMControl (or extend from a class that implements the above-mentioned interface).

After instantiating the bean, the Process Manager engine will check to see if the bean implements IHWMControl. If it does, the Process Manager engine will call the SetFrameWork method, and pass the IHWMFrameWork instance.

If the bean does not implement the IHWMControl interface, it simply does not get the handle to the IHWMFrameWork. However, the bean can work on its own.

The IHWMControl Interface

If the Java beans implement the interface called IHWMControl, they get the handle to IHWMFrameWork (The API interface).

The IHWMControl interface also requires a method called SetBeanName. The Process Manager engine will call this method to set the name of the bean instance. This will be the name of the bean set by the process author. This bean instance name will be very useful when multiple instances of the same bean are used in a process.

The beans implementing the IHWMControl interface will also implement a method called Play(), which will be called by the engine in the "Replay mode."

import com.altair.hwm.interfaces.*;
public class MyClass extends JButton
           implements IHWMControl, ActionListener

/**
* The framework interface that facilitates the communication between
* the controls and their container
*/
protected IHWMFrameWork m_hwmFrameWork = null;
protected String m_strBeanName = null;

/**
* Constructor
*/
public MyClass()

super();
this.setText("My Test");
this.addActionListener(this);
}

/**
* Callback for when the button is pressed
*/
public void actionPerformed(ActionEvent event)

DoSomething();
}

/**
* The main function wherein, something will be done when the
* button is pressed
*/
public void DoSomething()
{
}

/**
* This method is called by the HWPM engine to set the interface with
* which a bean can communicate directly with the HWPM classes.
* @param hwmFrameWork The interface with which a bean can
* communicate with HWPM.
*/
public void SetFrameWork(IHWMFrameWork hwmFrameWork)

m_hwmFrameWork = hwmFrameWork;
}

/**
* Set the name of the bean instance
* @param strBeanName The name of this bean as the framework knows it
* to be. Will be useful, if the bean chooses to scope its data in
* the datamodel - especially if multiple instances of the same bean
* appear in the process
*/
public void SetBeanName(String strBeanName)

m_strBeanName = strBeanName;
}

/**
* Invoked by the HWPM engine when the bean is being destroyed. Any
* uninitializations to be done, can be done here
*/
public void OnExit()
{
}

/**
* Invoked by the HWPM engine when all the beans are loaded and the
* application can run. Beans that need to perform some action once  
* all the beans are loaded can do it here. The container will call
* 'Run' on all the beans that have implemented the IHWMControl. The
* order will be:
* a> First call "Run" on all the beans in pages associated with a
*    task. Begin with the first task.
* b> Call 'Run' on rest of the pages (which are not associated with
*    a task). The pages are selected based on their order of
*    creation.
* c> Within a page, the beans are invoked depending on the order of
*    their creation.
*/
public void Run()
{
}

/**
* The play method needs to execute the functionaliy. This may be
* invoked in the replay mode.
*/
public void Play()
{
}
}