Source Code Cross Referenced for ImplementationFactory.java in  » Workflow-Engines » pegasus-2.1.0 » org » griphyn » cPlanner » transfer » implementation » 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.transfer.implementation 
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.cPlanner.transfer.implementation;
016:
017:        import org.griphyn.cPlanner.common.PegasusProperties;
018:
019:        import org.griphyn.cPlanner.classes.PlannerOptions;
020:
021:        import org.griphyn.cPlanner.transfer.Implementation;
022:
023:        import org.griphyn.common.util.DynamicLoader;
024:
025:        import java.io.IOException;
026:
027:        import java.lang.reflect.InvocationTargetException;
028:
029:        /**
030:         * The factory class that loads an appropriate Transfer Immplementation class,
031:         * as specified by the properties.
032:         *
033:         * @author Karan Vahi
034:         * @version $Revision: 50 $
035:         */
036:        public class ImplementationFactory {
037:
038:            /**
039:             * The default package where the implementations reside, which this factory
040:             * loads.
041:             */
042:            public static final String DEFAULT_PACKAGE_NAME = "org.griphyn.cPlanner.transfer.implementation";
043:
044:            /**
045:             * The constant designating the implementation be loaded for stage in jobs.
046:             */
047:            public static final int TYPE_STAGE_IN = 0;
048:
049:            /**
050:             * The constant designating the implementation be loaded for inter pool jobs.
051:             */
052:            public static final int TYPE_STAGE_INTER = 1;
053:
054:            /**
055:             * The constant designating the implementation be loaded for stage out jobs.
056:             */
057:            public static final int TYPE_STAGE_OUT = 2;
058:
059:            /**
060:             * Loads the implementing class corresponding to the type specified by the user.
061:             * The type is used to determine what property to be picked up from the
062:             * properties file. The properties object passed should not be null.
063:             *
064:             * @param properties the <code>PegasusProperties</code> object containing all
065:             *                   the properties required by Pegasus.
066:             * @param options    the options passed to the planner at runtime.
067:             * @param type       the type for which implementation needs to be loaded.
068:             *
069:             * @return the instance of the class implementing this interface.
070:             *
071:             * @exception TransferImplementationFactoryException that nests any error that
072:             *            might occur during the instantiation.
073:             *
074:             * @see #DEFAULT_PACKAGE_NAME
075:             */
076:            public static Implementation loadInstance(
077:                    PegasusProperties properties, PlannerOptions options,
078:                    int type) throws TransferImplementationFactoryException {
079:
080:                return loadInstance(properties
081:                        .getTransferImplementation(getProperty(type)),
082:                        properties, options);
083:            }
084:
085:            /**
086:             * Loads the implementing class corresponding to the mode specified by the user
087:             * at runtime in the properties file. The properties object passed should not
088:             * be null.
089:             *
090:             * @param properties the <code>PegasusProperties</code> object containing all
091:             *                   the properties required by Pegasus.
092:             * @param options    the options passed to the planner at runtime.
093:             *
094:             * @return the instance of the class implementing this interface.
095:             *
096:             * @exception TransferImplementationFactoryException that nests any error that
097:             *            might occur during the instantiation.
098:             *
099:             * @see #DEFAULT_PACKAGE_NAME
100:             */
101:            public static Implementation loadInstance(
102:                    PegasusProperties properties, PlannerOptions options)
103:                    throws TransferImplementationFactoryException {
104:
105:                return loadInstance(properties.getTransferImplementation(),
106:                        properties, options);
107:            }
108:
109:            /**
110:             * Loads the implementing class corresponding to the class. If the package
111:             * name is not specified with the class, then class is assumed to be
112:             * in the DEFAULT_PACKAGE. The properties object passed should not be null.
113:             *
114:             * @param className  the name of the class that implements the mode.It can or
115:             *                   cannot be with the package name.
116:             * @param properties the <code>PegasusProperties</code> object containing all
117:             *                   the properties required by Pegasus.
118:             * @param options    the options passed to the planner at runtime.
119:             *
120:             * @return the instance of the class implementing this interface.
121:             *
122:             * @exception TransferImplementationFactoryException that nests any error that
123:             *            might occur during the instantiation.
124:             *
125:             * @see #DEFAULT_PACKAGE_NAME
126:             */
127:            private static Implementation loadInstance(String className,
128:                    PegasusProperties properties, PlannerOptions options)
129:                    throws TransferImplementationFactoryException {
130:
131:                Implementation implementation = null;
132:                try {
133:                    //sanity check
134:                    if (properties == null) {
135:                        throw new RuntimeException("Invalid properties passed");
136:                    }
137:
138:                    //prepend the package name
139:                    className = (className.indexOf('.') == -1) ?
140:                    //pick up from the default package
141:                    DEFAULT_PACKAGE_NAME + "." + className
142:                            :
143:                            //load directly
144:                            className;
145:
146:                    //try loading the class dynamically
147:                    DynamicLoader dl = new DynamicLoader(className);
148:                    Object argList[] = new Object[2];
149:                    argList[0] = properties;
150:                    argList[1] = options;
151:                    implementation = (Implementation) dl.instantiate(argList);
152:                } catch (Exception e) {
153:                    throw new TransferImplementationFactoryException(
154:                            "Instantiating Transfer Impelmentation ",
155:                            className, e);
156:                }
157:                return implementation;
158:
159:            }
160:
161:            /**
162:             * Returns the name of the property that needs to be loaded for a particular
163:             * type.
164:             *
165:             * @param type   the type of implementation to be loaded.
166:             *
167:             * @return the name of the property
168:             * @throws IllegalArgumentException
169:             */
170:            private static String getProperty(int type)
171:                    throws IllegalArgumentException {
172:                String property;
173:                if (type == TYPE_STAGE_IN) {
174:                    property = "pegasus.transfer.stagein.impl";
175:                } else if (type == TYPE_STAGE_INTER) {
176:                    property = "pegasus.transfer.inter.impl";
177:                } else if (type == TYPE_STAGE_OUT) {
178:                    property = "pegasus.transfer.stageout.impl";
179:                } else {
180:                    throw new java.lang.IllegalArgumentException(
181:                            "Invalid implementation type passed to factory "
182:                                    + type);
183:                }
184:                return property;
185:            }
186:
187:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.