javax.naming
Class Reference

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by javax.naming.Reference
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable , Cloneable sample code for java.lang.Cloneable definition code for java.lang.Cloneable
Direct Known Subclasses:
LinkRef sample code for javax.naming.LinkRef definition code for javax.naming.LinkRef

public class Reference
extends Object sample code for java.lang.Object definition code for java.lang.Object
implements Cloneable sample code for java.lang.Cloneable definition code for java.lang.Cloneable , Serializable sample code for java.io.Serializable definition code for java.io.Serializable

This class represents a reference to an object that is found outside of the naming/directory system.

Reference provides a way of recording address information about objects which themselves are not directly bound to the naming/directory system.

A Reference consists of an ordered list of addresses and class information about the object being referenced. Each address in the list identifies a communications endpoint for the same conceptual object. The "communications endpoint" is information that indicates how to contact the object. It could be, for example, a network address, a location in memory on the local machine, another process on the same machine, etc. The order of the addresses in the list may be of significance to object factories that interpret the reference.

Multiple addresses may arise for various reasons, such as replication or the object offering interfaces over more than one communication mechanism. The addresses are indexed starting with zero.

A Reference also contains information to assist in creating an instance of the object to which this Reference refers. It contains the class name of that object, and the class name and location of the factory to be used to create the object. The class factory location is a space-separated list of URLs representing the class path used to load the factory. When the factory class (or any class or resource upon which it depends) needs to be loaded, each URL is used (in order) to attempt to load the class.

A Reference instance is not synchronized against concurrent access by multiple threads. Threads that need to access a single Reference concurrently should synchronize amongst themselves and provide the necessary locking.

Since:
1.3
See Also:
RefAddr sample code for javax.naming.RefAddr definition code for javax.naming.RefAddr , StringRefAddr sample code for javax.naming.StringRefAddr definition code for javax.naming.StringRefAddr , BinaryRefAddr sample code for javax.naming.BinaryRefAddr definition code for javax.naming.BinaryRefAddr , Serialized Form

Field Summary
protected  Vector sample code for java.util.Vector definition code for java.util.Vector <RefAddr sample code for javax.naming.RefAddr definition code for javax.naming.RefAddr > addrs sample code for javax.naming.Reference.addrs definition code for javax.naming.Reference.addrs
          Contains the addresses contained in this Reference.
protected  String sample code for java.lang.String definition code for java.lang.String classFactory sample code for javax.naming.Reference.classFactory definition code for javax.naming.Reference.classFactory
          Contains the name of the factory class for creating an instance of the object to which this Reference refers.
protected  String sample code for java.lang.String definition code for java.lang.String classFactoryLocation sample code for javax.naming.Reference.classFactoryLocation definition code for javax.naming.Reference.classFactoryLocation
          Contains the location of the factory class.
protected  String sample code for java.lang.String definition code for java.lang.String className sample code for javax.naming.Reference.className definition code for javax.naming.Reference.className
          Contains the fully-qualified name of the class of the object to which this Reference refers.
 
Constructor Summary
Reference sample code for javax.naming.Reference.Reference(java.lang.String) definition code for javax.naming.Reference.Reference(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  className)
          Constructs a new reference for an object with class name 'className'.
Reference sample code for javax.naming.Reference.Reference(java.lang.String, javax.naming.RefAddr) definition code for javax.naming.Reference.Reference(java.lang.String, javax.naming.RefAddr) (String sample code for java.lang.String definition code for java.lang.String  className, RefAddr sample code for javax.naming.RefAddr definition code for javax.naming.RefAddr  addr)
          Constructs a new reference for an object with class name 'className' and an address.
