Skip to end of banner
Go to start of banner

Process Classes

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 12 Next »

Process Classes

Process classes are Controller 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.

Creating the Process Classes

In this example, we are going to implement a process class that will create a number of installed items.. The first thing to do is to create an EJB that will handle our process class. In order to create our class we must first decide the name of the package to place it in. Based on the business structure, the respective packages should be created. Based on CRM.COM naming conventions, all process classes are stored in the com.crm.process package. Based on the module we are implementing, further packages are then created in here.

 

In this case, we will create the package com.crm.process.inventory that will contain the module's process classes, and create the CRMProcessInstalledItemBean.java class.

 

 Creating CRMProcessInstalledItemBean.java

 

Note that on EJB creation, we also specify the super class of the class we are creating, depending on the business logic of our class. In this case we select the com.crm.process.CRMProcess as the super class.

 

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

createInstalledItems
    /**
     * 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 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.

  • No labels