Creating Business Components

Much like Business Entities, it is necessary to create an implementation class (*_​Impl) containing the actual logic that is then processed by the artifact generator. Below is an example that would be created by hand:


/**
 * 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();
    }
}

This example shows a finder component that is responsible for holding queries related to the person entity. These queries are not related to any particular person because, in that case, they would rightfully belong on the entity implementation class itself. Our (cooked up) example shows a single method that returns a count of PersonName instances by name type.

Let's look at various parts of the component: