Source Code Cross Referenced for ServiceUnitOperation.java in  » ESB » open-esb » com » sun » jbi » framework » 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 » ESB » open esb » com.sun.jbi.framework 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * BEGIN_HEADER - DO NOT EDIT
003:         *
004:         * The contents of this file are subject to the terms
005:         * of the Common Development and Distribution License
006:         * (the "License").  You may not use this file except
007:         * in compliance with the License.
008:         *
009:         * You can obtain a copy of the license at
010:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011:         * See the License for the specific language governing
012:         * permissions and limitations under the License.
013:         *
014:         * When distributing Covered Code, include this CDDL
015:         * HEADER in each file and include the License file at
016:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017:         * If applicable add the following below this CDDL HEADER,
018:         * with the fields enclosed by brackets "[]" replaced with
019:         * your own identifying information: Portions Copyright
020:         * [year] [name of copyright owner]
021:         */
022:
023:        /*
024:         * @(#)ServiceUnitOperation.java
025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026:         *
027:         * END_HEADER - DO NOT EDIT
028:         */
029:        package com.sun.jbi.framework;
030:
031:        import javax.jbi.component.ServiceUnitManager;
032:
033:        /**
034:         * This class extends the Operation abstract class, and is designed to run on a
035:         * separate thread. The main purpose of this class is to provide a way to run
036:         * operations on Service Units with a timeout to prevent a hang if the call to
037:         * the component's ServiceUnitManager fails to return 
038:         * 
039:         * To use this class, create an instance for the Service Unit, providing the
040:         * appropriate Service Unit Manager, operation type, and operation arguments to
041:         * the constructor. Then create a thread for the instance and call its start()
042:         * method.
043:         *
044:         * If the parent thread needs to wait for the operation to complete, it can call
045:         * wait() on the instance of this class. Optionally, the wait() call can have a
046:         * a timeout parameter to limit the amount of time to wait for completion of the
047:         * operation.
048:         *
049:         * @author Sun Microsystems, Inc.
050:         */
051:        class ServiceUnitOperation extends Operation {
052:            /**
053:             * The JBI environment context.
054:             */
055:            private EnvironmentContext mEnv;
056:
057:            /**
058:             * The type of operation to be performed.
059:             */
060:            private int mOperation;
061:
062:            /**
063:             * The name of the component.
064:             */
065:            private String mComponentName;
066:
067:            /**
068:             * The ServiceUnitManager for the component.
069:             */
070:            private ServiceUnitManager mSuManager;
071:
072:            /**
073:             * The message string translator.
074:             */
075:            private StringTranslator mTranslator;
076:
077:            /**
078:             * Value for mOperation for a deploy operation.
079:             */
080:            public static final int DEPLOY = 1;
081:
082:            /**
083:             * Value for mOperation for an init operation.
084:             */
085:            public static final int INIT = 2;
086:
087:            /**
088:             * Value for mOperation for a start operation.
089:             */
090:            public static final int START = 3;
091:
092:            /**
093:             * Value for mOperation for a stop operation.
094:             */
095:            public static final int STOP = 4;
096:
097:            /**
098:             * Value for mOperation for a shutdown operation.
099:             */
100:            public static final int SHUTDOWN = 5;
101:
102:            /**
103:             * Value for mOperation for an undeploy operation.
104:             */
105:            public static final int UNDEPLOY = 6;
106:
107:            /**
108:             * Constructor.
109:             *
110:             * @param counter the OperationCounter for synchronization of the operation.
111:             * @param compName the name of the component.
112:             * @param suManager the ServiceUnitManager instance for the component.
113:             * @param operation the type of operation to be performed, either DEPLOY,
114:             * INIT, START, STOP, SHUTDOWN, or UNDEPLOY.
115:             * @param args array of arguments for the operation.
116:             */
117:            ServiceUnitOperation(OperationCounter counter, String compName,
118:                    ServiceUnitManager suManager, int operation, Object args[]) {
119:                super (counter, args);
120:
121:                mComponentName = compName;
122:                mSuManager = suManager;
123:                mEnv = EnvironmentContext.getInstance();
124:                mTranslator = (StringTranslator) mEnv
125:                        .getStringTranslatorFor(this );
126:
127:                if (null == suManager) {
128:                    throw new IllegalArgumentException(mTranslator.getString(
129:                            LocalStringKeys.NULL_ARGUMENT, "suManager"));
130:                }
131:
132:                if (DEPLOY == operation || INIT == operation
133:                        || START == operation || STOP == operation
134:                        || SHUTDOWN == operation || UNDEPLOY == operation) {
135:                    mOperation = operation;
136:                } else {
137:                    throw new IllegalArgumentException(mTranslator.getString(
138:                            LocalStringKeys.INVALID_ARGUMENT, "operation",
139:                            new Integer(operation)));
140:                }
141:            }
142:
143:            /**
144:             * Call the ServiceUnitManager to perform the operation on the Service Unit.
145:             *
146:             * @param argumentList - the arguments for the operation provided to the
147:             * constructor.
148:             * @return the returned string from operations that return a string or null
149:             * for operations that have no return value.
150:             * @throws Throwable if any error occurs.
151:             */
152:            Object process(Object argumentList[]) throws Throwable {
153:                String returnValue = null;
154:
155:                ClassLoader cl = Thread.currentThread().getContextClassLoader();
156:                try {
157:                    Thread.currentThread().setContextClassLoader(
158:                            ClassLoaderFactory.getInstance()
159:                                    .getComponentClassLoader(mComponentName));
160:                    switch (mOperation) {
161:                    case DEPLOY:
162:                        returnValue = mSuManager.deploy(
163:                                (String) argumentList[0],
164:                                (String) argumentList[1]);
165:                        break;
166:                    case INIT:
167:                        mSuManager.init((String) argumentList[0],
168:                                (String) argumentList[1]);
169:                        break;
170:                    case START:
171:                        mSuManager.start((String) argumentList[0]);
172:                        break;
173:                    case STOP:
174:                        mSuManager.stop((String) argumentList[0]);
175:                        break;
176:                    case SHUTDOWN:
177:                        mSuManager.shutDown((String) argumentList[0]);
178:                        break;
179:                    case UNDEPLOY:
180:                        returnValue = mSuManager.undeploy(
181:                                (String) argumentList[0],
182:                                (String) argumentList[1]);
183:                        break;
184:                    default:
185:                        break;
186:                    }
187:                } finally {
188:                    Thread.currentThread().setContextClassLoader(cl);
189:                }
190:
191:                return (Object) returnValue;
192:            }
193:
194:            /**
195:             * Reset the instance with a new operation. Values must be either DEPLOY,
196:             * INIT, START, STOP, SHUTDOWN, or UNDEPLOY. This method reinitializes the
197:             * instance to reuse for another operation.
198:             *
199:             * @param operation the type of operation to be performed, either DEPLOY,
200:             * INIT, START, STOP, SHUTDOWN, or UNDEPLOY.
201:             */
202:            void resetOperation(int operation) {
203:                if (DEPLOY == operation || INIT == operation
204:                        || START == operation || STOP == operation
205:                        || SHUTDOWN == operation || UNDEPLOY == operation) {
206:                    mOperation = operation;
207:                    super .reset();
208:                } else {
209:                    throw new IllegalArgumentException(mTranslator.getString(
210:                            LocalStringKeys.INVALID_ARGUMENT, "operation",
211:                            new Integer(operation)));
212:                }
213:            }
214:
215:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.