Source Code Cross Referenced for JBossASJBIFramework.java in  » ESB » open-esb » com » sun » jbi » framework » jboss » 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.jboss 
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:         * @(#)JBossASJBIFramework.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.jboss;
030:
031:        import com.sun.jbi.framework.JBIFramework;
032:
033:        import java.util.Properties;
034:        import java.util.logging.Logger;
035:
036:        import javax.management.MBeanServer;
037:        import javax.management.ObjectName;
038:        import javax.management.remote.JMXConnectorServer;
039:        import javax.management.remote.JMXConnectorServerFactory;
040:        import javax.management.remote.JMXServiceURL;
041:
042:        import javax.naming.Context;
043:        import javax.naming.InitialContext;
044:        import javax.naming.NamingException;
045:
046:        /**
047:         * This is the JBI Framework class for JBoss.
048:         *
049:         * @author Sun Microsystems, Inc.
050:         */
051:        public class JBossASJBIFramework extends JBIFramework implements 
052:                JBossASJBIFrameworkMBean {
053:            /**
054:             * JBI Home property, which is the install root.
055:             */
056:            private static final String JBI_HOME = "com.sun.jbi.home";
057:
058:            /**
059:             * Jboss naming service.
060:             */
061:            private static final String JBOSS_NAMING_SERVICE = "jboss:service=Naming";
062:
063:            /**
064:             * key for the install root property *
065:             */
066:            public static final String INSTALL_ROOT = "install.root";
067:
068:            /**
069:             * key for the instance name property *
070:             */
071:            public static final String INSTANCE_NAME = "instance.name";
072:
073:            /**
074:             * key for the instance root property.
075:             */
076:            public static final String INSTANCE_ROOT = "instance.root";
077:
078:            /**
079:             * Configuration defaults.
080:             */
081:            private static final String DEFAULT_INSTALL_ROOT = System
082:                    .getProperty("user.dir");
083:
084:            /**
085:             * Default Jboss instance name.
086:             */
087:            private static final String DEFAULT_INSTANCE_NAME = "default";
088:
089:            /**
090:             * Naming prefix for Jboss
091:             */
092:            private static final String JBOSS_NAMING_PREFIX = "";
093:
094:            /**
095:             * Determines wheter or not the Framework has been loaded.
096:             */
097:            private boolean mLoaded;
098:
099:            /**
100:             * The Logger instance for the framework.
101:             */
102:            private Logger mLog = Logger.getLogger(this .getClass().getPackage()
103:                    .getName());
104:
105:            /**
106:             * Folder where JBoss is installed.
107:             */
108:            private String mInstallRoot;
109:
110:            /**
111:             * JMX connector server for accepting JMX connections.
112:             */
113:            private JMXConnectorServer mConnectorServer;
114:
115:            /**
116:             * platform context instance
117:             */
118:            private JBossPlatformContext mPlatformContext;
119:
120:            public JBossASJBIFramework(Properties env) {
121:                super ();
122:                mInstallRoot = env.getProperty(INSTALL_ROOT,
123:                        DEFAULT_INSTALL_ROOT);
124:
125:                mPlatformContext = new JBossPlatformContext(env.getProperty(
126:                        INSTANCE_NAME, DEFAULT_INSTANCE_NAME), mInstallRoot,
127:                        env.getProperty(INSTANCE_ROOT, DEFAULT_INSTALL_ROOT));
128:            }
129:
130:            /**
131:             * This method is called by the Bootstrap to load the JBI Framework.
132:             *
133:             * @throws java.lang.Exception any exception.
134:             */
135:            public void load() throws java.lang.Exception {
136:                try {
137:                    Properties props = new Properties();
138:                    props.put(JBI_HOME, mInstallRoot);
139:
140:                    MBeanServer mbs;
141:                    mbs = mPlatformContext.getMBeanServer();
142:                    startJMXConnectorServer(mbs);
143:                    super .init(mPlatformContext, props);
144:                } catch (javax.jbi.JBIException je) {
145:                    throw je;
146:                }
147:
148:                try {
149:                    InitialContext ctx = new InitialContext();
150:                    Context subctx = null;
151:
152:                    try {
153:                        Object obj = ctx.lookup("jbi");
154:
155:                        // great ther is already one
156:                        subctx = (Context) obj;
157:                    } catch (NamingException ne) {
158:                        subctx = ctx.createSubcontext("jbi");
159:                    }
160:
161:                    mConnectorServer.start();
162:                    super .startup(ctx, JBOSS_NAMING_PREFIX);
163:                    super .prepare();
164:                    mLog.info("JBI Framework - Created");
165:                    super .ready(true);
166:                    mLog.info("JBI Framework - Started");
167:                    // JBI framework has been loaded
168:                    mLoaded = true;
169:                } catch (javax.jbi.JBIException sje) {
170:                    throw sje;
171:                }
172:            }
173:
174:            /**
175:             * Starts the JMX connector server. This is a feature that is supported
176:             * in J2SE 1.5 ( JMX-remoting). When run on 1.4 the jmx-remoting jar should
177:             * be supplied. This is only a temporary measure as the Jboss AS 4.0.3
178:             * does not have a JSR 160 implementation. Once the implementation is
179:             * available that can be used instead of the jms-remoting RI.
180:             *
181:             * @param mbs Mbean server to be used.
182:             */
183:            private void startJMXConnectorServer(MBeanServer mbs) {
184:                try {
185:                    ObjectName mbeanName = new ObjectName(JBOSS_NAMING_SERVICE);
186:                    Integer port = (Integer) mbs
187:                            .getAttribute(mbeanName, "Port");
188:
189:                    String jmxurl = "service:jmx:rmi:///jndi/jnp://localhost:"
190:                            + port.toString() + "/jbiconnector";
191:                    mLog.info("JMX Url: " + jmxurl);
192:
193:                    JMXServiceURL url = new JMXServiceURL(jmxurl);
194:                    mConnectorServer = JMXConnectorServerFactory
195:                            .newJMXConnectorServer(url, null, mbs);
196:                    mLog
197:                            .info("RMI Connector server started - JMXServiceURL to access "
198:                                    + "   the mbean server would be " + jmxurl);
199:                } catch (Exception e) {
200:                    mLog.severe("Cannot create Connector " + e.getMessage());
201:                }
202:            }
203:
204:            /**
205:             * Queries the state of the JBI Framework.
206:             *
207:             * @return true if the JBI framework is loaded, false otherwise.
208:             */
209:            public boolean isLoaded() {
210:                return mLoaded;
211:            }
212:
213:            /**
214:             * Unloads the JBI framework.  When this method retuns, all
215:             * public interfaces, system services, and JMX connector (if configured)
216:             * have been destroyed.
217:             *
218:             * @throws java.lang.Exception failed to unload JBI framework
219:             */
220:            public synchronized void unload() throws Exception {
221:                if (!mLoaded) {
222:                    return;
223:                }
224:
225:                shutdown();
226:                mLog.info("JBI Framework - Stopped");
227:                mConnectorServer.stop();
228:                mLog.info("JBI RMI Connector server stopped ");
229:                terminate();
230:
231:                mLoaded = false;
232:            }
233:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.