Revision 4335
Added by daigle over 15 years ago
MetaCatUtil.java | ||
---|---|---|
32 | 32 |
import java.io.IOException; |
33 | 33 |
import java.io.PrintWriter; |
34 | 34 |
import java.net.MalformedURLException; |
35 |
import java.util.HashMap; |
|
36 | 35 |
import java.util.Hashtable; |
37 |
import java.util.Properties; |
|
38 | 36 |
import java.util.Stack; |
39 | 37 |
import java.util.Vector; |
40 |
import java.util.regex.PatternSyntaxException; |
|
41 | 38 |
|
42 | 39 |
import org.apache.log4j.Logger; |
43 | 40 |
|
... | ... | |
69 | 66 |
private static char separator = '.'; |
70 | 67 |
|
71 | 68 |
static { |
72 |
// Determine our db adapter class and create an instance of that class |
|
73 | 69 |
try { |
74 |
dbAdapter = (AbstractDatabase) createObject(PropertyService.getProperty("database.adapter")); |
|
75 |
} catch (Exception e) { |
|
76 |
System.err.println("Error in MetaCatUtil static block:" |
|
77 |
+ e.getMessage()); |
|
78 |
e.printStackTrace(); |
|
79 |
} |
|
80 |
|
|
81 |
try { |
|
82 | 70 |
separator = PropertyService.getProperty("document.accNumSeparator").charAt(0); |
83 | 71 |
} catch (PropertyNotFoundException pnfe) { |
84 | 72 |
logMetacat.error("Could not retrieve account number separator. " |
85 | 73 |
+ "Separator set to '.' : " + pnfe.getMessage()); |
86 | 74 |
} |
87 | 75 |
} |
88 |
|
|
89 |
/** |
|
90 |
* Instantiate a class using the name of the class at runtime |
|
91 |
* |
|
92 |
* @param className the fully qualified name of the class to instantiate |
|
93 |
*/ |
|
94 |
public static Object createObject(String className) throws Exception |
|
95 |
{ |
|
96 | 76 |
|
97 |
Object object = null; |
|
98 |
try { |
|
99 |
Class classDefinition = Class.forName(className); |
|
100 |
object = classDefinition.newInstance(); |
|
101 |
} catch (InstantiationException e) { |
|
102 |
throw e; |
|
103 |
} catch (IllegalAccessException e) { |
|
104 |
throw e; |
|
105 |
} catch (ClassNotFoundException e) { |
|
106 |
throw e; |
|
107 |
} |
|
108 |
return object; |
|
109 |
} |
|
110 |
|
|
111 | 77 |
/** |
112 | 78 |
* Utility method to parse the query part of a URL into parameters. This |
113 | 79 |
* method assumes the format of the query par tof the url is an ampersand |
Also available in: Unified diff
Move the DBAdaptor accessor into a DatabaseService class