Source Code Cross Referenced for ComponentOperation.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:         * @(#)ComponentOperation.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:        /**
032:         * This class extends the Operation abstract class, and is designed to run on a
033:         * separate thread. The main purpose of this class is to provide a way to run
034:         * operations on multiple components (BCs and SEs) in parallel, and optionally
035:         * wait for all of them to complete.
036:         * 
037:         * To use this class, create an instance for each BC or SE, providing the
038:         * appropriate Component instances and and operation types to the constructor.
039:         * Then, create a thread for each instance and call its start() method.
040:         *
041:         * If the parent thread needs to wait for all of the operations to complete,
042:         * a single OperationCounter instance must be created and provided to the
043:         * constructor when creating the instances of this class. Then after all of the
044:         * threads have been started, the parent thread calls wait() on the instance
045:         * of OperationCounter. Optionally, the wait() call can have a timeout parameter
046:         * to limit the amount of time the parent thread will wait for completion of
047:         * all of the threads.
048:         *
049:         * In the Component Framework, this class is used in conjunction with the
050:         * OperationCounter class to multi-thread startup and shutdown of BCs and SEs
051:         * during AppServer startup and shutdown. This design prevents an ill-behaved
052:         * BC or SE from hanging the AppServer startup or shutdown should the BC or
053:         * SE hang.
054:         *
055:         * @author Sun Microsystems, Inc.
056:         */
057:        class ComponentOperation extends Operation {
058:            /**
059:             * The Component to be operated upon.
060:             */
061:            private Component mComponent;
062:
063:            /**
064:             * Flag indicating whether the admin service needs notification of
065:             * operation completion.
066:             */
067:            private boolean mNotify;
068:
069:            /**
070:             * The type of operation to be performed.
071:             */
072:            private int mOperation;
073:
074:            /**
075:             * The JBI environment context.
076:             */
077:            private EnvironmentContext mEnv;
078:
079:            /**
080:             * The message string translator.
081:             */
082:            private StringTranslator mTranslator;
083:
084:            /**
085:             * Value for mOperation for an initialize operation.
086:             */
087:            public static final int INITIALIZE = 1;
088:
089:            /**
090:             * Value for mOperation for a startup operation.
091:             */
092:            public static final int STARTUP = 2;
093:
094:            /**
095:             * Value for mOperation for a shutdown operation.
096:             */
097:            public static final int SHUTDOWN = 3;
098:
099:            /**
100:             * Constructor.
101:             *
102:             * @param component the Component instance that represents the BC or SE
103:             * to be operated upon.
104:             * @param operation the type of operation to be performed, either
105:             * INITIALIZE, STARTUP, or SHUTDOWN.
106:             */
107:            ComponentOperation(Component component, int operation) {
108:                super (null, null);
109:                init(component, operation);
110:            }
111:
112:            /**
113:             * Constructor.
114:             *
115:             * @param counter the OperationCounter instance associated with this
116:             * operation.
117:             * @param component the Component instance that represents the BC or SE
118:             * to be operated upon.
119:             * @param operation the type of operation to be performed, either
120:             * INITIALIZE, STARTUP, or SHUTDOWN.
121:             */
122:            ComponentOperation(OperationCounter counter, Component component,
123:                    int operation) {
124:                super (counter, null);
125:                init(component, operation);
126:            }
127:
128:            /**
129:             * Constructor.
130:             *
131:             * @param counter the OperationCounter instance associated with this
132:             * operation.
133:             * @param component the Component instance that represents the BC or SE
134:             * to be operated upon.
135:             * @param operation the type of operation to be performed, either
136:             * INITIALIZE, STARTUP, or SHUTDOWN.
137:             * @param notify set to True if the framework should notify the admin
138:             * service when the operation is complete.
139:             */
140:            ComponentOperation(OperationCounter counter, Component component,
141:                    int operation, boolean notify) {
142:                super (counter, null);
143:                init(component, operation);
144:                mNotify = notify;
145:            }
146:
147:            /**
148:             * Common constructor initialization code.
149:             *
150:             * @param component the Component instance that represents the BC or SE
151:             * to be operated upon.
152:             * @param operation the type of operation to be performed, either
153:             * INITIALIZE, STARTUP, or SHUTDOWN.
154:             */
155:            void init(Component component, int operation) {
156:                mEnv = EnvironmentContext.getInstance();
157:                mTranslator = (StringTranslator) mEnv
158:                        .getStringTranslatorFor(this );
159:
160:                if (null == component) {
161:                    throw new IllegalArgumentException(mTranslator.getString(
162:                            LocalStringKeys.NULL_ARGUMENT, "component"));
163:                }
164:                mComponent = component;
165:
166:                if (INITIALIZE == operation || STARTUP == operation
167:                        || SHUTDOWN == operation) {
168:                    mOperation = operation;
169:                } else {
170:                    throw new IllegalArgumentException(mTranslator.getString(
171:                            LocalStringKeys.INVALID_ARGUMENT, "operation",
172:                            new Integer(operation)));
173:                }
174:            }
175:
176:            /**
177:             * Return the Component instance for which this ComponentOperation was
178:             * created.
179:             *
180:             * @return the instance of Component for this operation.
181:             */
182:            Component getComponent() {
183:                return mComponent;
184:            }
185:
186:            /**
187:             * Return the operation that this instance represents.
188:             *
189:             * @return the integer value of the operation code.
190:             */
191:            int getOperation() {
192:                return mOperation;
193:            }
194:
195:            /**
196:             * Overridden method to call the ComponentFramework to initialize, startup
197:             * or shut down the BC or SE.
198:             *
199:             * @param argumentList the arguments for the operation. For this class this
200:             * is always null.
201:             * @return the returned string from operations that return a string or null
202:             * for operations that have no return value.
203:             * @throws Throwable if any error occurs.
204:             */
205:            Object process(Object argumentList[]) throws Throwable {
206:                ComponentFramework cf = mEnv.getComponentFramework();
207:                try {
208:                    if (mComponent.isBinding() || mComponent.isEngine()) {
209:                        if (INITIALIZE == mOperation) {
210:                            cf.initializeComponent(mComponent);
211:                        } else if (STARTUP == mOperation) {
212:                            cf.startComponent(mComponent);
213:                        } else if (SHUTDOWN == mOperation) {
214:                            cf.shutdownComponent(mComponent);
215:                        }
216:                    } else {
217:                        cf
218:                                .getLogger()
219:                                .warning(
220:                                        mTranslator
221:                                                .getString(
222:                                                        LocalStringKeys.CF_COMP_UNRECOGNIZED_TYPE,
223:                                                        mComponent.getName(),
224:                                                        mComponent
225:                                                                .getComponentType()
226:                                                                .toString()));
227:                    }
228:                } catch (javax.jbi.JBIException jbiEx) {
229:                    // All exceptions caught here already have a formatted
230:                    // message that requires no further formatting.
231:                    cf.getLogger().warning(jbiEx.getMessage());
232:                }
233:
234:                // If requested, notify the admin service of completion.
235:
236:                if (mNotify) {
237:                    mEnv.getManagementService().updateComponentState(
238:                            mComponent.getName());
239:                }
240:                return null;
241:            }
242:
243:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.