01: /*
02: * This file or a portion of this file is licensed under the terms of
03: * the Globus Toolkit Public License, found in file GTPL, or at
04: * http://www.globus.org/toolkit/download/license.html. This notice must
05: * appear in redistributions of this file, with or without modification.
06: *
07: * Redistributions of this Software, with or without modification, must
08: * reproduce the GTPL in: (1) the Software, or (2) the Documentation or
09: * some other similar material which is provided with the Software (if
10: * any).
11: *
12: * Copyright 1999-2004 University of Chicago and The University of
13: * Southern California. All rights reserved.
14: */
15: package org.griphyn.vdl.directive;
16:
17: import org.griphyn.common.util.*;
18: import org.griphyn.vdl.parser.*;
19: import org.griphyn.vdl.classes.*;
20: import org.griphyn.vdl.dbschema.*;
21: import org.griphyn.vdl.util.Logging;
22:
23: import java.lang.reflect.*;
24: import java.io.IOException;
25: import java.util.MissingResourceException;
26:
27: /**
28: * The class dynamically loads a databaseschema
29: *
30: * @see org.griphyn.vdl.dbschema.DatabaseSchema
31: */
32: public class Connect extends Directive {
33: /**
34: * Constructor
35: */
36: public Connect() throws IOException, MissingResourceException {
37: super ();
38: }
39:
40: /**
41: * Connects the database backend. This is not done in the c'tor, because
42: * some apps don't need this heavyweight instructions.
43: *
44: * @param schemaName is the name of the schema class to load. This
45: * better be the fully-qualified name in-sync with properties.
46: *
47: * @return the schema class on success, null on non-exceptional failure.
48: * The result is to be cast to appropriate catalog classes.
49: *
50: * @see org.griphyn.vdl.util.ChimeraProperties#getVDCSchemaName()
51: * @see org.griphyn.vdl.util.ChimeraProperties#getPTCSchemaName()
52: */
53: public DatabaseSchema connectDatabase(String schemaName)
54: throws ClassNotFoundException, IOException,
55: NoSuchMethodException, InstantiationException,
56: IllegalAccessException, InvocationTargetException {
57: DatabaseSchema result = null;
58: m_logger.log("connect", 0, "Connecting the database backend");
59:
60: Object[] arg = new Object[1];
61: arg[0] = new String();
62:
63: return DatabaseSchema.loadSchema(schemaName, null, arg);
64: }
65:
66: /**
67: * Connects the database backend. This is not done in the c'tor, because
68: * some apps don't need this heavyweight instructions.
69: *
70: * @param schemaName is the name of the schema class to load. This
71: * better be the fully-qualified name in-sync with properties.
72: * @param dbDriverName is the name of the database driver
73: *
74: * @return the schema class on success, null on non-exceptional failure.
75: * The result is to be cast to appropriate catalog classes.
76: *
77: * @see org.griphyn.vdl.util.ChimeraProperties#getVDCSchemaName()
78: * @see org.griphyn.vdl.util.ChimeraProperties#getPTCSchemaName()
79: */
80: public DatabaseSchema connectDatabase(String schemaName,
81: String dbDriverName) throws ClassNotFoundException,
82: IOException, NoSuchMethodException, InstantiationException,
83: IllegalAccessException, InvocationTargetException {
84: DatabaseSchema result = null;
85: m_logger.log("connect", 0, "Connecting the database backend");
86:
87: Object[] arg = new Object[1];
88: arg[0] = (dbDriverName == null) ? new String() : dbDriverName;
89:
90: return DatabaseSchema.loadSchema(schemaName, null, arg);
91: }
92: }
|