KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > ejosa > piggybank > spec > business > CoinFactory


1 /**
2  * Title: EJOSA - Enterprise Java Open Source Architecture
3  * My Piggy Bank Example
4  * Description: Specification Object
5  * Copyright: Copyright (c) 2003 by B. Lofi Dewanto, T. Menzel
6  * Company: University of Muenster, HTWK Leipzig
7  * @author B. Lofi Dewanto, T. Menzel
8  * @version 1.2
9  */

10 package net.sourceforge.ejosa.piggybank.spec.business;
11
12 /**
13  * The business object factory.
14  *
15  * @author B. Lofi Dewanto, T. Menzel
16  * @version 1.2
17  */

18 public class CoinFactory {
19     /**
20      * Constructor can't be used.
21      */

22     private CoinFactory() {
23     }
24
25     /**
26      * Create a coin as state object/value object/data transfer object
27      */

28     public static Coin createCoin(String JavaDoc fullClassName) {
29         Coin result = null;
30         Class JavaDoc objectClass = null;
31
32         try {
33             // Create the value object
34
objectClass = Class.forName(fullClassName);
35             result = (Coin) objectClass.newInstance();
36         } catch (Exception JavaDoc ex) {
37             System.out.println("Error on creating the object" + ex);
38         }
39
40         return result;
41     }
42 }
Popular Tags