Source Code Cross Referenced for Engine.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:         * @(#)Engine.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 java.util.logging.Logger;
032:
033:        import javax.jbi.component.ComponentContext;
034:
035:        /**
036:         * This is an implementation of a Service Engine that is purely for
037:         * unit testing. It does nothing other than log messages when its methods
038:         * are called.
039:         *
040:         * @author Sun Microsystems, Inc.
041:         */
042:        public class Engine extends AbstractComponent {
043:            /**
044:             * Special flag for causing failure on second call to init().
045:             */
046:            private boolean mFirst = true;
047:
048:            /**
049:             * Constant for timeout tests - 1 minute sleep interval (in milliseconds).
050:             */
051:            private static final long TIMEOUT_INTERVAL = 60000;
052:
053:            /**
054:             * Public Constructor.
055:             */
056:            public Engine() {
057:                mLog = Logger.getLogger("com.sun.jbi.framework.test.Engine");
058:                mComponentType = "Engine";
059:            }
060:
061:            //
062:            // Overridden ComponentLifeCycle methods
063:            //
064:
065:            /**
066:             * Initialize the Service Engine.
067:             * @param context the JBI component context created by the JBI framework.
068:             * @throws javax.jbi.JBIException if an error occurs.
069:             */
070:            public void init(ComponentContext context)
071:                    throws javax.jbi.JBIException {
072:                if (null != context) {
073:                    mContext = context;
074:                    mComponentName = context.getComponentName();
075:                    if (mComponentName.equals(Constants.SE_NAME_BAD_INIT)) {
076:                        throw new javax.jbi.JBIException("EngineBadInit");
077:                    } else {
078:                        mLog.info("Engine " + mComponentName + " initialized");
079:                    }
080:                } else {
081:                    throw new javax.jbi.JBIException(
082:                            "Null argument received for " + "ComponentContext");
083:                }
084:
085:                // This code is here to allow a special test case to run, where the
086:                // engine is being started after having been shut down, and the
087:                // init() method throws an exception. The second time init() is
088:                // called, it throws an exception.
089:
090:                if (mFirst) {
091:                    mFirst = false;
092:                } else {
093:                    throw new javax.jbi.JBIException(
094:                            "Engine initialization failed");
095:                }
096:            }
097:
098:            /**
099:             * Get the JMX ObjectName for any additional MBean for this SE. This
100:             * implementation always returns null.
101:             * @return javax.management.ObjectName is always null.
102:             */
103:            public javax.management.ObjectName getExtensionMBeanName() {
104:                return null;
105:            }
106:
107:            /**
108:             * Start the Service Engine.
109:             * @throws javax.jbi.JBIException if an error occurs.
110:             */
111:            public void start() throws javax.jbi.JBIException {
112:                if (mComponentName.equals(Constants.SE_NAME_BAD_START)) {
113:                    throw new javax.jbi.JBIException("EngineBadStart");
114:                } else if (mComponentName
115:                        .equals(Constants.SE_NAME_TIMEOUT_START)) {
116:                    try {
117:                        Thread.sleep(TIMEOUT_INTERVAL); /* 5 minutes */
118:                    } catch (java.lang.InterruptedException iEx) {
119:                        throw new javax.jbi.JBIException("EngineInterrupted");
120:                    }
121:                } else {
122:                    mLog.info("Engine " + mComponentName + " started");
123:                }
124:            }
125:
126:            /**
127:             * Stop the Service Engine.
128:             * @throws javax.jbi.JBIException if an error occurs.
129:             */
130:            public void stop() throws javax.jbi.JBIException {
131:                if (mComponentName.equals(Constants.SE_NAME_BAD_STOP)) {
132:                    throw new javax.jbi.JBIException("EngineBadStop");
133:                } else if (mComponentName
134:                        .equals(Constants.SE_NAME_TIMEOUT_STOP)) {
135:                    try {
136:                        Thread.sleep(TIMEOUT_INTERVAL); /* 5 minutes */
137:                    } catch (java.lang.InterruptedException iEx) {
138:                        throw new javax.jbi.JBIException("EngineInterrupted");
139:                    }
140:                } else {
141:                    mLog.info("Engine " + mComponentName + " stopped");
142:                }
143:            }
144:
145:            /**
146:             * Shut down the Service Engine.
147:             * @throws javax.jbi.JBIException if an error occurs.
148:             */
149:            public void shutDown() throws javax.jbi.JBIException {
150:                if (mComponentName.equals(Constants.SE_NAME_BAD_SHUTDOWN)) {
151:                    throw new javax.jbi.JBIException("EngineBadShutdown");
152:                } else if (mComponentName
153:                        .equals(Constants.SE_NAME_BAD_SHUTDOWN_BOOTSTRAP_ONUNINSTALL)) {
154:                    throw new javax.jbi.JBIException("EngineBadShutdown");
155:                } else if (mComponentName
156:                        .equals(Constants.SE_NAME_TIMEOUT_SHUTDOWN)) {
157:                    try {
158:                        Thread.sleep(TIMEOUT_INTERVAL); /* 5 minutes */
159:                    } catch (java.lang.InterruptedException iEx) {
160:                        throw new javax.jbi.JBIException("EngineInterrupted");
161:                    }
162:                } else {
163:                    mLog.info("Engine " + mComponentName + " shut down");
164:                }
165:            }
166:
167:            //
168:            // ServiceUnitManager methods
169:            //
170:
171:            /**
172:             * Deploy a Service Unit.
173:             * @param serviceUnitName the name of the Service Unit being deployed.
174:             * @param serviceUnitRootPath the full path to the Service Unit artifact
175:             * root directory.
176:             * @return a deployment status message.
177:             * @throws javax.jbi.management.DeploymentException if the deployment
178:             * operation is unsuccessful.
179:             */
180:            public String deploy(String serviceUnitName,
181:                    String serviceUnitRootPath)
182:                    throws javax.jbi.management.DeploymentException {
183:                mLog.info("Engine " + mComponentName
184:                        + " deployed Service Unit " + serviceUnitName);
185:                return null;
186:            }
187:
188:            /**
189:             * Initialize the deployment.
190:             * @param serviceUnitName the name of the Service Unit being initialized.
191:             * @param serviceUnitRootPath the full path to the Service Unit artifact
192:             * root directory.
193:             * @throws javax.jbi.management.DeploymentException if the Service Unit is
194:             * not deployed, or is in an incorrect state.
195:             */
196:            public void init(String serviceUnitName, String serviceUnitRootPath)
197:                    throws javax.jbi.management.DeploymentException {
198:                mLog.info("Engine " + mComponentName
199:                        + " initialized Service Unit " + serviceUnitName);
200:            }
201:
202:            /**
203:             * Shut down the deployment.
204:             * @param serviceUnitName the name of the Service Unit being shut down.
205:             * @throws javax.jbi.management.DeploymentException if the Service Unit
206:             * is not deployed, or is in an incorrect state.
207:             */
208:            public void shutDown(String serviceUnitName)
209:                    throws javax.jbi.management.DeploymentException {
210:                mLog.info("Engine " + mComponentName
211:                        + " shut down Service Unit " + serviceUnitName);
212:            }
213:
214:            /**
215:             * Start the deployment.
216:             * @param serviceUnitName the name of the Service Unit being started.
217:             * @throws javax.jbi.management.DeploymentException if the Service Unit
218:             * is not deployed, or is in an incorrect state.
219:             */
220:            public void start(String serviceUnitName)
221:                    throws javax.jbi.management.DeploymentException {
222:                mLog.info("Engine " + mComponentName + " started Service Unit "
223:                        + serviceUnitName);
224:            }
225:
226:            /**
227:             * Stop the deployment.
228:             * @param serviceUnitName the name of the Service Unit being stopped.
229:             * @throws javax.jbi.management.DeploymentException if the Service Unit
230:             * is not deployed, or is in an incorrect state.
231:             */
232:            public void stop(String serviceUnitName)
233:                    throws javax.jbi.management.DeploymentException {
234:                mLog.info("Engine " + mComponentName + " stopped Service Unit "
235:                        + serviceUnitName);
236:            }
237:
238:            /**
239:             * Undeploy a Service Unit from the component.
240:             * @param serviceUnitName the name of the Service Unit being undeployed.
241:             * @param serviceUnitRootPath the full path to the Service Unit artifact
242:             * root directory.
243:             * @return an undeployment status message.
244:             * @throws javax.jbi.management.DeploymentException if the undeployment
245:             * operation is unsuccessful.
246:             */
247:            public String undeploy(String serviceUnitName,
248:                    String serviceUnitRootPath)
249:                    throws javax.jbi.management.DeploymentException {
250:                mLog.info("Engine " + mComponentName
251:                        + " undeployed Service Unit " + serviceUnitName);
252:                return null;
253:            }
254:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.