Reference sample code for javax.naming.Reference.Reference(java.lang.String, javax.naming.RefAddr, java.lang.String, java.lang.String) definition code for javax.naming.Reference.Reference(java.lang.String, javax.naming.RefAddr, java.lang.String, java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  className, RefAddr sample code for javax.naming.RefAddr definition code for javax.naming.RefAddr  addr, String sample code for java.lang.String definition code for java.lang.String  factory, String sample code for java.lang.String definition code for java.lang.String  factoryLocation)
          Constructs a new reference for an object with class name 'className', the class name and location of the object's factory, and the address for the object.
Reference sample code for javax.naming.Reference.Reference(java.lang.String, java.lang.String, java.lang.String) definition code for javax.naming.Reference.Reference(java.lang.String, java.lang.String, java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  className, String sample code for java.lang.String definition code for java.lang.String  factory, String sample code for java.lang.String definition code for java.lang.String  factoryLocation)
          Constructs a new reference for an object with class name 'className', and the class name and location of the object's factory.
 
Method Summary
 void add sample code for javax.naming.Reference.add(int, javax.naming.RefAddr) definition code for javax.naming.Reference.add(int, javax.naming.RefAddr) (int posn, RefAddr sample code for javax.naming.RefAddr definition code for javax.naming.RefAddr  addr)
          Adds an address to the list of addresses at index posn.
 void add sample code for javax.naming.Reference.add(javax.naming.RefAddr) definition code for javax.naming.Reference.add(javax.naming.RefAddr) (RefAddr sample code for javax.naming.RefAddr definition code for javax.naming.RefAddr  addr)
          Adds an address to the end of the list of addresses.
 void clear sample code for javax.naming.Reference.clear() definition code for javax.naming.Reference.clear() ()
          Deletes all addresses from this reference.
 Object sample code for java.lang.Object definition code for java.lang.Object clone sample code for javax.naming.Reference.clone() definition code for javax.naming.Reference.clone() ()
          Makes a copy of this reference using its class name list of addresses, class factory name and class factory location.
 boolean equals sample code for javax.naming.Reference.equals(java.lang.Object) definition code for javax.naming.Reference.equals(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  obj)
          Determines whether obj is a reference with the same addresses (in same order) as this reference.
 RefAddr sample code for javax.naming.RefAddr definition code for javax.naming.RefAddr get sample code for javax.naming.Reference.get(int) definition code for javax.naming.Reference.get(int) (int posn)
          Retrieves the address at index posn.
 RefAddr sample code for javax.naming.RefAddr definition code for javax.naming.RefAddr get sample code for javax.naming.Reference.get(java.lang.String) definition code for javax.naming.Reference.get(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  addrType)
          Retrieves the first address that has the address type 'addrType'.
 Enumeration sample code for java.util.Enumeration definition code for java.util.Enumeration <RefAddr sample code for javax.naming.RefAddr definition code for javax.naming.RefAddr > getAll sample code for javax.naming.Reference.getAll() definition code for javax.naming.Reference.getAll() ()
          Retrieves an enumeration of the addresses in this reference.
 String sample code for java.lang.String definition code for java.lang.String getClassName sample code for javax.naming.Reference.getClassName() definition code for javax.naming.Reference.getClassName() ()
          Retrieves the class name of the object to which this reference refers.
 String sample code for java.lang.String definition code for java.lang.String getFactoryClassLocation sample code for javax.naming.Reference.getFactoryClassLocation() definition code for javax.naming.Reference.getFactoryClassLocation() ()
          Retrieves the location of the factory of the object to which this reference refers.
 String sample code for java.lang.String definition code for java.lang.String getFactoryClassName sample code for javax.naming.Reference.getFactoryClassName() definition code for javax.naming.Reference.getFactoryClassName() ()
          Retrieves the class name of the factory of the object to which this reference refers.
 int hashCode sample code for javax.naming.Reference.hashCode() definition code for javax.naming.Reference.hashCode() ()
          Computes the hash code of this reference.
 Object sample code for java.lang.Object definition code for java.lang.Object remove sample code for javax.naming.Reference.remove(int) definition code for javax.naming.Reference.remove(int) (int posn)
          Deletes the address at index posn from the list of addresses.
 int size sample code for javax.naming.Reference.size() definition code for javax.naming.Reference.size() ()
          Retrieves the number of addresses in this reference.
 String sample code for java.lang.String definition code for java.lang.String toString sample code for javax.naming.Reference.toString() definition code for javax.naming.Reference.toString() ()
          Generates the string representation of this reference.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Field Detail

