Path: blob/master/src/java.naming/share/classes/javax/naming/spi/ContinuationContext.java
41159 views
/*1* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.naming.spi;2627import java.util.Hashtable;28import javax.naming.*;2930/**31* This class is for dealing with federations/continuations.32*33* @author Rosanna Lee34* @author Scott Seligman35* @since 1.336*/3738class ContinuationContext implements Context, Resolver {39protected CannotProceedException cpe;40protected Hashtable<?,?> env;41protected Context contCtx = null;4243protected ContinuationContext(CannotProceedException cpe,44Hashtable<?,?> env) {45this.cpe = cpe;46this.env = env;47}4849protected Context getTargetContext() throws NamingException {50if (contCtx == null) {51if (cpe.getResolvedObj() == null)52throw (NamingException)cpe.fillInStackTrace();5354contCtx = NamingManager.getContext(cpe.getResolvedObj(),55cpe.getAltName(),56cpe.getAltNameCtx(),57env);58if (contCtx == null)59throw (NamingException)cpe.fillInStackTrace();60}61return contCtx;62}6364public Object lookup(Name name) throws NamingException {65Context ctx = getTargetContext();66return ctx.lookup(name);67}6869public Object lookup(String name) throws NamingException {70Context ctx = getTargetContext();71return ctx.lookup(name);72}7374public void bind(Name name, Object newObj) throws NamingException {75Context ctx = getTargetContext();76ctx.bind(name, newObj);77}7879public void bind(String name, Object newObj) throws NamingException {80Context ctx = getTargetContext();81ctx.bind(name, newObj);82}8384public void rebind(Name name, Object newObj) throws NamingException {85Context ctx = getTargetContext();86ctx.rebind(name, newObj);87}88public void rebind(String name, Object newObj) throws NamingException {89Context ctx = getTargetContext();90ctx.rebind(name, newObj);91}9293public void unbind(Name name) throws NamingException {94Context ctx = getTargetContext();95ctx.unbind(name);96}97public void unbind(String name) throws NamingException {98Context ctx = getTargetContext();99ctx.unbind(name);100}101102public void rename(Name name, Name newName) throws NamingException {103Context ctx = getTargetContext();104ctx.rename(name, newName);105}106public void rename(String name, String newName) throws NamingException {107Context ctx = getTargetContext();108ctx.rename(name, newName);109}110111public NamingEnumeration<NameClassPair> list(Name name) throws NamingException {112Context ctx = getTargetContext();113return ctx.list(name);114}115public NamingEnumeration<NameClassPair> list(String name) throws NamingException {116Context ctx = getTargetContext();117return ctx.list(name);118}119120121public NamingEnumeration<Binding> listBindings(Name name)122throws NamingException123{124Context ctx = getTargetContext();125return ctx.listBindings(name);126}127128public NamingEnumeration<Binding> listBindings(String name) throws NamingException {129Context ctx = getTargetContext();130return ctx.listBindings(name);131}132133public void destroySubcontext(Name name) throws NamingException {134Context ctx = getTargetContext();135ctx.destroySubcontext(name);136}137public void destroySubcontext(String name) throws NamingException {138Context ctx = getTargetContext();139ctx.destroySubcontext(name);140}141142public Context createSubcontext(Name name) throws NamingException {143Context ctx = getTargetContext();144return ctx.createSubcontext(name);145}146public Context createSubcontext(String name) throws NamingException {147Context ctx = getTargetContext();148return ctx.createSubcontext(name);149}150151public Object lookupLink(Name name) throws NamingException {152Context ctx = getTargetContext();153return ctx.lookupLink(name);154}155public Object lookupLink(String name) throws NamingException {156Context ctx = getTargetContext();157return ctx.lookupLink(name);158}159160public NameParser getNameParser(Name name) throws NamingException {161Context ctx = getTargetContext();162return ctx.getNameParser(name);163}164165public NameParser getNameParser(String name) throws NamingException {166Context ctx = getTargetContext();167return ctx.getNameParser(name);168}169170public Name composeName(Name name, Name prefix)171throws NamingException172{173Context ctx = getTargetContext();174return ctx.composeName(name, prefix);175}176177public String composeName(String name, String prefix)178throws NamingException {179Context ctx = getTargetContext();180return ctx.composeName(name, prefix);181}182183public Object addToEnvironment(String propName, Object value)184throws NamingException {185Context ctx = getTargetContext();186return ctx.addToEnvironment(propName, value);187}188189public Object removeFromEnvironment(String propName)190throws NamingException {191Context ctx = getTargetContext();192return ctx.removeFromEnvironment(propName);193}194195public Hashtable<?,?> getEnvironment() throws NamingException {196Context ctx = getTargetContext();197return ctx.getEnvironment();198}199200public String getNameInNamespace() throws NamingException {201Context ctx = getTargetContext();202return ctx.getNameInNamespace();203}204205public ResolveResult206resolveToClass(Name name, Class<? extends Context> contextType)207throws NamingException208{209if (cpe.getResolvedObj() == null)210throw (NamingException)cpe.fillInStackTrace();211212Resolver res = NamingManager.getResolver(cpe.getResolvedObj(),213cpe.getAltName(),214cpe.getAltNameCtx(),215env);216if (res == null)217throw (NamingException)cpe.fillInStackTrace();218return res.resolveToClass(name, contextType);219}220221public ResolveResult222resolveToClass(String name, Class<? extends Context> contextType)223throws NamingException224{225if (cpe.getResolvedObj() == null)226throw (NamingException)cpe.fillInStackTrace();227228Resolver res = NamingManager.getResolver(cpe.getResolvedObj(),229cpe.getAltName(),230cpe.getAltNameCtx(),231env);232if (res == null)233throw (NamingException)cpe.fillInStackTrace();234return res.resolveToClass(name, contextType);235}236237public void close() throws NamingException {238cpe = null;239env = null;240if (contCtx != null) {241contCtx.close();242contCtx = null;243}244}245}246247248