Source Code Cross Referenced for ENV.java in  » Workflow-Engines » pegasus-2.1.0 » org » griphyn » cPlanner » namespace » 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.cPlanner.namespace 
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:
016:        package org.griphyn.cPlanner.namespace;
017:
018:        import java.util.Iterator;
019:        import java.util.Map;
020:        import java.util.StringTokenizer;
021:        import java.util.TreeMap;
022:
023:        import org.griphyn.cPlanner.classes.Profile;
024:        import org.griphyn.cPlanner.common.PegasusProperties;
025:
026:        /**
027:         * The environment namespace, that puts in the environment variables for the
028:         * transformation that is being run, through Condor. At present on the occurence
029:         * of a clash between the values of an environment variable the values are
030:         * overwritten with the order of preference in decreasing order being users
031:         * local properties, transformation catalog, pool file and the dax (vdl).
032:         * Later on operations like append , prepend would also be supported.
033:         *
034:         * @author Karan Vahi
035:         * @author Gaurang Mehta
036:         * @version $Revision: 50 $
037:         */
038:
039:        public class ENV extends Namespace {
040:
041:            /**
042:             * The name of the namespace that this class implements.
043:             */
044:            public static final String NAMESPACE_NAME = Profile.ENV;
045:
046:            /**
047:             * The name of the environment variable that specifies the path to the
048:             * proxy.
049:             */
050:            public static final String X509_USER_PROXY_KEY = "X509_USER_PROXY";
051:
052:            /**
053:             * The name of the environment variable that specifies the Gridstart PREJOB.
054:             */
055:            public static final String GRIDSTART_PREJOB = "GRIDSTART_PREJOB";
056:
057:            /**
058:             * The name of the implementing namespace. It should be one of the valid
059:             * namespaces always.
060:             *
061:             * @see Namespace#isNamespaceValid(String)
062:             */
063:            protected String mNamespace;
064:
065:            /**
066:             * The default constructor.
067:             * Note that the map is not allocated memory at this stage. It is done so
068:             * in the overloaded construct function.
069:             */
070:            public ENV() {
071:                mProfileMap = null;
072:                mNamespace = NAMESPACE_NAME;
073:            }
074:
075:            /**
076:             * The overloaded constructor.
077:             *
078:             * @param mp  map (possibly empty).
079:             */
080:            public ENV(Map mp) {
081:                mProfileMap = new TreeMap(mp);
082:                mNamespace = NAMESPACE_NAME;
083:            }
084:
085:            /**
086:             * Returns the name of the namespace associated with the profile implementations.
087:             *
088:             * @return the namespace name.
089:             * @see #NAMESPACE_NAME
090:             */
091:            public String namespaceName() {
092:                return mNamespace;
093:            }
094:
095:            /**
096:             * Constructs a new element of the format (key=value). It first checks if
097:             * the map has been initialised or not. If not then allocates memory first.
098:             *
099:             * @param key is the left-hand-side
100:             * @param value is the right hand side
101:             */
102:            public void construct(String key, String value) {
103:                if (mProfileMap == null)
104:                    mProfileMap = new TreeMap();
105:                mProfileMap.put(key, value);
106:            }
107:
108:            /**
109:             * This checks whether the key passed by the user is valid in the current
110:             * namespace or not. At present, for this namespace all the keys are
111:             * construed as valid as long as the value passed is not null.
112:             *
113:             * @param  key (left hand side)
114:             * @param  value (right hand side)
115:             *
116:             * @return Namespace.VALID_KEY
117:             * @return Namespace.NOT_PERMITTED_KEY
118:             *
119:             */
120:            public int checkKey(String key, String value) {
121:                if (key == null || value == null)
122:                    return Namespace.NOT_PERMITTED_KEY;
123:                return Namespace.VALID_KEY;
124:            }
125:
126:            /**
127:             * Converts the contents of the map into the string that can be put in the
128:             * Condor file for printing.
129:             */
130:            public String toString() {
131:                StringBuffer st = new StringBuffer();
132:                String key = null;
133:                String value = null;
134:
135:                Iterator it = (mProfileMap == null) ? null : mProfileMap
136:                        .keySet().iterator();
137:                if (it == null)
138:                    return null;
139:
140:                st.append("environment = ");
141:                while (it.hasNext()) {
142:                    key = (String) it.next();
143:                    value = (String) mProfileMap.get(key);
144:                    st.append(key).append("=").append(value).append(";");
145:                }
146:                st.append("\n");
147:                return st.toString();
148:
149:            }
150:
151:            /**
152:             * It puts in the namespace specific information specified in the properties
153:             * file into the namespace. The name of the pool is also passed, as many of
154:             * the properties specified in the properties file are on a per pool basis.
155:             *
156:             * @param properties  the <code>PegasusProperties</code> object containing
157:             *                    all the properties that the user specified at various
158:             *                    places (like .chimerarc, properties file, command line).
159:             * @param pool        the pool name where the job is scheduled to run.
160:             */
161:            public void checkKeyInNS(PegasusProperties properties, String pool) {
162:                //get from the properties for pool local
163:                String prop = pool.equalsIgnoreCase("local") ?
164:                //check if property in props file
165:                properties.getLocalPoolEnvVar()
166:                        : null;
167:
168:                if (prop != null) {
169:                    checkKeyInNS(prop);
170:                }
171:
172:            }
173:
174:            /**
175:             * It takes in key=value pairs separated by a ; and puts them into the
176:             * namespace after checking if they are valid or not.
177:             *
178:             * @param envString   the String containing the environment variables and
179:             *                    their values separated by a semi colon.
180:             */
181:            public void checkKeyInNS(String envString) {
182:                //sanity check
183:                if (envString == null)
184:                    return;
185:
186:                StringTokenizer st = new StringTokenizer(envString, ";");
187:                String name;
188:                String value;
189:                String keyValPair;
190:
191:                while (st.hasMoreTokens()) {
192:                    keyValPair = (String) st.nextToken(";");
193:                    if (keyValPair.trim().equalsIgnoreCase("null")) {
194:                        return;
195:                    }
196:                    StringTokenizer st1 = new StringTokenizer(keyValPair);
197:
198:                    name = st1.nextToken("=");
199:                    value = st1.nextToken();
200:
201:                    checkKeyInNS(name, value);
202:                }
203:
204:            }
205:
206:            /**
207:             * Merge the profiles in the namespace in a controlled manner.
208:             * In case of intersection, the new profile value overrides, the existing
209:             * profile value.
210:             *
211:             * @param profiles  the <code>Namespace</code> object containing the profiles.
212:             */
213:            public void merge(Namespace profiles) {
214:                //check if we are merging profiles of same type
215:                if (!(profiles instanceof  ENV)) {
216:                    //throw an error
217:                    throw new IllegalArgumentException(
218:                            "Profiles mismatch while merging");
219:                }
220:                String key;
221:                for (Iterator it = profiles.getProfileKeyIterator(); it
222:                        .hasNext();) {
223:                    //construct directly. bypassing the checks!
224:                    key = (String) it.next();
225:                    this .construct(key, (String) profiles.get(key));
226:                }
227:            }
228:
229:            /**
230:             * Returns a copy of the current namespace object.
231:             *
232:             * @return the Cloned object
233:             */
234:            public Object clone() {
235:                return (mProfileMap == null ? new ENV() : new ENV(
236:                        this.mProfileMap));
237:            }
238:
239:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.