/** * * Copyright 2004-2005 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.geronimo.interop.naming; import java.util.HashMap; import java.util.Hashtable; import javax.naming.Context; import javax.naming.Name; import javax.naming.NameParser; import javax.naming.NamingEnumeration; import javax.naming.NamingException; import javax.naming.OperationNotSupportedException; public class InitialContext implements Context, java.io.Serializable { private static HashMap EMPTY_MAP = new HashMap(); private String prefix; InitialContext(String prefix) { this.prefix = prefix; } public HashMap getMap() { NamingContext namingContext = NamingContext.getCurrent(); if (namingContext == null) { return EMPTY_MAP; } else { return namingContext.getMap(); } } public Object lookup(Name name) throws NamingException { return lookup(name.toString()); } public Object lookup(String name) throws NamingException { NamingContext namingContext = NamingContext.getCurrent(); if (namingContext == null) { namingContext = NamingContext.getInstance(NameService.class); } return namingContext.lookup(name, prefix); } public Object lookupReturnNullIfNotFound(String name) { NamingContext namingContext = NamingContext.getCurrent(); if (namingContext == null) { return null; } else { return namingContext.lookupReturnNullIfNotFound(name, prefix); } } public void bind(Name name, Object obj) throws NamingException { throw new OperationNotSupportedException(); } public void bind(String name, Object obj) throws NamingException { throw new OperationNotSupportedException(); } public void rebind(Name name, Object obj) throws NamingException { throw new OperationNotSupportedException(); } public void rebind(String name, Object obj) throws NamingException { throw new OperationNotSupportedException(); } public void unbind(Name name) throws NamingException { throw new OperationNotSupportedException(); } public void unbind(String name) throws NamingException { throw new OperationNotSupportedException(); } public void rename(Name oldName, Name newName) throws NamingException { throw new OperationNotSupportedException(); } public void rename(String oldName, String newName) throws NamingException { throw new OperationNotSupportedException(); } public NamingEnumeration list(Name name) throws NamingException { throw new OperationNotSupportedException(); } public NamingEnumeration list(String name) throws NamingException { throw new OperationNotSupportedException(); } public NamingEnumeration listBindings(Name name) throws NamingException { throw new OperationNotSupportedException(); } public NamingEnumeration listBindings(String name) throws NamingException { throw new OperationNotSupportedException(); } public void destroySubcontext(Name name) throws NamingException { throw new OperationNotSupportedException(); } public void destroySubcontext(String name) throws NamingException { throw new OperationNotSupportedException(); } public Context createSubcontext(Name name) throws NamingException { throw new OperationNotSupportedException(); } public Context createSubcontext(String name) throws NamingException { throw new OperationNotSupportedException(); } public Object lookupLink(Name name) throws NamingException { throw new OperationNotSupportedException(); } public Object lookupLink(String name) throws NamingException { throw new OperationNotSupportedException(); } public NameParser getNameParser(Name name) throws NamingException { throw new OperationNotSupportedException(); } public NameParser getNameParser(String name) throws NamingException { throw new OperationNotSupportedException(); } public Name composeName(Name name, Name prefix) throws NamingException { throw new OperationNotSupportedException(); } public String composeName(String name, String prefix) throws NamingException { throw new OperationNotSupportedException(); } public Object addToEnvironment(String propName, Object propVal) throws NamingException { throw new OperationNotSupportedException(); } public Object removeFromEnvironment(String propName) throws NamingException { throw new OperationNotSupportedException(); } public Hashtable getEnvironment() throws NamingException { throw new OperationNotSupportedException(); } public String getNameInNamespace() throws NamingException { throw new OperationNotSupportedException(); } public void close() throws NamingException { throw new OperationNotSupportedException(); } }