Source Code Cross Referenced for ComponentLifeCycle.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:         * @(#)ComponentLifeCycle.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 com.sun.jbi.ComponentState;
032:        import com.sun.jbi.management.registry.Updater;
033:        import javax.management.ObjectName;
034:
035:        /**
036:         * This class implements the LifeCycleMBean for a Component (BC or SE). This
037:         * MBean acts as an agent between the JMX management service and the Component 
038:         * Framework to allow the Component Framework to keep track of the state of the
039:         * component. Some methods in this MBean delegate to methods in the Component
040:         * Framework, which in turn interact directly with the component. Other methods
041:         * in this MBean interact directly with the component.
042:         *
043:         * @author Sun Microsystems, Inc.
044:         */
045:        public class ComponentLifeCycle implements 
046:                com.sun.jbi.framework.ComponentLifeCycleMBean {
047:            /**
048:             * Component instance handle.
049:             */
050:            private Component mComponent;
051:
052:            /**
053:             * Component Framework handle.
054:             */
055:            private ComponentFramework mComponentFramework;
056:
057:            /**
058:             * Local handle to StringTranslator.
059:             */
060:            private StringTranslator mTranslator;
061:
062:            /**
063:             * Local handle to registry updater.
064:             */
065:            private Updater mUpdater;
066:
067:            /**
068:             * Constructor.
069:             * @param component is the Component instance for this component.
070:             * @param componentFramework is the ComponentFramework service handle.
071:             */
072:            ComponentLifeCycle(Component component,
073:                    ComponentFramework componentFramework) {
074:                mComponent = component;
075:                mComponentFramework = componentFramework;
076:                mTranslator = (StringTranslator) EnvironmentContext
077:                        .getInstance().getStringTranslatorFor(this );
078:            }
079:
080:            /**
081:             * Get the current state of this component.
082:             * @return The current state of the component as a string.
083:             */
084:            public String getCurrentState() {
085:                String state;
086:                if (mComponent.isStarted()) {
087:                    state = STARTED;
088:                } else if (mComponent.isStopped()) {
089:                    state = STOPPED;
090:                } else if (mComponent.isShutDown()) {
091:                    state = SHUTDOWN;
092:                } else {
093:                    state = UNKNOWN;
094:                }
095:                return state;
096:            }
097:
098:            /**
099:             * Get the JMX ObjectName for the DeployerMBean for this component. If
100:             * there is none, return null.
101:             * @throws javax.jbi.JBIException if there is a failure getting component
102:             * information from the Component Registry.
103:             * @return ObjectName the JMX object name of the DeployerMBean or null
104:             * if there is no DeployerMBean.
105:             */
106:            public ObjectName getDeploymentMBeanName()
107:                    throws javax.jbi.JBIException {
108:                ObjectName name = null;
109:                name = mComponent.getDeployerMBeanName();
110:                return name;
111:            }
112:
113:            /**
114:             * Get the JMX ObjectName for any additional MBean for this component. If
115:             * there is none, return null.
116:             * @throws javax.jbi.JBIException if there is a failure getting component
117:             * information from the Component Registry.
118:             * @return ObjectName the JMX object name of the additional MBean or null
119:             * if there is no additional MBean.
120:             */
121:            public ObjectName getExtensionMBeanName()
122:                    throws javax.jbi.JBIException {
123:                ObjectName name = null;
124:                javax.jbi.component.ComponentLifeCycle instance = mComponent
125:                        .getLifeCycleInstance(false);
126:                if (instance != null) {
127:                    name = instance.getExtensionMBeanName();
128:                }
129:                return name;
130:            }
131:
132:            /**
133:             * Start command. This starts up the component, calling its init() method
134:             * if necessary.
135:             * @throws javax.jbi.JBIException if the component fails to start or if
136:             * another life cycle operation is already in progress.
137:             */
138:            public void start() throws javax.jbi.JBIException {
139:                mComponent.setBusy();
140:                mComponent.setDesiredState(ComponentState.STARTED);
141:                persistState();
142:                try {
143:                    mComponentFramework.startComponent(mComponent, true);
144:                } finally {
145:                    mComponent.clearBusy();
146:                }
147:                return;
148:            }
149:
150:            /**
151:             * Stop command. This stops the component but does not completely shut
152:             * it down. It can be restarted without going through init() again.
153:             * @throws javax.jbi.JBIException if the component fails to stop or if
154:             * another life cycle operation is already in progress.
155:             */
156:            public void stop() throws javax.jbi.JBIException {
157:                mComponent.setBusy();
158:                mComponent.setDesiredState(ComponentState.STOPPED);
159:                persistState();
160:                try {
161:                    mComponentFramework.stopComponent(mComponent);
162:                } finally {
163:                    mComponent.clearBusy();
164:                }
165:                return;
166:            }
167:
168:            /**
169:             * Shutdown command. This completely shuts down the component and unloads
170:             * its classes from the JBI Framework. The next start command will
171:             * require init() to be called again.
172:             * @throws javax.jbi.JBIException if the component fails to shut down or if
173:             * another life cycle operation is already in progress.
174:             */
175:            public void shutDown() throws javax.jbi.JBIException {
176:                shutDown(false);
177:            }
178:
179:            /**
180:             * Shutdown command. This completely shuts down the component and unloads
181:             * its classes from the JBI Framework. The next start command will require
182:             * init() to be called again. If the force flag is set to true, the
183:             * shutdown succeeds regardless of the success or failure of the component's
184:             * shutDown() method. 
185:             * @throws javax.jbi.JBIException if any failure occurs or if another life
186:             * cycle operation is already in progress.
187:             */
188:            public void shutDown(boolean force) throws javax.jbi.JBIException {
189:                if (force) {
190:                    mComponent.setBusyForce();
191:                } else {
192:                    mComponent.setBusy();
193:                }
194:                mComponent.setDesiredState(ComponentState.SHUTDOWN);
195:                persistState();
196:                try {
197:                    mComponentFramework.shutdownComponent(mComponent, force);
198:                } finally {
199:                    mComponent.clearBusy();
200:                }
201:                return;
202:            }
203:
204:            /**
205:             * Persist a change in the desired state of a component.
206:             */
207:            private void persistState() {
208:                try {
209:                    if (null == mUpdater) {
210:                        mUpdater = ((com.sun.jbi.management.registry.Registry) EnvironmentContext
211:                                .getInstance().getRegistry()).getUpdater();
212:                    }
213:                    mUpdater.setComponentState(mComponent.getDesiredState(),
214:                            mComponent.getName());
215:                } catch (com.sun.jbi.management.registry.RegistryException rEx) {
216:                    EnvironmentContext.getInstance().getLogger().log(
217:                            java.util.logging.Level.WARNING, rEx.getMessage(),
218:                            rEx);
219:                }
220:            }
221:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.