All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class javax.naming.Reference

java.lang.Object
   |
   +----javax.naming.Reference

public class Reference
extends Object
implements Cloneable, Serializable
Reference represents a way of recording address information about objects which themselves are not directly bound to the naming 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.

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.

The serialized form of a Reference object consists of the class name of the object being referenced (a String), a Vector of the addresses (each a RefAddr), the name of the class factory (a String), and the location of the class factory (a String).

See Also:
RefAddr, StringRefAddr, BinaryRefAddr

Variable Index

 o addrs
Field containing the adddresses contained in this Reference.
 o classFactory
Field containing the name of the factory class for creating an instance of the object to which this Reference refers.
 o classFactoryLocation
Field containing the location of the factory class.
 o className
Field containing the fully-qualified name of the class of the object to which this Reference refers.

Constructor Index

 o Reference(String)
Constructs a new reference for an object with class name 'className'.
 o Reference(String, RefAddr)
Constructs a new reference for an object with class name 'className' and an address.
 o Reference(String, RefAddr, String, String)
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.
 o Reference(String, String, String)
Constructs a new reference for an object with class name 'className', and the class name and location of the object's factory.

Method Index

 o add(int, RefAddr)
Adds an address to the list of addresses at index posn.
 o add(RefAddr)
Adds an address to the end of the list of addresses.
 o clear()
Deletes all addresses from this reference.
 o clone()
Makes a copy of this reference using its class name list of addresses, class factory name and class factory location.
 o equals(Object)
Determines whether obj is a reference with the same addresses (in same order) as this reference.
 o get(int)
Retrieves the address at index posn.
 o get(String)
Retrieves the first address that has the address type 'addrType'.
 o getAll()
Retrieves an enumeration of the addresses in this reference.
 o getClassName()
Retrieves the class name of the object to which this reference refers.
 o getFactoryClassLocation()
Retrieves the location of the factory of the object to which this reference refers.
 o getFactoryClassName()
Retrieves the class name of the factory of the object to which this reference refers.
 o hashCode()
Computes the hash code of this reference.
 o remove(int)
Deletes the address at index posn from the list of addresses.
 o size()
Retrieves the number of adddresses in this reference.
 o toString()
Generates the string representation of this reference.

Variables

 o className
 protected String className
Field containing the fully-qualified name of the class of the object to which this Reference refers.

See Also:
getName
 o addrs
 protected Vector addrs
Field containing the adddresses contained in this Reference. Initialized by constructor.

 o classFactory
 protected String classFactory
Field containing the name of the factory class for creating an instance of the object to which this Reference refers. Initialized to null.

 o classFactoryLocation
 protected String classFactoryLocation
Field containing the location of the factory class. Initialized to null.

Constructors

 o Reference
 public Reference(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 constains zero addresses.

Parameters:
className - The non-null class name of the object to which this reference refers.
 o Reference
 public Reference(String className,
                  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.
 o Reference
 public Reference(String className,
                  String factory,
                  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, getObjectInstance
 o Reference
 public Reference(String className,
                  RefAddr addr,
                  String factory,
                  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, getObjectInstance

Methods

 o getClassName
 public 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")
 o getFactoryClassName
 public 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")
 o getFactoryClassLocation
 public String getFactoryClassLocation()
Retrieves the location of the factory of the object to which this reference refers.

Returns:
The possibly null string containing the location for loading in the factory's class.
 o get
 public RefAddr get(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.
 o get
 public 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
If posn not in the specified range.
 o getAll
 public Enumeration 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.
 o size
 public int size()
Retrieves the number of adddresses in this reference.

Returns:
The nonnegative number of addresses in this reference.
 o add
 public void add(RefAddr addr)
Adds an address to the end of the list of addresses.

Parameters:
addr - The non-null address to add.
 o add
 public void add(int posn,
                 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
If posn not in the specified range.
 o remove
 public 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
If posn not in the specified range.
 o clear
 public void clear()
Deletes all addresses from this reference.

 o equals
 public boolean equals(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.

Parameters:
obj - The possibly null object to check.
Returns:
true if obj is equal to this reference; false otherwise.
Overrides:
equals in class Object
 o hashCode
 public int hashCode()
Computes the hash code of this reference. The hash code is the sum of the hash code of its addresses.

Returns:
A hash code of this reference as an int.
Overrides:
hashCode in class Object
 o toString
 public 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.

Returns:
The non-null string representation of this reference.
Overrides:
toString in class Object
 o clone
 public 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 in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index