01: package com.xoetrope.service;
02:
03: import java.lang.reflect.Constructor;
04: import net.xoetrope.optional.data.XOptionalDataSource;
05: import net.xoetrope.xui.XProject;
06:
07: /**
08: *
09: * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
10: * the GNU Public License (GPL), please see license.txt for more details. If
11: * you make commercial use of this software you must purchase a commercial
12: * license from Xoetrope.</p>
13: * <p> $Revision: 1.7 $</p>
14: */
15: public class ModelHelper {
16: public static XOptionalDataSource getDataSource(
17: XProject currentProject) {
18: XOptionalDataSource modelDataSource = null;
19: String startDataSource = currentProject
20: .getStartupParam("XDataSourceClass");
21: try {
22: if (startDataSource != null) {
23: Class dsClass = Class.forName(startDataSource.trim());
24: Class[] classes = new Class[] { currentProject
25: .getClass() };
26: Constructor con = dsClass.getConstructor(classes);
27: modelDataSource = (XOptionalDataSource) con
28: .newInstance(new Object[] { currentProject });
29: } else
30: modelDataSource = new XOptionalDataSource(
31: currentProject);
32: } catch (Exception ex) {
33: ex.printStackTrace();
34: }
35:
36: return modelDataSource;
37: }
38:
39: }
|