Creating Business Components
Business Components provide a mechanism to provide non-persistent business logic (as opposed to business entities that add to persistent objects). An example business component is as follows:
/**
* Component used to query for {@link Person} instances based on various
* predefined criteria.
*
* @BusinessComponent
* (customizationReplaceable = false)
*/
public class PersonFinders_Impl
extends GenericBusinessComponent
implements PersonFinders
/**
* @param nameType a name type
* @return count of names by name type
*
* @BusinessMethod (customizationCallable = true)
*/
public int findCountByNameType(Lookup nameType) {
Query query = createQuery
("FROM PersonName name where name.nameType = :type");
query.bindLookup("type", nameType);
return (int) query.listSize();
}
To add a new component:
- Create a new implementation class.
- Specify appropriate annotations for a business component implementation class.
- Code business methods.
- Specify appropriate annotations for business methods.
- Create a JUnit test.
- Generate artifacts.
- Run JUnit tests.
- Deploy to runtime.
- Test in runtime.