Source Code Cross Referenced for NameService.java in  » EJB-Server-geronimo » plugins » org » apache » geronimo » corba » 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 » EJB Server geronimo » plugins » org.apache.geronimo.corba 
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:         */package org.apache.geronimo.corba;
017:
018:        import org.apache.commons.logging.Log;
019:        import org.apache.commons.logging.LogFactory;
020:        import org.apache.geronimo.gbean.GBeanLifecycle;
021:        import org.apache.geronimo.gbean.InvalidConfigurationException;
022:        import org.apache.geronimo.system.serverinfo.ServerInfo;
023:
024:        import org.apache.geronimo.corba.security.config.ConfigAdapter;
025:
026:        import java.net.InetSocketAddress;
027:
028:        /**
029:         * Starts the openejb transient cos naming service.
030:         * <p/>
031:         * <gbean name="NameServer" class="org.apache.geronimo.corba.NameService">
032:         * <reference name="ServerInfo">
033:         * <reference name="ConfigAdapter">
034:         * <attribute name="port">2809</attribute>
035:         * <attribute name="host">localhost</attribute>
036:         * </gbean>
037:         *
038:         * @version $Revision: 465108 $ $Date: 2006-10-17 17:23:40 -0700 (Tue, 17 Oct 2006) $
039:         */
040:        public class NameService implements  GBeanLifecycle {
041:            private static final Log log = LogFactory.getLog(NameService.class);
042:
043:            // the ORB configurator
044:            private final ConfigAdapter config;
045:            // the name service instance
046:            private Object service;
047:            // the name service listening port
048:            private final int port;
049:            // the published port name (defaults to "localhost").
050:            private String host;
051:            // indicates whether we start and host this server locally.
052:            private boolean localServer;
053:
054:            protected NameService() {
055:                service = null;
056:                config = null;
057:                port = -1;
058:                host = "localhost";
059:                localServer = true;
060:            }
061:
062:            /**
063:             * GBean constructor to create a NameService instance.
064:             *
065:             * @param serverInfo The dependent ServerInfo.  This value is not used,
066:             *                   but is in the constructor to create an ordering
067:             *                   dependency.
068:             * @param config     The ORB ConfigAdapter used to create the real
069:             *                   NameService instance.
070:             * @param host       The advertised host name.
071:             * @param port       The listener port.
072:             *
073:             * @exception Exception
074:             */
075:            public NameService(ServerInfo serverInfo, ConfigAdapter config,
076:                    String host, int port) throws Exception {
077:                this .host = host;
078:                this .port = port;
079:                this .config = config;
080:                localServer = true;
081:                service = null;
082:                // if not specified, our default host is "localhost".
083:                if (this .host == null) {
084:                    this .host = "localhost";
085:                }
086:            }
087:
088:            /**
089:             * Retrieve the host name for this NameService instance.
090:             *
091:             * @return The String host name.
092:             */
093:            public String getHost() {
094:                return host;
095:            }
096:
097:            /**
098:             * Get the port information for this NameService instance.
099:             *
100:             * @return The configured name service listener port.
101:             */
102:            public int getPort() {
103:                return port;
104:            }
105:
106:            /**
107:             * Get the "local" value for this server.  If true, an
108:             * in-process NameService instance will be created when
109:             * the service is started.  If false, this is an
110:             * indirect reference to a NameService (possibly located
111:             * elsewhere).
112:             *
113:             * @return The current localServer value.  The default is
114:             *         true.
115:             */
116:            public boolean getLocal() {
117:                return localServer;
118:            }
119:
120:            /**
121:             * Get the "local" value for this server.  If true, an
122:             * in-process NameService instance will be created when
123:             * the service is started.  If false, this is an
124:             * indirect reference to a NameService (possibly located
125:             * elsewhere).
126:             *
127:             * @param l      The new local setting.
128:             */
129:            public void setLocal(boolean l) {
130:                localServer = l;
131:            }
132:
133:            /**
134:             * Get the InetSocketAddress for this NameService.
135:             *
136:             * @return An InetSocketAddress containing the host and port
137:             *         information.
138:             */
139:            public InetSocketAddress getAddress() {
140:                return new InetSocketAddress(host, getPort());
141:            }
142:
143:            /**
144:             * Return the NameService locator as a URI (generally
145:             * using the corbaloc:: protocol);
146:             *
147:             * @return The URI in String format.
148:             */
149:            public String getURI() {
150:                return "corbaloc::" + host + ":" + port + "/NameService";
151:            }
152:
153:            /**
154:             * Start the NameService instance.  If the local
155:             * setting is true, will launch an appropriate
156:             * in-process name server instance.
157:             *
158:             * @exception Exception
159:             */
160:            public void doStart() throws Exception {
161:                if (localServer) {
162:                    try {
163:                        service = config.createNameService(host, port);
164:                        log
165:                                .debug("Started transient CORBA name service on port "
166:                                        + port);
167:                    } catch (NoSuchMethodError e) {
168:                        log
169:                                .error("Incorrect level of org.omg.CORBA classes found.\nLikely cause is an incorrect java.endorsed.dirs configuration");
170:                        throw new InvalidConfigurationException(
171:                                "CORBA usage requires Yoko CORBA spec classes in java.endorsed.dirs classpath",
172:                                e);
173:                    }
174:                }
175:            }
176:
177:            /**
178:             * Stop the name server.  Only has an effect if doStart()
179:             * launched an NameServer instance.
180:             *
181:             * @exception Exception
182:             */
183:            public void doStop() throws Exception {
184:                if (service != null) {
185:                    config.destroyNameService(service);
186:                    log.debug("Stopped transient CORBA name service on port "
187:                            + port);
188:                }
189:            }
190:
191:            public void doFail() {
192:                if (service != null) {
193:                    config.destroyNameService(service);
194:                    log.warn("Failed transient CORBA name service on port "
195:                            + port);
196:                }
197:            }
198:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.