Source Code Cross Referenced for NamingService.java in  » Sevlet-Container » apache-tomcat-6.0.14 » org » apache » naming » 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 » Sevlet Container » apache tomcat 6.0.14 » org.apache.naming 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        package org.apache.naming;
019:
020:        import javax.naming.Context;
021:        import javax.management.NotificationBroadcasterSupport;
022:        import javax.management.ObjectName;
023:        import javax.management.MBeanServer;
024:        import javax.management.MBeanRegistration;
025:        import javax.management.AttributeChangeNotification;
026:        import javax.management.Notification;
027:
028:        /**
029:         * Implementation of the NamingService JMX MBean.
030:         * 
031:         * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
032:         * @version $Revision: 467222 $
033:         */
034:
035:        public final class NamingService extends NotificationBroadcasterSupport
036:                implements  NamingServiceMBean, MBeanRegistration {
037:
038:            // ----------------------------------------------------- Instance Variables
039:
040:            /**
041:             * Status of the Slide domain.
042:             */
043:            private int state = STOPPED;
044:
045:            /**
046:             * Notification sequence number.
047:             */
048:            private long sequenceNumber = 0;
049:
050:            /**
051:             * Old URL packages value.
052:             */
053:            private String oldUrlValue = "";
054:
055:            /**
056:             * Old initial context value.
057:             */
058:            private String oldIcValue = "";
059:
060:            // ---------------------------------------------- MBeanRegistration Methods
061:
062:            public ObjectName preRegister(MBeanServer server, ObjectName name)
063:                    throws Exception {
064:                return new ObjectName(OBJECT_NAME);
065:            }
066:
067:            public void postRegister(Boolean registrationDone) {
068:                if (!registrationDone.booleanValue())
069:                    destroy();
070:            }
071:
072:            public void preDeregister() throws Exception {
073:            }
074:
075:            public void postDeregister() {
076:                destroy();
077:            }
078:
079:            // ----------------------------------------------------- SlideMBean Methods
080:
081:            /**
082:             * Retruns the Catalina component name.
083:             */
084:            public String getName() {
085:                return NAME;
086:            }
087:
088:            /**
089:             * Returns the state.
090:             */
091:            public int getState() {
092:                return state;
093:            }
094:
095:            /**
096:             * Returns a String representation of the state.
097:             */
098:            public String getStateString() {
099:                return states[state];
100:            }
101:
102:            /**
103:             * Start the servlet container.
104:             */
105:            public void start() throws Exception {
106:
107:                Notification notification = null;
108:
109:                if (state != STOPPED)
110:                    return;
111:
112:                state = STARTING;
113:
114:                // Notifying the MBEan server that we're starting
115:
116:                notification = new AttributeChangeNotification(this ,
117:                        sequenceNumber++, System.currentTimeMillis(),
118:                        "Starting " + NAME, "State", "java.lang.Integer",
119:                        new Integer(STOPPED), new Integer(STARTING));
120:                sendNotification(notification);
121:
122:                try {
123:
124:                    String value = "org.apache.naming";
125:                    String oldValue = System
126:                            .getProperty(Context.URL_PKG_PREFIXES);
127:                    if (oldValue != null) {
128:                        oldUrlValue = oldValue;
129:                        value = oldValue + ":" + value;
130:                    }
131:                    System.setProperty(Context.URL_PKG_PREFIXES, value);
132:
133:                    oldValue = System
134:                            .getProperty(Context.INITIAL_CONTEXT_FACTORY);
135:                    if ((oldValue != null) && (oldValue.length() > 0)) {
136:                        oldIcValue = oldValue;
137:                    } else {
138:                        System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
139:                                Constants.Package
140:                                        + ".java.javaURLContextFactory");
141:                    }
142:
143:                } catch (Throwable t) {
144:                    state = STOPPED;
145:                    notification = new AttributeChangeNotification(this ,
146:                            sequenceNumber++, System.currentTimeMillis(),
147:                            "Stopped " + NAME, "State", "java.lang.Integer",
148:                            new Integer(STARTING), new Integer(STOPPED));
149:                    sendNotification(notification);
150:                }
151:
152:                state = STARTED;
153:                notification = new AttributeChangeNotification(this ,
154:                        sequenceNumber++, System.currentTimeMillis(),
155:                        "Started " + NAME, "State", "java.lang.Integer",
156:                        new Integer(STARTING), new Integer(STARTED));
157:                sendNotification(notification);
158:
159:            }
160:
161:            /**
162:             * Stop the servlet container.
163:             */
164:            public void stop() {
165:
166:                Notification notification = null;
167:
168:                if (state != STARTED)
169:                    return;
170:
171:                state = STOPPING;
172:
173:                notification = new AttributeChangeNotification(this ,
174:                        sequenceNumber++, System.currentTimeMillis(),
175:                        "Stopping " + NAME, "State", "java.lang.Integer",
176:                        new Integer(STARTED), new Integer(STOPPING));
177:                sendNotification(notification);
178:
179:                try {
180:
181:                    System.setProperty(Context.URL_PKG_PREFIXES, oldUrlValue);
182:                    System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
183:                            oldIcValue);
184:
185:                } catch (Throwable t) {
186:
187:                    // FIXME
188:                    t.printStackTrace();
189:
190:                }
191:
192:                state = STOPPED;
193:
194:                notification = new AttributeChangeNotification(this ,
195:                        sequenceNumber++, System.currentTimeMillis(),
196:                        "Stopped " + NAME, "State", "java.lang.Integer",
197:                        new Integer(STOPPING), new Integer(STOPPED));
198:                sendNotification(notification);
199:
200:            }
201:
202:            /**
203:             * Destroy servlet container (if any is running).
204:             */
205:            public void destroy() {
206:
207:                if (getState() != STOPPED)
208:                    stop();
209:
210:            }
211:
212:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.