className sample code for javax.naming.Reference.className

protected String sample code for java.lang.String definition code for java.lang.String  className
Contains the fully-qualified name of the class of the object to which this Reference refers.

See Also:
Class.getName() sample code for java.lang.Class.getName() definition code for java.lang.Class.getName()

addrs sample code for javax.naming.Reference.addrs

protected Vector sample code for java.util.Vector definition code for java.util.Vector <RefAddr sample code for javax.naming.RefAddr definition code for javax.naming.RefAddr > addrs
Contains the addresses contained in this Reference. Initialized by constructor.


classFactory sample code for javax.naming.Reference.classFactory

protected String sample code for java.lang.String definition code for java.lang.String  classFactory
Contains the name of the factory class for creating an instance of the object to which this Reference refers. Initialized to null.


classFactoryLocation sample code for javax.naming.Reference.classFactoryLocation

protected String sample code for java.lang.String definition code for java.lang.String  classFactoryLocation
Contains the location of the factory class. Initialized to null.

Constructor Detail

Reference sample code for javax.naming.Reference(java.lang.String) definition code for javax.naming.Reference(java.lang.String)

public Reference(String sample code for java.lang.String definition code for java.lang.String  className)
Constructs a new reference for an object with class name 'className'. Class factory and class factory location are set to null. The newly created reference contains zero addresses.

Parameters:
className - The non-null class name of the object to which this reference refers.

Reference sample code for javax.naming.Reference(java.lang.String, javax.naming.RefAddr) definition code for javax.naming.Reference(java.lang.String, javax.naming.RefAddr)

public Reference(String sample code for java.lang.String definition code for java.lang.String  className,
                 RefAddr sample code for javax.naming.RefAddr definition code for javax.naming.RefAddr  addr)
Constructs a new reference for an object with class name 'className' and an address. Class factory and class factory location are set to null.

Parameters:
className - The non-null class name of the object to which this reference refers.
addr - The non-null address of the object.

Reference sample code for javax.naming.Reference(java.lang.String, java.lang.String, java.lang.String) definition code for javax.naming.Reference(java.lang.String, java.lang.String, java.lang.String)

public Reference(String sample code for java.lang.String definition code for java.lang.String  className,
                 String sample code for java.lang.String definition code for java.lang.String  factory,
                 String sample code for java.lang.String definition code for java.lang.String  factoryLocation)
Constructs a new reference for an object with class name 'className', and the class name and location of the object's factory.

Parameters:
className - The non-null class name of the object to which this reference refers.
factory - The possibly null class name of the object's factory.
factoryLocation - The possibly null location from which to load the factory (e.g. URL)
See Also:
ObjectFactory sample code for javax.naming.spi.ObjectFactory definition code for javax.naming.spi.ObjectFactory , NamingManager.getObjectInstance(java.lang.Object, javax.naming.Name, javax.naming.Context, java.util.Hashtable) sample code for javax.naming.spi.NamingManager.getObjectInstance(java.lang.Object, javax.naming.Name, javax.naming.Context, java.util.Hashtable) definition code for javax.naming.spi.NamingManager.getObjectInstance(java.lang.Object, javax.naming.Name, javax.naming.Context, java.util.Hashtable)

Reference sample code for javax.naming.Reference(java.lang.String, javax.naming.RefAddr, java.lang.String, java.lang.String) definition code for javax.naming.Reference(java.lang.String, javax.naming.RefAddr, java.lang.String, java.lang.String)

