01: /*
02: This file is part of the PolePosition database benchmark
03: http://www.polepos.org
04:
05: This program is free software; you can redistribute it and/or
06: modify it under the terms of the GNU General Public License
07: as published by the Free Software Foundation; either version 2
08: of the License, or (at your option) any later version.
09:
10: This program is distributed in the hope that it will be useful,
11: but WITHOUT ANY WARRANTY; without even the implied warranty of
12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13: GNU General Public License for more details.
14:
15: You should have received a copy of the GNU General Public
16: License along with this program; if not, write to the Free
17: Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18: MA 02111-1307, USA. */
19:
20: package org.polepos.teams.jdo;
21:
22: import java.lang.reflect.*;
23:
24: public class Jdo {
25:
26: private final static JdoSettings sSettings = new JdoSettings();
27:
28: public static JdoSettings settings() {
29: return sSettings;
30: }
31:
32: /**
33: * runs the JDO enhancer
34: * @param arguments
35: */
36: public static void main(String[] args) {
37:
38: if (args == null || args.length == 0) {
39: System.out.println("Supply the class");
40: }
41:
42: enhanceObjectDB();
43: }
44:
45: /**
46: * ObjectDB is not supplied with the distribution
47: * @throws Exception
48: */
49: private static void enhanceObjectDB() {
50:
51: String clazz = "com.objectdb.Enhancer";
52: String method = "enhance";
53: Class[] types = new Class[] { String.class };
54: Object[] params = new Object[] { "org.polepos.teams.jdo.data.*" };
55:
56: try {
57: callByReflection(clazz, method, types, params);
58: } catch (Exception e) {
59: System.out.println("ObjectDB libraries are not included");
60: e.printStackTrace();
61: }
62: }
63:
64: private static void callByReflection(String enhancerClass,
65: String enhancerMethod, Class[] parameterTypes,
66: Object[] parameters) throws ClassNotFoundException,
67: SecurityException, NoSuchMethodException,
68: IllegalArgumentException, IllegalAccessException,
69: InvocationTargetException {
70: Class clazz = Class.forName(enhancerClass);
71: Method method = clazz.getMethod(enhancerMethod, parameterTypes);
72: method.invoke(null, parameters);
73: }
74:
75: }
|