Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Panel
nameidblue0

Process classes are Controller classes are classes used to implement all the process flows by calling the business objects. Basically, they are used to implement any batch, background or interactive process in the system. We also use EJBs (Stateless Session Beans) for the process classes as well to implement the process functionality. 


What does this section cover?

Table of Contents

Creating the Process Classes

In this example, we are going to implement a process class that will create a number of installed items. All process classes should be placed under com.crm.process.* named packages and , extend either com.crm.process.CRMProcess or one of its subclasses  and follow this naming convention: CRMProcess<entityname>Bean.java. Classes created for processes handled by the scheduler, should scheduler should extend com.crm.process.CRMProcessRunBean. 

Expand
titleCreating CRMProcessInstalledItemBean.java

Image RemovedImage Added

Image Removed

 

 

Image Added

Implementing the Process Flow

To implement the desired process flow we add the corresponding methods.

Code Block
languagejava
themeEclipse
languagefirstlinejava1
titlecreateInstalledItems
firstline1
collapsetrue
    /**
     * Creates a number of installed items.
     * 
     * @param numberOfInstalledItems - the number of installed items to construct
     * @return a list of installed items
     * @throws Exception
     */
    public ArrayList<CRMDO> createInstalledItems(Integer numberOfInstalledItems) throws Exception {
    	
    	ArrayList<CRMDO> installedItems = new ArrayList<CRMDO>();
    	
    	for (int i=0; i<numberOfInstalledItems; i++)
    	{
    		CRMDOInstalledItem installedItem = (CRMDOInstalledItem)installedItemBean.construct();
    		
    		installedItem.setSerialNumber(newGuid());
    		
    		installedItem = (CRMDOInstalledItem)installedItemBean.validateAndSave(installedItem);
    		
    		installedItems.add(installedItem);
    	}
    	
    	return installedItems;
    }
 

 


Note that our method does not contain any complex business logic. In short, it executes a loop and for each iteration, it uses the business logic provided by the installedItemBean  installedItemBean(com.crm.businessobject.inventory.CRMBOInstalledItemBean) business object and sets a new serial number on the data objects returned. When the loop completes, it returns a list of the installed item data objects created.

EJB Binding File

In order for the EJB class to be bound to the WebSphere Application Server, it must be specified in the ibm-ejb-jar-bnd.xml binding file 

Code Block
languagexml
themeEclipse
titleibm-ejb-jar-bnd.xml
collapsetrue
<ejb-jar-bnd>
    ...
	<!-- CRMProcess > inventory -->
	<session name="CRMProcessInstalledItemBean" simple-binding-name="ejb/CRMProcessInstalledItem" />
	...
</ejb-jar-bnd>


For more information on creating custom process classes, go to Customize existing business logic. 

To start implementing the view layer, go to Developing the View layer