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


001:        /*
002:         * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/NamingService.java,v 1.2 2001/11/22 16:48:32 remm Exp $
003:         * $Revision: 1.2 $
004:         * $Date: 2001/11/22 16:48:32 $
005:         *
006:         * ====================================================================
007:         *
008:         * The Apache Software License, Version 1.1
009:         *
010:         * Copyright (c) 1999 The Apache Software Foundation.  All rights 
011:         * reserved.
012:         *
013:         * Redistribution and use in source and binary forms, with or without
014:         * modification, are permitted provided that the following conditions
015:         * are met:
016:         *
017:         * 1. Redistributions of source code must retain the above copyright
018:         *    notice, this list of conditions and the following disclaimer. 
019:         *
020:         * 2. Redistributions in binary form must reproduce the above copyright
021:         *    notice, this list of conditions and the following disclaimer in
022:         *    the documentation and/or other materials provided with the
023:         *    distribution.
024:         *
025:         * 3. The end-user documentation included with the redistribution, if
026:         *    any, must include the following acknowlegement:  
027:         *       "This product includes software developed by the 
028:         *        Apache Software Foundation (http://www.apache.org/)."
029:         *    Alternately, this acknowlegement may appear in the software itself,
030:         *    if and wherever such third-party acknowlegements normally appear.
031:         *
032:         * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
033:         *    Foundation" must not be used to endorse or promote products derived
034:         *    from this software without prior written permission. For written 
035:         *    permission, please contact apache@apache.org.
036:         *
037:         * 5. Products derived from this software may not be called "Apache"
038:         *    nor may "Apache" appear in their names without prior written
039:         *    permission of the Apache Group.
040:         *
041:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
042:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
043:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
044:         * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
045:         * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
046:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
047:         * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
048:         * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
049:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
050:         * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
051:         * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
052:         * SUCH DAMAGE.
053:         * ====================================================================
054:         *
055:         * This software consists of voluntary contributions made by many
056:         * individuals on behalf of the Apache Software Foundation.  For more
057:         * information on the Apache Software Foundation, please see
058:         * <http://www.apache.org/>.
059:         *
060:         * [Additional notices, if required by prior licensing conditions]
061:         *
062:         */
063:
064:        package org.apache.naming;
065:
066:        import javax.naming.Context;
067:        import javax.management.NotificationBroadcasterSupport;
068:        import javax.management.ObjectName;
069:        import javax.management.MBeanServer;
070:        import javax.management.MBeanRegistration;
071:        import javax.management.AttributeChangeNotification;
072:        import javax.management.Notification;
073:
074:        /**
075:         * Implementation of the NamingService JMX MBean.
076:         * 
077:         * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
078:         * @version $Revision: 1.2 $
079:         */
080:
081:        public final class NamingService extends NotificationBroadcasterSupport
082:                implements  NamingServiceMBean, MBeanRegistration {
083:
084:            // ----------------------------------------------------- Instance Variables
085:
086:            /**
087:             * Status of the Slide domain.
088:             */
089:            private int state = STOPPED;
090:
091:            /**
092:             * Notification sequence number.
093:             */
094:            private long sequenceNumber = 0;
095:
096:            /**
097:             * Old URL packages value.
098:             */
099:            private String oldUrlValue = "";
100:
101:            /**
102:             * Old initial context value.
103:             */
104:            private String oldIcValue = "";
105:
106:            // ---------------------------------------------- MBeanRegistration Methods
107:
108:            public ObjectName preRegister(MBeanServer server, ObjectName name)
109:                    throws Exception {
110:                return new ObjectName(OBJECT_NAME);
111:            }
112:
113:            public void postRegister(Boolean registrationDone) {
114:                if (!registrationDone.booleanValue())
115:                    destroy();
116:            }
117:
118:            public void preDeregister() throws Exception {
119:            }
120:
121:            public void postDeregister() {
122:                destroy();
123:            }
124:
125:            // ----------------------------------------------------- SlideMBean Methods
126:
127:            /**
128:             * Retruns the Catalina component name.
129:             */
130:            public String getName() {
131:                return NAME;
132:            }
133:
134:            /**
135:             * Returns the state.
136:             */
137:            public int getState() {
138:                return state;
139:            }
140:
141:            /**
142:             * Returns a String representation of the state.
143:             */
144:            public String getStateString() {
145:                return states[state];
146:            }
147:
148:            /**
149:             * Start the servlet container.
150:             */
151:            public void start() throws Exception {
152:
153:                Notification notification = null;
154:
155:                if (state != STOPPED)
156:                    return;
157:
158:                state = STARTING;
159:
160:                // Notifying the MBEan server that we're starting
161:
162:                notification = new AttributeChangeNotification(this ,
163:                        sequenceNumber++, System.currentTimeMillis(),
164:                        "Starting " + NAME, "State", "java.lang.Integer",
165:                        new Integer(STOPPED), new Integer(STARTING));
166:                sendNotification(notification);
167:
168:                try {
169:
170:                    String value = "org.apache.naming";
171:                    String oldValue = System
172:                            .getProperty(Context.URL_PKG_PREFIXES);
173:                    if (oldValue != null) {
174:                        oldUrlValue = oldValue;
175:                        value = oldValue + ":" + value;
176:                    }
177:                    System.setProperty(Context.URL_PKG_PREFIXES, value);
178:
179:                    oldValue = System
180:                            .getProperty(Context.INITIAL_CONTEXT_FACTORY);
181:                    if (oldValue != null) {
182:                        oldIcValue = oldValue;
183:                    } else {
184:                        System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
185:                                Constants.Package
186:                                        + ".java.javaURLContextFactory");
187:                    }
188:
189:                } catch (Throwable t) {
190:                    state = STOPPED;
191:                    notification = new AttributeChangeNotification(this ,
192:                            sequenceNumber++, System.currentTimeMillis(),
193:                            "Stopped " + NAME, "State", "java.lang.Integer",
194:                            new Integer(STARTING), new Integer(STOPPED));
195:                    sendNotification(notification);
196:                }
197:
198:                state = STARTED;
199:                notification = new AttributeChangeNotification(this ,
200:                        sequenceNumber++, System.currentTimeMillis(),
201:                        "Started " + NAME, "State", "java.lang.Integer",
202:                        new Integer(STARTING), new Integer(STARTED));
203:                sendNotification(notification);
204:
205:            }
206:
207:            /**
208:             * Stop the servlet container.
209:             */
210:            public void stop() {
211:
212:                Notification notification = null;
213:
214:                if (state != STARTED)
215:                    return;
216:
217:                state = STOPPING;
218:
219:                notification = new AttributeChangeNotification(this ,
220:                        sequenceNumber++, System.currentTimeMillis(),
221:                        "Stopping " + NAME, "State", "java.lang.Integer",
222:                        new Integer(STARTED), new Integer(STOPPING));
223:                sendNotification(notification);
224:
225:                try {
226:
227:                    System.setProperty(Context.URL_PKG_PREFIXES, oldUrlValue);
228:                    System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
229:                            oldIcValue);
230:
231:                } catch (Throwable t) {
232:
233:                    // FIXME
234:                    t.printStackTrace();
235:
236:                }
237:
238:                state = STOPPED;
239:
240:                notification = new AttributeChangeNotification(this ,
241:                        sequenceNumber++, System.currentTimeMillis(),
242:                        "Stopped " + NAME, "State", "java.lang.Integer",
243:                        new Integer(STOPPING), new Integer(STOPPED));
244:                sendNotification(notification);
245:
246:            }
247:
248:            /**
249:             * Destroy servlet container (if any is running).
250:             */
251:            public void destroy() {
252:
253:                if (getState() != STOPPED)
254:                    stop();
255:
256:            }
257:
258:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.