1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.spring.jndi;
24  
25  import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil;
26  
27  import java.util.Hashtable;
28  
29  import javax.naming.Binding;
30  import javax.naming.Context;
31  import javax.naming.Name;
32  import javax.naming.NameClassPair;
33  import javax.naming.NameParser;
34  import javax.naming.NamingEnumeration;
35  import javax.naming.NamingException;
36  
37  import org.apache.commons.logging.Log;
38  import org.apache.commons.logging.LogFactory;
39  
40  /**
41   * <a href="PortalInitialContext.java.html"><b><i>View Source</i></b></a>
42   *
43   * @author Brian Wing Shun Chan
44   *
45   */
46  public class PortalInitialContext implements Context {
47  
48      public Object addToEnvironment(String propName, Object propVal) {
49          return null;
50      }
51  
52      public void bind(Name name, Object obj) {
53      }
54  
55      public void bind(String name, Object obj) {
56      }
57  
58      public void close() {
59      }
60  
61      public Name composeName(Name name, Name prefix) {
62          return null;
63      }
64  
65      public String composeName(String name, String prefix) {
66          return null;
67      }
68  
69      public Context createSubcontext(Name name) {
70          return null;
71      }
72  
73      public Context createSubcontext(String name) {
74          return null;
75      }
76  
77      public void destroySubcontext(Name name) {
78      }
79  
80      public void destroySubcontext(String name) {
81      }
82  
83      public Hashtable<?, ?> getEnvironment() {
84          return null;
85      }
86  
87      public String getNameInNamespace() {
88          return null;
89      }
90  
91      public NameParser getNameParser(Name name) {
92          return null;
93      }
94  
95      public NameParser getNameParser(String name) {
96          return null;
97      }
98  
99      public NamingEnumeration<NameClassPair> list(Name name) {
100         return null;
101     }
102 
103     public NamingEnumeration<NameClassPair> list(String name) {
104         return null;
105     }
106 
107     public NamingEnumeration<Binding> listBindings(Name name) {
108         return null;
109     }
110 
111     public NamingEnumeration<Binding> listBindings(String name) {
112         return null;
113     }
114 
115     public Object lookup(Name name) {
116         return null;
117     }
118 
119     public Object lookup(String name) throws NamingException {
120         Object value = null;
121 
122         if (name.equals("jdbc/LiferayPool")) {
123             try {
124                 value = PortalBeanLocatorUtil.locate("liferayDataSource");
125             }
126             catch (Exception e) {
127                 _log.error(e, e);
128             }
129         }
130 
131         if (value == null) {
132             throw new NamingException();
133         }
134 
135         return value;
136     }
137 
138     public Object lookupLink(Name name) {
139         return null;
140     }
141 
142     public Object lookupLink(String name) {
143         return null;
144     }
145 
146     public void rebind(Name name, Object obj) {
147     }
148 
149     public void rebind(String name, Object obj) {
150     }
151 
152     public Object removeFromEnvironment(String propName) {
153         return null;
154     }
155 
156     public void rename(Name oldName, Name newName) {
157     }
158 
159     public void rename(String oldName, String newName) {
160     }
161 
162     public void unbind(Name name) {
163     }
164 
165     public void unbind(String name) {
166     }
167 
168     private static Log _log = LogFactory.getLog(PortalInitialContext.class);
169 
170 }