Source Code Cross Referenced for Operation.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:         * @(#)Operation.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 is an abstract class that provides a generalized way for the framework
033:         * to perform a set of operations on BCs and SEs in parallel on separate
034:         * threads. In conjunction with the OperationCounter class, it can wait for
035:         * all of the operations to complete, with an optional timeout.
036:         *
037:         * @author Sun Microsystems, Inc.
038:         */
039:        abstract class Operation implements  Runnable {
040:            /**
041:             * Arguments to be passed to the operation.
042:             */
043:            private Object mArguments[];
044:
045:            /**
046:             * Completion flag set to true if the operation completed.
047:             */
048:            private boolean mCompleted;
049:
050:            /**
051:             * The OperationCounter instance to use.
052:             */
053:            private OperationCounter mCounter;
054:
055:            /**
056:             * An exception thrown by the operation, if any.
057:             */
058:            private Throwable mException;
059:
060:            /**
061:             * A return value from the operation, if any.
062:             */
063:            private Object mReturnValue;
064:
065:            /**
066:             * The thread on which this operation is running.
067:             */
068:            private Thread mThread;
069:
070:            /**
071:             * Constructor.
072:             *
073:             * @param counter - the optional OperationCounter instance that should be
074:             * associated with this Operation. If this is not null, its increment()
075:             * method is called here.
076:             * @param arguments - the arguments to be passed to the process() method,
077:             * which is called to perform the operation.
078:             */
079:            Operation(OperationCounter counter, Object arguments[]) {
080:                mArguments = arguments;
081:                mCounter = counter;
082:                mCompleted = false;
083:                if (null != mCounter) {
084:                    mCounter.increment();
085:                }
086:            }
087:
088:            /**
089:             * Run the operation. Save the thread on which this operation is running in
090:             * case of a timeout, so that the parent thread can interrupt this one.
091:             * When the operation completes, save its return value and set the completed
092:             * flag. If an OperationCounter is present, decrement its counter. If the
093:             * operation throws an exception, save it. Upon return from this method,
094:             * this thread terminates.
095:             */
096:            public final void run() {
097:                mThread = Thread.currentThread();
098:                try {
099:                    mReturnValue = process(mArguments);
100:                } catch (Throwable ex) {
101:                    mException = ex;
102:                }
103:                mCompleted = true;
104:                if (null != mCounter) {
105:                    mCounter.decrement();
106:                }
107:                return;
108:            }
109:
110:            /**
111:             * Returns true if this operation completed.
112:             *
113:             * @return true if the operation has completed, false if it has not.
114:             */
115:            final boolean completed() {
116:                return mCompleted;
117:            }
118:
119:            /**
120:             * Returns one argument that was provided to the constructor and passed
121:             * to the operation.
122:             *
123:             * @param index the index of the argument to be returned.
124:             * @return The argument that was provided to the operation.
125:             */
126:            final Object getArgument(int index) {
127:                return mArguments[index];
128:            }
129:
130:            /**
131:             * Returns the arguments that were provided to the constructor and passed
132:             * to the operation.
133:             *
134:             * @return The arguments that were provided to the operation.
135:             */
136:            final Object[] getArguments() {
137:                return mArguments;
138:            }
139:
140:            /**
141:             * Returns any exception thrown by the operation, or null if no exception
142:             * was thrown.
143:             *
144:             * @return The exception from the operation or null.
145:             */
146:            final Throwable getException() {
147:                return mException;
148:            }
149:
150:            /**
151:             * Returns any return value from the operation, or null if there was none.
152:             *
153:             * @return The return value from the operation or null.
154:             */
155:            final Object getReturnValue() {
156:                return mReturnValue;
157:            }
158:
159:            /**
160:             * Returns the thread on which this operation is running.
161:             *
162:             * @return The thread on which the operation is running.
163:             */
164:            final Thread getThread() {
165:                return mThread;
166:            }
167:
168:            /**
169:             * Process the operation. This method must be overridden to perform the
170:             * desired processing.
171:             *
172:             * @param arguments the arguments to be provided to the operation.
173:             * @return the returned value from the operation as an object or null if
174:             * no value was returned.
175:             * @throws Throwable if any error occurs.
176:             */
177:            abstract Object process(Object arguments[]) throws Throwable;
178:
179:            /**
180:             * Reset this instance for a new operation. This clears all results of
181:             * a previous operation.
182:             */
183:            final void reset() {
184:                mCompleted = false;
185:                mException = null;
186:                mReturnValue = null;
187:                mThread = null;
188:            }
189:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.