Source Code Cross Referenced for ChimeraProperties.java in  » Workflow-Engines » pegasus-2.1.0 » org » griphyn » vdl » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Workflow Engines » pegasus 2.1.0 » org.griphyn.vdl.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * This file or a portion of this file is licensed under the terms of
003:         * the Globus Toolkit Public License, found in file GTPL, or at
004:         * http://www.globus.org/toolkit/download/license.html. This notice must
005:         * appear in redistributions of this file, with or without modification.
006:         *
007:         * Redistributions of this Software, with or without modification, must
008:         * reproduce the GTPL in: (1) the Software, or (2) the Documentation or
009:         * some other similar material which is provided with the Software (if
010:         * any).
011:         *
012:         * Copyright 1999-2004 University of Chicago and The University of
013:         * Southern California. All rights reserved.
014:         */
015:        package org.griphyn.vdl.util;
016:
017:        import java.io.IOException;
018:        import java.io.File;
019:        import java.util.*;
020:
021:        import org.griphyn.common.util.Currently;
022:        import org.griphyn.common.util.VDSProperties;
023:        import org.griphyn.vdl.util.Logging;
024:
025:        /**
026:         * A Central Properties class that keeps track of all the properties
027:         * used by Chimera. All other classes access the methods in this class
028:         * to get the value of the property. It access the VDSProperties class
029:         * to read the property file.
030:         *
031:         * @author Jens-S. Vöckler
032:         * @author Yong Zhao
033:         * @version $Revision: 364 $
034:         *
035:         * @see org.griphyn.common.util.VDSProperties
036:         */
037:        public class ChimeraProperties {
038:            /**
039:             * Default values for schema locations.
040:             */
041:            public static final String VDL_SCHEMA_LOCATION = "http://www.griphyn.org/chimera/vdl-1.24.xsd";
042:
043:            public static final String DAX_SCHEMA_LOCATION = "http://pegasus.isi.edu/schema/dax-2.0.xsd";
044:
045:            public static final String IVR_SCHEMA_LOCATION = "http://pegasus.isi.edu/schema/iv-2.0.xsd";
046:
047:            public static final String DB_ALL_PREFIX = "pegasus.catalog.*.db";
048:
049:            public static final String DBDRIVER_ALL_PREFIX = "pegasus.catalog.*.db.driver";
050:
051:            /**
052:             * Implements the Singleton access.
053:             */
054:            private static ChimeraProperties m_instance = null;
055:
056:            /**
057:             * The value of the PEGASUS_HOME environment variable.
058:             */
059:            private String m_home;
060:
061:            /**
062:             * The object holding all the properties pertaining
063:             * to the VDS system.
064:             */
065:            private VDSProperties m_props;
066:
067:            /**
068:             * To get a reference to the the object.
069:             */
070:            public static ChimeraProperties instance() throws IOException,
071:                    MissingResourceException {
072:                if (m_instance == null) {
073:                    m_instance = new ChimeraProperties();
074:                }
075:                return m_instance;
076:            }
077:
078:            /**
079:             * Constructor that is called only once, when creating the
080:             * Singleton instance.
081:             */
082:            private ChimeraProperties() throws IOException,
083:                    MissingResourceException {
084:                m_props = getVDSPropertiesInstance();
085:                m_home = m_props.getVDSHome();
086:            }
087:
088:            /**
089:             * Gets the handle to the property file.
090:             */
091:            private VDSProperties getVDSPropertiesInstance()
092:                    throws IOException, MissingResourceException {
093:                return VDSProperties.instance();
094:            }
095:
096:            /**
097:             * Set up logging
098:             */
099:            public void setupLogging(Logging logger) {
100:                for (Enumeration e = m_props.propertyNames(); e
101:                        .hasMoreElements();) {
102:                    String key = (String) e.nextElement();
103:                    if (key.equals("vds.timestamp.format")) {
104:                        Currently c = new Currently(this .m_props
105:                                .getProperty(key));
106:                        logger.setDateFormat(c);
107:                    } else if (key.startsWith("vds.log.")) {
108:                        String subkey = key.substring(8);
109:                        logger.log("default", 2, "found \"" + key + "\" -> "
110:                                + subkey);
111:                        logger.register(subkey, this .m_props.getProperty(key));
112:                    } else if (key.startsWith("vds.verbose")) {
113:                        int verbose = Integer.parseInt(this .m_props
114:                                .getProperty(key));
115:                        logger.log("default", 2, "verbosity mode = " + verbose);
116:                        logger.setVerbose(verbose);
117:                    }
118:                }
119:            }
120:
121:            /**
122:             * Accessor to $PEGASUS_HOME/etc. The files in this directory have a low
123:             * change frequency, are effectively read-only, they reside on a
124:             * per-machine basis, and they are valid usually for a single user.
125:             *
126:             * @return the "etc" directory of the VDS runtime system.
127:             */
128:            public File getSysConfDir() {
129:                return m_props.getSysConfDir();
130:            }
131:
132:            /**
133:             * Accessor: Obtains the root directory of the VDS/Chimera runtime
134:             * system.
135:             *
136:             * @return the root directory of the VDS runtime system, as initially
137:             * set from the system properties.
138:             */
139:            public String getVDSHome() {
140:                return m_props.getVDSHome();
141:            }
142:
143:            /**
144:             * Accessor to $PEGASUS_HOME/var. The files in this directory have a high
145:             * change frequency, are effectively read-write, they reside on a
146:             * per-machine basis, and they are valid usually for a single user.
147:             *
148:             * @return the "var" directory of the VDS runtime system.
149:             */
150:            public File getLocalStateDir() {
151:                return m_props.getLocalStateDir();
152:            }
153:
154:            /**
155:             * Accessor to $PEGASUS_HOME/share. The files in this directory have a low
156:             * change frequency, are effectively read-only, can be shared via a
157:             * networked FS, and they are valid for multiple users.
158:             *
159:             * @return the "share" directory of the VDS runtime system.
160:             */
161:            public File getDataDir() {
162:                return m_props.getDataDir();
163:            }
164:
165:            /**
166:             * Get the fully qualified class name of the VDC-implementing
167:             * database schema. If no properties are configured, it returns
168:             * the file-based VDC-schema implementation.
169:             *
170:             * @return the fully-qualified name of the class which implements
171:             * the VDC according to properties.
172:             * @see org.griphyn.vdl.dbschema.SingleFileSchema
173:             */
174:            public String getVDCSchemaName() {
175:                // load the default schema name - default is to use the file based
176:                // schema.
177:                String schemaName = m_props.getProperty("vds.db.vdc.schema",
178:                        "SingleFileSchema");
179:                if (schemaName.indexOf('.') == -1)
180:                    schemaName = "org.griphyn.vdl.dbschema." + schemaName;
181:
182:                // always returns something
183:                return schemaName;
184:            }
185:
186:            /**
187:             * Obtains the fully qualified class name of the PTC-implementing
188:             * database schema.
189:             *
190:             * @return the fully-qualified name of the class which implements
191:             * the PTC according to properties, or <code>null</code>, if no
192:             * such class exists.
193:             */
194:            public String getPTCSchemaName() {
195:                // load the default schema name - default is to use the file based
196:                // schema.
197:                //this should not have a default value because if this property is not set
198:                // the invocation records should not be populated to DB.
199:                String schemaName = m_props
200:                        .getProperty("pegasus.catalog.provenance");
201:                if (schemaName != null && schemaName.indexOf('.') == -1)
202:                    schemaName = "org.griphyn.vdl.dbschema." + schemaName;
203:
204:                // may return null
205:                return schemaName;
206:            }
207:
208:            /**
209:             * Obtains the fully qualified class name of the WF-implementing
210:             * database schema.
211:             *
212:             * @return the fully-qualified name of the class which implements the
213:             * WF according to properties, or <code>null</code>, if no such class
214:             * exists.
215:             */
216:            public String getWFSchemaName() {
217:                // load the default schema name
218:                String schemaName = m_props.getProperty("vds.db.wf.schema");
219:                if (schemaName != null && schemaName.indexOf('.') == -1)
220:                    schemaName = "org.griphyn.vdl.dbschema." + schemaName;
221:
222:                // may return null
223:                return schemaName;
224:            }
225:
226:            /**
227:             * Gets the location the VDLx XML schema from properties, if available.
228:             * Please note that the schema location URL in the instance document
229:             * is only a hint, and may be overriden by the findings of this method.
230:             *
231:             * @return a location pointing to a definition document of the XML
232:             * schema that can read VDLx. Result may be null, if such a document
233:             * is unknown or unspecified.
234:             * @see org.griphyn.vdl.parser.VDLxParser#VDLxParser( String )
235:             */
236:            public String getVDLSchemaLocation() {
237:                // treat URI as File, yes, I know - I need the basename
238:                File uri = new File(VDL_SCHEMA_LOCATION);
239:                File vdlx = // create a pointer to the default local position
240:                new File(this .m_props.getSysConfDir(), uri.getName());
241:
242:                // Nota bene: vds.schema.vdl may be a networked URI...
243:                return m_props.getProperty("vds.schema.vdl", vdlx
244:                        .getAbsolutePath());
245:            }
246:
247:            /**
248:             * Gets the location of the DAX XML schema from properties, if available.
249:             * Please note that the schema location URL in the instance document
250:             * is only a hint, and may be overriden by the findings of this method.
251:             *
252:             * @return a location pointing to a definition document of the XML
253:             * schema that can read DAX. Result may be null, if such a document
254:             * is unknown or unspecified.
255:             * @see org.griphyn.vdl.parser.DAXParser#DAXParser( String )
256:             */
257:            public String getDAXSchemaLocation() {
258:                // treat URI as File, yes, I know - I need the basename
259:                File uri = new File(DAX_SCHEMA_LOCATION);
260:                File dax = // create a pointer to the default local position
261:                new File(m_props.getSysConfDir(), uri.getName());
262:
263:                // Nota bene: vds.schema.dax may be a networked URI...
264:                return m_props.getProperty("vds.schema.dax", dax
265:                        .getAbsolutePath());
266:            }
267:
268:            /**
269:             * Helps the load database to locate the invocation record XML schema,
270:             * if available. Please note that the schema location URL in the
271:             * instance document is only a hint, and may be overriden by the
272:             * findings of this method.
273:             *
274:             * @return a location pointing to a definition document of the XML
275:             * schema that can read DAX. Result may be null, if such a document
276:             * is unknown or unspecified.
277:             * @see org.griphyn.vdl.parser.InvocationParser#InvocationParser( String )
278:             */
279:            public String getPTCSchemaLocation() {
280:                // treat URI as File, yes, I know - I need the basename
281:                File uri = new File(IVR_SCHEMA_LOCATION);
282:                File ptc = // create a pointer to the default local position
283:                new File(m_props.getSysConfDir(), uri.getName());
284:
285:                // Nota bene: vds.schema.ptc may be a networked URI...
286:                return m_props.getProperty("pegasus.catalog.provenance", ptc
287:                        .getAbsolutePath());
288:            }
289:
290:            /**
291:             * Get the rc.data file location, which is used by shell planner
292:             *
293:             */
294:            public String getRCLocation() {
295:                File rcFile = new File(m_props.getLocalStateDir(), "rc.data");
296:                return m_props.getProperty("vds.db.rc", rcFile
297:                        .getAbsolutePath());
298:            }
299:
300:            /**
301:             * Get the tc.data file location, which is used by shell planner
302:             *
303:             */
304:            public String getTCLocation() {
305:                File tcFile = new File(m_props.getLocalStateDir(), "tc.data");
306:                return m_props.getProperty("vds.db.tc", tcFile
307:                        .getAbsolutePath());
308:            }
309:
310:            /**
311:             * Gets the name of the database schema name from the properties.
312:             *
313:             * @param dbSchemaPrefix is the database schema key name in the
314:             * properties file, which happens to be the pointer to the class
315:             * to load.
316:             * @return the database schema name, result may be null, if such
317:             * property is not specified.
318:             */
319:            public String getDatabaseSchemaName(String dbSchemaPrefix) {
320:                return m_props.getProperty(dbSchemaPrefix);
321:            }
322:
323:            /**
324:             * Gets then name of the database driver from the properties.
325:             * A specific match is preferred over the any match.
326:             *
327:             * @param dbDriverPrefix is the database schema key name in the
328:             * properties file, which happens to be the pointer to the class
329:             * to load.
330:             * @return the database driver name, result may be null, if such
331:             * property is not specified.
332:             */
333:            public String getDatabaseDriverName(String dbDriverPrefix) {
334:                return (dbDriverPrefix == null ? m_props
335:                        .getProperty(DBDRIVER_ALL_PREFIX) : m_props
336:                        .getProperty(dbDriverPrefix, m_props
337:                                .getProperty(DBDRIVER_ALL_PREFIX)));
338:            }
339:
340:            /**
341:             * Gets the Database URL from Properties file, the URL is a contact
342:             * string to the database. The URL contact string is removed from the
343:             * regular properties which are passed to the JDBC driver.
344:             *
345:             * @param dbDriverPrefix is the database schema key name.
346:             * @return the database url, result may be <code>null</code>, if the
347:             * driver URL is not specified.
348:             * @see #getDatabaseDriverProperties( String )
349:             */
350:            public String getDatabaseURL(String dbDriverPrefix) {
351:                return (dbDriverPrefix == null ?
352:                //pick pegasus.catalog.*.db.url
353:                m_props.getProperty(DB_ALL_PREFIX + ".url")
354:                        : m_props.getProperty(dbDriverPrefix + ".url",
355:                        //default value pegasus.catalog.*.db.url
356:                                m_props.getProperty(DB_ALL_PREFIX + ".url")));
357:            }
358:
359:            /**
360:             * Extracts a specific property key subset from the known properties.
361:             * The prefix is removed from the keys in the resulting dictionary.
362:             *
363:             * @param prefix is the key prefix to filter the properties by.
364:             * @return a property dictionary matching the filter key. May be
365:             * an empty dictionary, if no prefix matches were found.
366:             */
367:            public Properties matchingSubset(String prefix) {
368:                return m_props.matchingSubset(prefix, false);
369:            }
370:
371:            /**
372:             * Obtains database driver specific properties.
373:             *
374:             * @param dbDriverPrefix is the database driver property key prefix
375:             * for which to obtain properties.
376:             * @return a property set to be filled with driver specific
377:             * properties. May be null if no such properties specified.
378:             */
379:            public Properties getDatabaseDriverProperties(String dbDriverPrefix) {
380:                Properties result = new Properties(
381:                        matchingSubset(DB_ALL_PREFIX));
382:                if (dbDriverPrefix != null)
383:                    result.putAll(matchingSubset(dbDriverPrefix));
384:                result.remove("url"); // must not be passed to the JDBC driver
385:                return result;
386:            }
387:
388:            /**
389:             * Obtains the database schema specific properties.
390:             *
391:             * @param dbSchemaPrefix is the database schema key name in the
392:             * properties file
393:             * @return a property set to be filled with schema specific
394:             * properties. May be null if no such properties specified.
395:             */
396:            public Properties getDatabaseSchemaProperties(String dbSchemaPrefix) {
397:                return matchingSubset(dbSchemaPrefix);
398:            }
399:
400:            /**
401:             * Gets the name of the replica catalog implementating class from the
402:             * properties.
403:             *
404:             * @param dbReplicaPrefix is the replica catalog class name in the
405:             * properties file.
406:             * @return the replica catalog implementing class name, result may be
407:             * null, if such property is not specified.
408:             */
409:            public String getReplicaCatalogName(String dbReplicaPrefix) {
410:                return m_props.getProperty(dbReplicaPrefix);
411:            }
412:
413:            /**
414:             * Obtains all properties to handle the experimental replica catalog
415:             * interface.
416:             * @param dbReplicaPrefix is the prefix for the replica catalog's
417:             * implementation configuration.
418:             * @return all properties, excluding the prefix itself, for the RC.
419:             */
420:            public Properties getReplicaCatalogProperties(String dbReplicaPrefix) {
421:                return matchingSubset(dbReplicaPrefix);
422:            }
423:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.