public Reference(String sample code for java.lang.String definition code for java.lang.String  className,
                 RefAddr sample code for javax.naming.RefAddr definition code for javax.naming.RefAddr  addr,
                 String sample code for java.lang.String definition code for java.lang.String  factory,
                 String sample code for java.lang.String definition code for java.lang.String  factoryLocation)
Constructs a new reference for an object with class name 'className', the class name and location of the object's factory, and the address for the object.

Parameters:
className - The non-null class name of the object to which this reference refers.
factory - The possibly null class name of the object's factory.
factoryLocation - The possibly null location from which to load the factory (e.g. URL)
addr - The non-null address of the object.
See Also:
ObjectFactory sample code for javax.naming.spi.ObjectFactory definition code for javax.naming.spi.ObjectFactory , NamingManager.getObjectInstance(java.lang.Object, javax.naming.Name, javax.naming.Context, java.util.Hashtable) sample code for javax.naming.spi.NamingManager.getObjectInstance(java.lang.Object, javax.naming.Name, javax.naming.Context, java.util.Hashtable) definition code for javax.naming.spi.NamingManager.getObjectInstance(java.lang.Object, javax.naming.Name, javax.naming.Context, java.util.Hashtable)
Method Detail

getClassName sample code for javax.naming.Reference.getClassName() definition code for javax.naming.Reference.getClassName()

public String sample code for java.lang.String definition code for java.lang.String  getClassName()
Retrieves the class name of the object to which this reference refers.

Returns:
The non-null fully-qualified class name of the object. (e.g. "java.lang.String")

getFactoryClassName sample code for javax.naming.Reference.getFactoryClassName() definition code for javax.naming.Reference.getFactoryClassName()

public String sample code for java.lang.String definition code for java.lang.String  getFactoryClassName()
Retrieves the class name of the factory of the object to which this reference refers.

Returns:
The possibly null fully-qualified class name of the factory. (e.g. "java.lang.String")

getFactoryClassLocation sample code for javax.naming.Reference.getFactoryClassLocation() definition code for javax.naming.Reference.getFactoryClassLocation()

public String sample code for java.lang.String definition code for java.lang.String  getFactoryClassLocation()
Retrieves the location of the factory of the object to which this reference refers. If it is a codebase, then it is an ordered list of URLs, separated by spaces, listing locations from where the factory class definition should be loaded.

Returns:
The possibly null string containing the location for loading in the factory's class.

get sample code for javax.naming.Reference.get(java.lang.String) definition code for javax.naming.Reference.get(java.lang.String)

public RefAddr sample code for javax.naming.RefAddr definition code for javax.naming.RefAddr  get(String sample code for java.lang.String definition code for java.lang.String  addrType)
Retrieves the first address that has the address type 'addrType'. String.compareTo() is used to test the equality of the address types.

Parameters:
addrType - The non-null address type for which to find the address.
Returns:
The address in this reference with address type 'addrType; null if no such address exist.

get sample code for javax.naming.Reference.get(int) definition code for javax.naming.Reference.get(int)

public RefAddr sample code for javax.naming.RefAddr definition code for javax.naming.RefAddr  get(int posn)
Retrieves the address at index posn.

Parameters:
posn - The index of the address to retrieve.
Returns:
The address at the 0-based index posn. It must be in the range [0,getAddressCount()).
Throws:
ArrayIndexOutOfBoundsException sample code for java.lang.ArrayIndexOutOfBoundsException definition code for java.lang.ArrayIndexOutOfBoundsException - If posn not in the specified range.

getAll sample code for javax.naming.Reference.getAll() definition code for javax.naming.Reference.getAll()

public Enumeration sample code for java.util.Enumeration definition code for java.util.Enumeration <RefAddr sample code for javax.naming.RefAddr definition code for javax.naming.RefAddr > getAll()
Retrieves an enumeration of the addresses in this reference. When addresses are added, changed or removed from this reference, its effects on this enumeration are undefined.

Returns:
An non-null enumeration of the addresses (RefAddr) in this reference. If this reference has zero addresses, an enumeration with zero elements is returned.

