Source Code Cross Referenced for DefaultInitialContextFactoryImpl.java in  » Inversion-of-Control » carbon » org » sape » carbon » services » jndi » 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 » Inversion of Control » carbon » org.sape.carbon.services.jndi 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the Sapient Public License
003:         * Version 1.0 (the "License"); you may not use this file except in compliance
004:         * with the License. You may obtain a copy of the License at
005:         * http://carbon.sf.net/License.html.
006:         *
007:         * Software distributed under the License is distributed on an "AS IS" basis,
008:         * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
009:         * the specific language governing rights and limitations under the License.
010:         *
011:         * The Original Code is The Carbon Component Framework.
012:         *
013:         * The Initial Developer of the Original Code is Sapient Corporation
014:         *
015:         * Copyright (C) 2003 Sapient Corporation. All Rights Reserved.
016:         */
017:        package org.sape.carbon.services.jndi;
018:
019:        import java.util.Hashtable;
020:        import java.util.Map;
021:
022:        import javax.naming.InitialContext;
023:        import javax.naming.NamingException;
024:        import javax.naming.directory.InitialDirContext;
025:
026:        import org.apache.commons.logging.Log;
027:        import org.apache.commons.logging.LogFactory;
028:
029:        import org.sape.carbon.core.component.Component;
030:        import org.sape.carbon.core.component.ComponentConfiguration;
031:        import org.sape.carbon.core.component.lifecycle.Configurable;
032:        import org.sape.carbon.core.component.lifecycle.Initializable;
033:        import org.sape.carbon.core.config.InvalidConfigurationException;
034:
035:        /**
036:         * <p>Default implementation of InitialContextFactory</p>
037:         *
038:         * Copyright 2003 Sapient
039:         * @since carbon 2.1
040:         * @author Douglas Voet, Jul 30, 2003
041:         * @version $Revision: 1.2 $($Author: dvoet $ / $Date: 2003/10/30 19:28:56 $)
042:         */
043:        public class DefaultInitialContextFactoryImpl implements 
044:                InitialContextFactory, Configurable, Initializable {
045:
046:            private Log log = LogFactory.getLog(this .getClass());
047:
048:            protected Hashtable environment;
049:
050:            public void configure(ComponentConfiguration configuration) {
051:
052:                try {
053:                    InitialContextFactoryConfiguration factoryConfig = (InitialContextFactoryConfiguration) configuration;
054:
055:                    this .environment.clear();
056:                    if (factoryConfig.getEnvironment() != null) {
057:                        this .environment.putAll(factoryConfig.getEnvironment());
058:                    }
059:
060:                } catch (ClassCastException cce) {
061:                    throw new InvalidConfigurationException(this .getClass(),
062:                            configuration.getConfigurationName(),
063:                            "ConfigurationInterface",
064:                            "Configuration was not of type "
065:                                    + InitialContextFactoryConfiguration.class
066:                                            .getName(), cce);
067:                }
068:
069:            }
070:
071:            public void initialize(Component this Component) {
072:                this .environment = new Hashtable();
073:            }
074:
075:            /**
076:             * Gets a new InitialContext instance with evironment values that come
077:             * from the service's configuration.
078:             * 
079:             * @return a new InitalContext
080:             * @throws NamingException this is also logged at the info level
081:             */
082:            public InitialContext getContext() throws NamingException {
083:                try {
084:                    return new InitialContext(this .environment);
085:                } catch (NamingException ne) {
086:                    this .log.info("Caught NamingException", ne);
087:                    throw ne;
088:                }
089:            }
090:
091:            /**
092:             * Gets a new InitialContext instance with evironment values that come
093:             * from the service's configuration, but environment values can also
094:             * be passed via the environment parameter to augment or override the
095:             * values stored in configuration.
096:             * 
097:             * @param environment values that augment and/or override the values
098:             * stored in configuration
099:             * @return a new InitialContext
100:             * @throws NamingException this is also logged at the info level
101:             */
102:            public InitialContext getContext(Map givenEnvironment)
103:                    throws NamingException {
104:
105:                try {
106:                    Hashtable localEnvironment = new Hashtable(this .environment);
107:                    if (givenEnvironment != null) {
108:                        localEnvironment.putAll(givenEnvironment);
109:                    }
110:                    return new InitialContext(localEnvironment);
111:                } catch (NamingException ne) {
112:                    this .log.info("Caught NamingException", ne);
113:                    throw ne;
114:                }
115:            }
116:
117:            /**
118:             * Gets a new InitialContext with environment values given in the
119:             * evironment parameter. The service's configuration is ignored.
120:             * 
121:             * @param environment values used to construct the InitialContext
122:             * @return a new InitialContext
123:             * @throws NamingException this is also logged at the info level
124:             */
125:            public InitialContext getContextIgnoreConfig(Map givenEnvironment)
126:                    throws NamingException {
127:
128:                try {
129:                    Hashtable localEnvironment = null;
130:                    if (givenEnvironment instanceof  Hashtable) {
131:                        localEnvironment = (Hashtable) givenEnvironment;
132:                    } else if (givenEnvironment != null) {
133:                        localEnvironment = new Hashtable(givenEnvironment);
134:                    }
135:
136:                    return new InitialContext(localEnvironment);
137:                } catch (NamingException ne) {
138:                    this .log.info("Caught NamingException", ne);
139:                    throw ne;
140:                }
141:            }
142:
143:            /**
144:             * Gets a new InitialDirContext instance with evironment values that come
145:             * from the service's configuration.
146:             * 
147:             * @return a new InitialDirContext
148:             * @throws NamingException
149:             */
150:            public InitialDirContext getDirContext() throws NamingException {
151:                try {
152:                    return new InitialDirContext(this .environment);
153:                } catch (NamingException ne) {
154:                    this .log.info("Caught NamingException", ne);
155:                    throw ne;
156:                }
157:            }
158:
159:            /**
160:             * Gets a new InitialDirContext instance with evironment values that come
161:             * from the service's configuration, but environment values can also
162:             * be passed via the environment parameter to augment or override the
163:             * values stored in configuration.
164:             * 
165:             * @param environment values that augment and/or override the values
166:             * stored in configuration
167:             * @return a new InitialDirContext
168:             * @throws NamingException
169:             */
170:            public InitialDirContext getDirContext(Map givenEnvironment)
171:                    throws NamingException {
172:
173:                try {
174:                    Hashtable localEnvironment = new Hashtable(this .environment);
175:                    if (givenEnvironment != null) {
176:                        localEnvironment.putAll(givenEnvironment);
177:                    }
178:                    return new InitialDirContext(localEnvironment);
179:                } catch (NamingException ne) {
180:                    this .log.info("Caught NamingException", ne);
181:                    throw ne;
182:                }
183:            }
184:
185:            /**
186:             * Gets a new InitialDirContext with environment values given in the
187:             * evironment parameter. The service's configuration is ignored.
188:             * 
189:             * @param environment values used to construct the InitialContext
190:             * @return a new InitialDirContext
191:             * @throws NamingException
192:             */
193:            public InitialDirContext getDirContextIgnoreConfig(
194:                    Map givenEnvironment) throws NamingException {
195:
196:                try {
197:                    Hashtable localEnvironment = null;
198:                    if (givenEnvironment instanceof  Hashtable) {
199:                        localEnvironment = (Hashtable) givenEnvironment;
200:                    } else if (givenEnvironment != null) {
201:                        localEnvironment = new Hashtable(givenEnvironment);
202:                    }
203:
204:                    return new InitialDirContext(localEnvironment);
205:                } catch (NamingException ne) {
206:                    this .log.info("Caught NamingException", ne);
207:                    throw ne;
208:                }
209:            }
210:
211:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.