Source Code Cross Referenced for BindingBootstrap.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:         * @(#)BindingBootstrap.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.io.File;
032:
033:        import java.util.ArrayList;
034:        import java.util.List;
035:        import java.util.logging.Logger;
036:
037:        import javax.jbi.component.ComponentContext;
038:        import javax.jbi.component.InstallationContext;
039:
040:        import javax.management.ObjectName;
041:        import javax.management.StandardMBean;
042:
043:        /**
044:         * This is an implementation of the bootstrap class for a Binding Component
045:         * that is purely for unit testing. It does nothing but log messages when
046:         * its methods are called.
047:         *
048:         * @author Sun Microsystems, Inc.
049:         */
050:        public class BindingBootstrap implements  javax.jbi.component.Bootstrap {
051:            /**
052:             * InstallationContext instance.
053:             */
054:            InstallationContext mCtx;
055:
056:            /**
057:             * ComponentContext instance.
058:             */
059:            ComponentContext mCompCtx;
060:
061:            /**
062:             * Logger instance.
063:             */
064:            Logger mLog = Logger
065:                    .getLogger("com.sun.jbi.framework.test.BindingBootstrap");
066:
067:            /**
068:             * Cleans up any resources allocated by the bootstrap implementation,
069:             * including deregistration of the extension MBean, if applicable.
070:             * This method will be called after the onInstall() or onUninstall() method
071:             * is called, whether it succeeds or fails.
072:             * @throws javax.jbi.JBIException when cleanup processing fails to complete
073:             * successfully.
074:             */
075:            public void cleanUp() throws javax.jbi.JBIException {
076:                String name = mCtx.getComponentName();
077:                mLog.info(name + ": cleanUp() called");
078:                if (mCtx.isInstall()) {
079:                    if (name
080:                            .equals(Constants.BC_NAME_BAD_BOOTSTRAP_INSTALL_CLEANUP)
081:                            || name
082:                                    .equals(Constants.BC_NAME_BAD_BOOTSTRAP_ONINSTALL_CLEANUP)
083:                            || name
084:                                    .equals(Constants.BC_NAME_BAD_BOOTSTRAP_INIT_CLEANUP)) {
085:                        throw new javax.jbi.JBIException(
086:                                "bootstrap cleanup failed");
087:                    }
088:                } else {
089:                    if (name
090:                            .equals(Constants.BC_NAME_BAD_BOOTSTRAP_UNINSTALL_CLEANUP)
091:                            || name
092:                                    .equals(Constants.BC_NAME_BAD_BOOTSTRAP_ONUNINSTALL_CLEANUP)
093:                            || name
094:                                    .equals(Constants.BC_NAME_BAD_BOOTSTRAP_INIT_CLEANUP)) {
095:                        throw new javax.jbi.JBIException(
096:                                "bootstrap cleanup failed");
097:                    }
098:                }
099:            }
100:
101:            /**
102:             * Initialize for installation.
103:             * @param installContext is the InstallationContext
104:             * @throws javax.jbi.JBIException if any error occurs.
105:             */
106:            public void init(InstallationContext installContext)
107:                    throws javax.jbi.JBIException {
108:                mCtx = installContext;
109:                mCompCtx = installContext.getContext();
110:                mLog.info(mCtx.getComponentName() + ": init() called");
111:
112:                // Create and register extension MBean.
113:
114:                javax.jbi.management.MBeanNames mbn = mCompCtx.getMBeanNames();
115:                ObjectName mbName = mbn
116:                        .createCustomComponentMBeanName("InstallerConfigurationMBean");
117:                registerMBean(new BindingBootstrapExtension(),
118:                        BindingBootstrapExtensionMBean.class, mbName);
119:                String name = mCtx.getComponentName();
120:                if (name.equals(Constants.BC_NAME_BAD_BOOTSTRAP_INIT)
121:                        || name
122:                                .equals(Constants.BC_NAME_BAD_BOOTSTRAP_INIT_CLEANUP)) {
123:                    throw new javax.jbi.JBIException("bootstrap init failed");
124:                }
125:                return;
126:            }
127:
128:            /**
129:             * Return the optional installation configuration MBean ObjectName.
130:             * @return The MBean ObjectName for this MBean.
131:             */
132:            public ObjectName getExtensionMBeanName() {
133:                mLog.info(mCtx.getComponentName()
134:                        + ": getExtensionMBeanName() called");
135:                javax.jbi.management.MBeanNames mbn = mCompCtx.getMBeanNames();
136:                ObjectName on = mbn
137:                        .createCustomComponentMBeanName("InstallerConfigurationMBean");
138:                return on;
139:            }
140:
141:            /**
142:             * Install the Binding Component into the JBI framework.
143:             * @throws javax.jbi.JBIException if any error occurs.
144:             */
145:            public void onInstall() throws javax.jbi.JBIException {
146:                mLog.info(mCtx.getComponentName() + ": onInstall() called");
147:                String compId = mCtx.getComponentName();
148:                if (compId.equals(Constants.BC_NAME_BAD_BOOTSTRAP_ONINSTALL)
149:                        || compId
150:                                .equals(Constants.BC_NAME_BAD_BOOTSTRAP_ONINSTALL_CLEANUP)) {
151:                    throw new javax.jbi.JBIException(
152:                            "unable to install binding");
153:                } else if (compId
154:                        .equals(Constants.BC_NAME_BOOTSTRAP_MODIFY_CLASS_PATH)) {
155:                    mLog.info("Life cycle class path was "
156:                            + mCtx.getClassPathElements());
157:                    List cp = new ArrayList();
158:                    cp.add("framework" + File.separator + "bld"
159:                            + File.separator + "regress" + File.separator
160:                            + "Binding");
161:                    mCtx.setClassPathElements(cp);
162:                    mLog.info("Life cycle class path now "
163:                            + mCtx.getClassPathElements());
164:                    mLog.info("Binding component " + compId + " now installed");
165:                } else {
166:                    mLog.info("Binding component " + compId + " now installed");
167:                }
168:                return;
169:            }
170:
171:            /**
172:             * Uninstall a Binding Component from the JBI framework.
173:             * @throws javax.jbi.JBIException if any error occurs.
174:             */
175:            public void onUninstall() throws javax.jbi.JBIException {
176:                mLog.info(mCtx.getComponentName() + ": onUninstall() called");
177:                String compId = mCtx.getComponentName();
178:                if (compId.equals(Constants.BC_NAME_BAD_BOOTSTRAP_ONUNINSTALL)
179:                        || compId
180:                                .equals(Constants.BC_NAME_BAD_BOOTSTRAP_ONUNINSTALL_CLEANUP)) {
181:                    throw new javax.jbi.JBIException(
182:                            "unable to uninstall binding");
183:                } else {
184:                    mLog.info("Binding component " + compId
185:                            + " now uninstalled");
186:                }
187:                return;
188:            }
189:
190:            /**
191:             * Register an MBean with the main MBean Server if it is available.
192:             * @param instance - the MBean implementation instance.
193:             * @param interfaceClass - the MBean interface implemented by the instance.
194:             * @param mbeanName - the JMX ObjectName of the MBean.
195:             * @throws javax.jbi.JBIException If the MBean registration fails.
196:             */
197:            private void registerMBean(Object instance, Class interfaceClass,
198:                    ObjectName mbeanName) throws javax.jbi.JBIException {
199:                if (null == mCompCtx.getMBeanServer()) {
200:                    return;
201:                }
202:                // Create a StandardMBean.
203:
204:                StandardMBean mbean = null;
205:                try {
206:                    mbean = new StandardMBean(instance, interfaceClass);
207:                } catch (javax.management.NotCompliantMBeanException ncEx) {
208:                    throw new javax.jbi.JBIException(
209:                            "Failed to create MBean due to "
210:                                    + ncEx.getClass().getName()
211:                                    + " exception. Exception message is: "
212:                                    + ncEx.getMessage(), ncEx);
213:                }
214:
215:                // Register the MBean. If it is already registered, unregister it
216:                // first, as it is an old registration with a stale instance reference.
217:
218:                try {
219:                    if (mCompCtx.getMBeanServer().isRegistered(mbeanName)) {
220:                        try {
221:                            mCompCtx.getMBeanServer()
222:                                    .unregisterMBean(mbeanName);
223:                        } catch (javax.management.InstanceNotFoundException infEx) {
224:                            ; // Just ignore this error
225:                        }
226:                    }
227:                    mCompCtx.getMBeanServer().registerMBean(mbean, mbeanName);
228:                } catch (javax.management.InstanceAlreadyExistsException iaeEx) {
229:                    throw new javax.jbi.JBIException(
230:                            "Failed to register MBean due to "
231:                                    + iaeEx.getClass().getName()
232:                                    + " exception. Exception message is: "
233:                                    + iaeEx.getMessage(), iaeEx);
234:                } catch (javax.management.MBeanRegistrationException mbrEx) {
235:                    throw new javax.jbi.JBIException(
236:                            "Failed to register MBean due to "
237:                                    + mbrEx.getClass().getName()
238:                                    + " exception. Exception message is: "
239:                                    + mbrEx.getMessage(), mbrEx);
240:                } catch (javax.management.NotCompliantMBeanException ncEx) {
241:                    throw new javax.jbi.JBIException(
242:                            "Failed to register MBean due to "
243:                                    + ncEx.getClass().getName()
244:                                    + " exception. Exception message is: "
245:                                    + ncEx.getMessage(), ncEx);
246:                }
247:            }
248:
249:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.