Source Code Cross Referenced for NamingDirector.java in  » Net » Coadunation_1.0.1 » com » rift » coad » lib » 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 » Net » Coadunation_1.0.1 » com.rift.coad.lib.naming 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * CoadunationLib: The coaduntion implementation library.
003:         * Copyright (C) 2006  Rift IT Contracting
004:         * 
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation; either
008:         * version 2.1 of the License, or (at your option) any later version.
009:         * 
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:         * Lesser General Public License for more details.
014:         * 
015:         * You should have received a copy of the GNU Lesser General Public
016:         * License along with this library; if not, write to the Free Software
017:         * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
018:         *
019:         * NamingDirector.java
020:         *
021:         * This object is responsible for instanciating the naming server.
022:         */
023:
024:        // package path
025:        package com.rift.coad.lib.naming;
026:
027:        // java imports
028:        import java.lang.reflect.Constructor;
029:        import java.rmi.registry.LocateRegistry;
030:        import java.rmi.registry.Registry;
031:        import org.omg.CORBA.ORB;
032:        import org.omg.PortableServer.POA;
033:        import org.omg.PortableServer.POAHelper;
034:        import javax.naming.Context;
035:
036:        // logging import
037:        import org.apache.log4j.Logger;
038:
039:        // carol imports
040:        import org.objectweb.carol.util.configuration.ConfigurationRepository;
041:
042:        // coadunation imports
043:        import com.rift.coad.lib.naming.*;
044:        import com.rift.coad.lib.configuration.ConfigurationFactory;
045:        import com.rift.coad.lib.configuration.Configuration;
046:        import com.rift.coad.lib.thread.CoadunationThreadGroup;
047:
048:        /**
049:         * This object is responsible for instanciating the naming server.
050:         *
051:         * @author Brett Chaldecott
052:         */
053:        public class NamingDirector {
054:
055:            // the class constants
056:            private final static String ORB_MANAGER = "orb_manager";
057:            private final static String NAMING_CONTEXT_MANAGER = "naming_context_manager";
058:            private final static String INSTANCE_IDENTIFIER = "instance_identifier";
059:            public final static String PRIMARY_URL = "primary_jndi_url";
060:            public final static String PRIMARY = "primary";
061:
062:            // the class log variable
063:            protected Logger log = Logger.getLogger(NamingDirector.class
064:                    .getName());
065:
066:            // The singleton reference
067:            private static NamingDirector singleton = null;
068:
069:            // private member variables
070:            private String instanceId = null;
071:            private String jndiBase = null;
072:            private String primaryJNDIUrl = null;
073:            private boolean primary = false;
074:            private OrbManager orbManager = null;
075:            private NamingContextManager namingContextManager = null;
076:            private CoadunationThreadGroup threadGroup = null;
077:
078:            /** Creates a new instance of NamingDirector */
079:            private NamingDirector(CoadunationThreadGroup threadGroup)
080:                    throws NamingException {
081:                try {
082:                    // init carol
083:                    ConfigurationRepository.init();
084:                    ConfigurationRepository
085:                            .addInterceptors("iiop",
086:                                    "com.rift.coad.lib.interceptor.iiop.InterceptorIntializer");
087:
088:                    // the reference to the configuration class
089:                    Configuration config = ConfigurationFactory.getInstance()
090:                            .getConfig(this .getClass());
091:
092:                    // retrieve the instance identifier
093:                    instanceId = config.getString(INSTANCE_IDENTIFIER);
094:                    primary = config.getBoolean(PRIMARY);
095:                    primaryJNDIUrl = config.getString(PRIMARY_URL);
096:
097:                    if (primary) {
098:                        jndiBase = primaryJNDIUrl;
099:                    } else {
100:                        jndiBase = primaryJNDIUrl + "/"
101:                                + NamingConstants.SUBCONTEXT + "/" + instanceId;
102:                    }
103:
104:                    // init the orb manager
105:                    Class ref = Class.forName(config.getString(ORB_MANAGER));
106:                    Constructor orgManagerConstructor = ref
107:                            .getConstructor(threadGroup.getClass());
108:                    orbManager = (OrbManager) orgManagerConstructor
109:                            .newInstance(threadGroup);
110:
111:                    // init the naming context manager
112:                    ref = Class.forName(config
113:                            .getString(NAMING_CONTEXT_MANAGER));
114:                    Constructor namingConstructor = ref.getConstructor(
115:                            threadGroup.getClass(), OrbManager.class,
116:                            String.class);
117:                    namingContextManager = (NamingContextManager) namingConstructor
118:                            .newInstance(threadGroup, orbManager, instanceId);
119:
120:                    // set the initial context factory.
121:                    System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
122:                            namingContextManager.getInitialContextFactory());
123:                    // set the initial context factory.
124:                    System.setProperty(Context.URL_PKG_PREFIXES,
125:                            namingContextManager.getURLContextFactory());
126:                } catch (Exception ex) {
127:                    log.error("Failed to start the naming director : "
128:                            + ex.getMessage(), ex);
129:                    throw new NamingException("Failed to init carol :"
130:                            + ex.getMessage(), ex);
131:                }
132:            }
133:
134:            /**
135:             * This method inits the naming director and starts carol.
136:             */
137:            public synchronized static NamingDirector init(
138:                    CoadunationThreadGroup threadGroup) throws NamingException {
139:                if (singleton == null) {
140:                    singleton = new NamingDirector(threadGroup);
141:                }
142:                return singleton;
143:            }
144:
145:            /**
146:             * This method returns a reference to the current instancance in memory.
147:             *
148:             * @exception Exception
149:             */
150:            public synchronized static NamingDirector getInstance()
151:                    throws NamingException {
152:                if (singleton == null) {
153:                    throw new NamingException(
154:                            "The naming director has not been initialized.");
155:                }
156:                return singleton;
157:            }
158:
159:            /**
160:             * This method returns the id for this coadunation instance.
161:             *
162:             * @return The string containing the id of this coadunation instance.
163:             */
164:            public String getInstanceId() {
165:                return instanceId;
166:            }
167:
168:            /**
169:             * This method returns true if this is a primary.
170:             *
171:             * @return TRUE if primary, FALSE if not.
172:             */
173:            public boolean isPrimary() {
174:                return primary;
175:            }
176:
177:            /**
178:             * This method returns the JNDI base for this instance.
179:             *
180:             * @return The string containing the jndi base for this instance.
181:             */
182:            public String getJNDIBase() {
183:                return jndiBase;
184:            }
185:
186:            /**
187:             * This method returns the primary JNDI url.
188:             *
189:             * @return The string containing the jndi base for this instance.
190:             */
191:            public String getPrimaryJNDIUrl() {
192:                return primaryJNDIUrl;
193:            }
194:
195:            /**
196:             * Retrieve a reference to the ORB.
197:             *
198:             * @return The reference to the orb.
199:             */
200:            public ORB getORB() {
201:                return orbManager.getORB();
202:            }
203:
204:            /**
205:             * Retrieve a reference to the POA.
206:             *
207:             * @return The reference to the POA.
208:             */
209:            public POA getPOA() {
210:                return orbManager.getPOA();
211:            }
212:
213:            /**
214:             * This method is called to init the context for a class loader.
215:             */
216:            public void initContext() throws NamingException {
217:                namingContextManager.initContext();
218:            }
219:
220:            /**
221:             * This method is called to release the context for class loader.
222:             */
223:            public void releaseContext() {
224:                namingContextManager.releaseContext();
225:            }
226:
227:            /**
228:             * This method is responsible for 
229:             */
230:            public synchronized void shutdown() {
231:                namingContextManager.shutdown();
232:                orbManager.terminate();
233:            }
234:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.