KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Created on May 27, 2005
3  *
4  * TODO To change the template for this generated file go to Window -
5  * Preferences - Java - Code Style - Code Templates
6  */

7 package org.enhydra.pim.spec;
8
9 import java.lang.reflect.InvocationTargetException JavaDoc;
10 import java.lang.reflect.Method JavaDoc;
11
12 /**
13  * @author P.Djojic May 27, 2005 12:26:04 AM
14  *
15  * TODO config
16  */

17 public class SpecUtil {
18
19     public static boolean useEjb = false;
20
21     /**
22      * @return
23      * @throws ClassNotFoundException
24      * @throws NoSuchMethodException
25      * @throws IllegalAccessException
26      * @throws InvocationTargetException
27      */

28     public static Object JavaDoc getLocalEjbManagerObject(String JavaDoc ejb_util_class_name, String JavaDoc ejb_local_home)
29                     throws ClassNotFoundException JavaDoc, NoSuchMethodException JavaDoc, IllegalAccessException JavaDoc,
30                     InvocationTargetException JavaDoc {
31
32         Class JavaDoc utilClass = Class.forName(ejb_util_class_name);
33         Method JavaDoc getLocalHomeMethod = utilClass.getMethod("getLocalHome", new Class JavaDoc[0]);
34         Object JavaDoc homeObject = getLocalHomeMethod.invoke(utilClass, new Class JavaDoc[0]);
35
36         Class JavaDoc localHomeClass = Class.forName(ejb_local_home);
37         Method JavaDoc createMethod = localHomeClass.getMethod("create", new Class JavaDoc[0]);
38
39         Object JavaDoc manager = createMethod.invoke(homeObject, new Class JavaDoc[0]);
40
41         return manager;
42     }
43     
44     /**
45      * @param useEjb The useEjb to set.
46      */

47     public static void useEjb(boolean value) {
48         
49         SpecUtil.useEjb = value;
50     }
51 }
Popular Tags