TOC

Creating the Custom BOL Domain

Shows how to create a custom BOL domain and how to create your own custom aspect types.
Step 1: Extending the DomainAdapter
Step 2: Making the Domain Accessible
Step 3: Implement the Domain Factory
Step 4: Create custom aspect types
TOP | Step1: Extending the DomainAdpater
The first step in creating your own Domain is the extend org.cougaar.core.domain.DomainAdapter:
public class BOLDomain extends DomainAdapter {
   
    /**
     * Get the Domain Name
     *
     * @return Domain name
     */
    public String getDomainName() {
        return "BOLDomain";
    }


    /**
     * Load the domain and custom aspect types used throughout BOL
     */
    public void load() {
        super.load();
     
    }


   


    /**
     * Load BOLFactory
     */
    protected void loadFactory() {
        

    }


    /**
     * Load Logic Providers
     */
    protected void loadLPs() {
    }


    /**
     * Load XPlan
     */
    protected void loadXPlan() {
       

    }
}			
			
This implementation does not provide any real implementation except for the returning of "BOLDomain" as the Doman's name. This name will be used to reference the BOLDomain in the LDMDomains.ini file:
Step 2: Making the Domain Accessible
In order for the BOLDomain to be used, it needs to be added to the LDMDomain.ini file:


BOLDomain=org.cougaar.tutorials.booksonline.domain.BOLDomain

Step 3: Implement the Domain Factory
The BOLDomain needs a Factory to create the custom Assets created for use within the application. This is done by implementing the org.cougaar.core.domain.Factory interface:


public class BOLFactory implements Factory {
    /**
     * Creates a new BOLFactory object.
     */
    public BOLFactory() {
    }


    /**
     * Creates a new BOLFactory object.
     *
     * @param pf PlanningFactory
     */
    public BOLFactory(PlanningFactory pf) {
        pf.addAssetFactory(new org.cougaar.tutorial.booksonline.assets.AssetFactory());
        pf.addPropertyGroupFactory(new org.cougaar.tutorial.booksonline.assets.PropertyGroupFactory());

    }
}
The BOLFactory is a simple factory that adds the BOL property groups and assets to the PlanningFactory.
Now, the factory needs to be loaded by the BOLDomain. The DomainAdapter contains a loadFactory method to do this. Override the loadFactory method:


 /**
     * Load BOLFactory
     */
    protected void loadFactory() {
        DomainBindingSite bindingSite = (DomainBindingSite) getBindingSite();
        DomainService ds = (DomainService) bindingSite.getServiceBroker()
                                                      .getService(this,
                DomainService.class, null);
        setFactory(new BOLFactory((PlanningFactory) ds.getFactory("planning")));

    }