KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > pim > spec > DataManagerFactory


1 package org.enhydra.pim.spec;
2
3 import org.enhydra.pim.business.DataManagerI;
4 import org.enhydra.pim.exception.EnhydraPimException;
5
6 /**
7  * @author p
8  *
9  * TODO To change the template for this generated type comment go to Window -
10  * Preferences - Java - Code Style - Code Templates
11  */

12 public class DataManagerFactory {
13
14     private static final String JavaDoc EJB_LOCAL_HOME = "org.enhydra.pim.ejb.session.DataManagerLocalHome";
15
16     private static final String JavaDoc EJB_UTIL_CLASS_NAME = "org.enhydra.pim.ejb.session.DataManagerUtil";
17
18     private static DataManagerI dataManager = null;
19
20     /**
21      * Create a DataManager
22      */

23
24     public static DataManagerI getDataManager() throws EnhydraPimException {
25
26         if (dataManager == null) {
27             try {
28                 if (SpecUtil.useEjb) {
29                     Object JavaDoc manager = SpecUtil.getLocalEjbManagerObject(EJB_UTIL_CLASS_NAME, EJB_LOCAL_HOME);
30                     dataManager = (DataManagerI) manager;
31                     return dataManager;
32                 }
33                 Class JavaDoc objectClass = Class.forName("org.enhydra.pim.business.DataManager");
34                 dataManager = (DataManagerI) objectClass.newInstance();
35
36             } catch (Exception JavaDoc ex) {
37                 System.out.println("Error on creating the DataManager object" + ex);
38             }
39         }
40         return dataManager;
41     }
42
43 }
Popular Tags