KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > ipanema > store > ProductFactory


1 /*
2  * Created on 30.10.2004
3  */

4 package com.nightlabs.ipanema.store;
5
6 import com.nightlabs.ModuleException;
7
8 /**
9  * A ProductFactory can be assigned to a product type and is then responsible
10  * to create product instances. If a product type does not have a productFactory
11  * assigned, it is not able to create product instances on the fly.
12  *
13  * @author Marco Schulze - marco at nightlabs dot de
14  *
15  * @jdo.persistence-capable
16  * identity-type = "application"
17  * objectid-class = "com.nightlabs.ipanema.store.id.ProductFactoryID"
18  * detachable = "true"
19  *
20  * @jdo.inheritance strategy = "new-table"
21  */

22 public abstract class ProductFactory
23 {
24     /**
25      * @jdo.field primary-key="true"
26      * @jdo.column length="100"
27      */

28     private String JavaDoc organisationID;
29
30     /**
31      * @jdo.field primary-key="true"
32      * @jdo.column length="100"
33      */

34     private String JavaDoc productFactoryID;
35
36     protected ProductFactory() { }
37     
38     public ProductFactory(String JavaDoc organisationID, String JavaDoc productFactoryID)
39     {
40         if (organisationID == null)
41             throw new NullPointerException JavaDoc("organisationID");
42         this.organisationID = organisationID;
43
44         if (productFactoryID == null)
45             throw new NullPointerException JavaDoc("productFactoryID");
46         this.productFactoryID = productFactoryID;
47     }
48
49     /**
50      * Overwrite this method to create an instance of the given product type.
51      *
52      * @param productType The type for which to create an instance.
53      * @return Returns a new Instance of the given productType
54      * @throws ModuleException
55      */

56     public abstract Product createProduct(Product productType)
57         throws ModuleException;
58
59 }
60
Popular Tags