0N/A/*
2362N/A * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.naming;
0N/A
0N/A/**
0N/A * This class represents a Reference whose contents is a name, called the link name,
0N/A * that is bound to an atomic name in a context.
0N/A *<p>
0N/A * The name is a URL, or a name to be resolved relative to the initial
0N/A * context, or if the first character of the name is ".", the name
0N/A * is relative to the context in which the link is bound.
0N/A *<p>
0N/A * Normal resolution of names in context operations always follow links.
0N/A * Resolution of the link name itself may cause resolution to pass through
0N/A * other links. This gives rise to the possibility of a cycle of links whose
0N/A * resolution could not terminate normally. As a simple means to avoid such
0N/A * non-terminating resolutions, service providers may define limits on the
0N/A * number of links that may be involved in any single operation invoked
0N/A * by the caller.
0N/A *<p>
0N/A * A LinkRef contains a single StringRefAddr, whose type is "LinkAddress",
0N/A * and whose contents is the link name. The class name field of the
0N/A * Reference is that of this (LinkRef) class.
0N/A *<p>
0N/A * LinkRef is bound to a name using the normal Context.bind()/rebind(), and
0N/A * DirContext.bind()/rebind(). Context.lookupLink() is used to retrieve the link
0N/A * itself if the terminal atomic name is bound to a link.
0N/A *<p>
0N/A * Many naming systems support a native notion of link that may be used
0N/A * within the naming system itself. JNDI does not specify whether
0N/A * there is any relationship between such native links and JNDI links.
0N/A *<p>
0N/A * A LinkRef instance is not synchronized against concurrent access by multiple
0N/A * threads. Threads that need to access a LinkRef instance concurrently should
0N/A * synchronize amongst themselves and provide the necessary locking.
0N/A *
0N/A * @author Rosanna Lee
0N/A * @author Scott Seligman
0N/A *
0N/A * @see LinkException
0N/A * @see LinkLoopException
0N/A * @see MalformedLinkException
0N/A * @see Context#lookupLink
0N/A * @since 1.3
0N/A */
0N/A
0N/A /*<p>
0N/A * The serialized form of a LinkRef object consists of the serialized
0N/A * fields of its Reference superclass.
0N/A */
0N/A
0N/Apublic class LinkRef extends Reference {
0N/A /* code for link handling */
0N/A static final String linkClassName = LinkRef.class.getName();
0N/A static final String linkAddrType = "LinkAddress";
0N/A
0N/A /**
0N/A * Constructs a LinkRef for a name.
0N/A * @param linkName The non-null name for which to create this link.
0N/A */
0N/A public LinkRef(Name linkName) {
0N/A super(linkClassName, new StringRefAddr(linkAddrType, linkName.toString()));
0N/A }
0N/A
0N/A /**
0N/A * Constructs a LinkRef for a string name.
0N/A * @param linkName The non-null name for which to create this link.
0N/A */
0N/A public LinkRef(String linkName) {
0N/A super(linkClassName, new StringRefAddr(linkAddrType, linkName));
0N/A }
0N/A
0N/A /**
0N/A * Retrieves the name of this link.
0N/A *
0N/A * @return The non-null name of this link.
0N/A * @exception MalformedLinkException If a link name could not be extracted
0N/A * @exception NamingException If a naming exception was encountered.
0N/A */
0N/A public String getLinkName() throws NamingException {
0N/A if (className != null && className.equals(linkClassName)) {
0N/A RefAddr addr = get(linkAddrType);
0N/A if (addr != null && addr instanceof StringRefAddr) {
0N/A return (String)((StringRefAddr)addr).getContent();
0N/A }
0N/A }
0N/A throw new MalformedLinkException();
0N/A }
0N/A /**
0N/A * Use serialVersionUID from JNDI 1.1.1 for interoperability
0N/A */
0N/A private static final long serialVersionUID = -5386290613498931298L;
0N/A}