size sample code for javax.naming.Reference.size() definition code for javax.naming.Reference.size()

public int size()
Retrieves the number of addresses in this reference.

Returns:
The nonnegative number of addresses in this reference.

add sample code for javax.naming.Reference.add(javax.naming.RefAddr) definition code for javax.naming.Reference.add(javax.naming.RefAddr)

public void add(RefAddr sample code for javax.naming.RefAddr definition code for javax.naming.RefAddr  addr)
Adds an address to the end of the list of addresses.

Parameters:
addr - The non-null address to add.

add sample code for javax.naming.Reference.add(int, javax.naming.RefAddr) definition code for javax.naming.Reference.add(int, javax.naming.RefAddr)

public void add(int posn,
                RefAddr sample code for javax.naming.RefAddr definition code for javax.naming.RefAddr  addr)
Adds an address to the list of addresses at index posn. All addresses at index posn or greater are shifted up the list by one (away from index 0).

Parameters:
posn - The 0-based index of the list to insert addr.
addr - The non-null address to add.
Throws:
ArrayIndexOutOfBoundsException sample code for java.lang.ArrayIndexOutOfBoundsException definition code for java.lang.ArrayIndexOutOfBoundsException - If posn not in the specified range.

remove sample code for javax.naming.Reference.remove(int) definition code for javax.naming.Reference.remove(int)

public Object sample code for java.lang.Object definition code for java.lang.Object  remove(int posn)
Deletes the address at index posn from the list of addresses. All addresses at index greater than posn are shifted down the list by one (towards index 0).

Parameters:
posn - The 0-based index of in address to delete.
Returns:
The address removed.
Throws:
ArrayIndexOutOfBoundsException sample code for java.lang.ArrayIndexOutOfBoundsException definition code for java.lang.ArrayIndexOutOfBoundsException - If posn not in the specified range.

clear sample code for javax.naming.Reference.clear() definition code for javax.naming.Reference.clear()

public void clear()
Deletes all addresses from this reference.


equals sample code for javax.naming.Reference.equals(java.lang.Object) definition code for javax.naming.Reference.equals(java.lang.Object)

public boolean equals(Object sample code for java.lang.Object definition code for java.lang.Object  obj)
Determines whether obj is a reference with the same addresses (in same order) as this reference. The addresses are checked using RefAddr.equals(). In addition to having the same addresses, the Reference also needs to have the same class name as this reference. The class factory and class factory location are not checked. If obj is null or not an instance of Reference, null is returned.

Overrides:
equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) in class Object sample code for java.lang.Object definition code for java.lang.Object
Parameters:
obj - The possibly null object to check.
Returns:
true if obj is equal to this reference; false otherwise.
See Also:
Object.hashCode() sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable

hashCode sample code for javax.naming.Reference.hashCode() definition code for javax.naming.Reference.hashCode()

public int hashCode()
Computes the hash code of this reference. The hash code is the sum of the hash code of its addresses.

Overrides:
hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
A hash code of this reference as an int.
See Also:
Object.equals(java.lang.Object) sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable

toString sample code for javax.naming.Reference.toString() definition code for javax.naming.Reference.toString()

public String sample code for java.lang.String definition code for java.lang.String  toString()
Generates the string representation of this reference. The string consists of the class name to which this reference refers, and the string representation of each of its addresses. This representation is intended for display only and not to be parsed.

Overrides:
toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
The non-null string representation of this reference.

clone sample code for javax.naming.Reference.clone() definition code for javax.naming.Reference.clone()

public Object sample code for java.lang.Object definition code for java.lang.Object  clone()
Makes a copy of this reference using its class name list of addresses, class factory name and class factory location. Changes to the newly created copy does not affect this Reference and vice versa.

Overrides:
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
a clone of this instance.
See Also:
Cloneable sample code for java.lang.Cloneable definition code for java.lang.Cloneable