Java api reference class

Java api reference class

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.

Field Summary

Contains the name of the factory class for creating an instance of the object to which this Reference refers.

Constructor Summary

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.

Constructs a new reference for an object with class name ‘className’, and the class name and location of the object’s factory.

Method Summary

Makes a copy of this reference using its class name list of addresses, class factory name and class factory location.

Methods inherited from class java.lang.Object

Field Detail

className

addrs

classFactory

Contains the name of the factory class for creating an instance of the object to which this Reference refers. Initialized to null.

classFactoryLocation

Constructor Detail

Reference

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.

Reference

Constructs a new reference for an object with class name ‘className’ and an address. Class factory and class factory location are set to null.

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.

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.

Читайте также:  Ярко серый цвет css

Method Detail

getClassName

getFactoryClassName

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.

get

Retrieves the first address that has the address type ‘addrType’. String.compareTo() is used to test the equality of the address types.

get

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.

size

add

add

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).

remove

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).

clear

equals

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.

hashCode

Computes the hash code of this reference. The hash code is the sum of the hash code of its addresses.

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.

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.

Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2023, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.

Источник

Java api reference class

Abstract base class for reference objects. This class defines the operations common to all reference objects. Because reference objects are implemented in close cooperation with the garbage collector, this class may not be subclassed directly.

Method Summary

Tells whether or not this reference object has been enqueued, either by the program or by the garbage collector.

Ensures that the object referenced by the given reference remains strongly reachable, regardless of any prior actions of the program that might otherwise cause the object to become unreachable; thus, the referenced object is not reclaimable by garbage collection at least until after the invocation of this method.

Читайте также:  Простая php mysql админка

Methods declared in class java.lang.Object

Method Detail

get

Returns this reference object’s referent. If this reference object has been cleared, either by the program or by the garbage collector, then this method returns null .

clear

Clears this reference object. Invoking this method will not cause this object to be enqueued. This method is invoked only by Java code; when the garbage collector clears references it does so directly, without invoking this method.

isEnqueued

public boolean isEnqueued()

Tells whether or not this reference object has been enqueued, either by the program or by the garbage collector. If this reference object was not registered with a queue when it was created, then this method will always return false .

enqueue

Clears this reference object and adds it to the queue with which it is registered, if any. This method is invoked only by Java code; when the garbage collector enqueues references it does so directly, without invoking this method.

clone

protected Object clone() throws CloneNotSupportedException

Throws CloneNotSupportedException . A Reference cannot be meaningfully cloned. Construct a new Reference instead.

reachabilityFence

Ensures that the object referenced by the given reference remains strongly reachable, regardless of any prior actions of the program that might otherwise cause the object to become unreachable; thus, the referenced object is not reclaimable by garbage collection at least until after the invocation of this method. Invocation of this method does not itself initiate garbage collection or finalization. This method establishes an ordering for strong reachability with respect to garbage collection. It controls relations that are otherwise only implicit in a program — the reachability conditions triggering garbage collection. This method is designed for use in uncommon situations of premature finalization where using synchronized blocks or methods, or using other synchronization facilities are not possible or do not provide the desired control. This method is applicable only when reclamation may have visible effects, which is possible for objects with finalizers (See Section 12.6 17 of The Java™ Language Specification ) that are implemented in ways that rely on ordering control for correctness.

API Note: Finalization may occur whenever the virtual machine detects that no reference to an object will ever be stored in the heap: The garbage collector may reclaim an object even if the fields of that object are still in use, so long as the object has otherwise become unreachable. This may have surprising and undesirable effects in cases such as the following example in which the bookkeeping associated with a class is managed through array indices. Here, method action uses a reachabilityFence to ensure that the Resource object is not reclaimed before bookkeeping on an associated ExternalResource has been performed; in particular here, to ensure that the array slot holding the ExternalResource is not nulled out in method Object.finalize() , which may otherwise run concurrently.

 class Resource < private static ExternalResource[] externalResourceArray = . int myIndex; Resource(. ) < myIndex = . externalResourceArray[myIndex] = . ; . >protected void finalize() < externalResourceArray[myIndex] = null; . >public void action() < try < // . int i = myIndex; Resource.update(externalResourceArray[i]); >finally < Reference.reachabilityFence(this); >> private static void update(ExternalResource ext) < ext.status = . ; >>

Here, the invocation of reachabilityFence is nonintuitively placed after the call to update , to ensure that the array slot is not nulled out by Object.finalize() before the update, even if the call to action was the last use of this object. This might be the case if, for example a usage in a user program had the form new Resource().action(); which retains no other reference to this Resource . While probably overkill here, reachabilityFence is placed in a finally block to ensure that it is invoked across all paths in the method. In a method with more complex control paths, you might need further precautions to ensure that reachabilityFence is encountered along all of them. It is sometimes possible to better encapsulate use of reachabilityFence . Continuing the above example, if it were acceptable for the call to method update to proceed even if the finalizer had already executed (nulling out slot), then you could localize use of reachabilityFence :

 public void action2() < // . Resource.update(getExternalResource()); >private ExternalResource getExternalResource()

Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2023, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.

Читайте также:  Javascript event click element

Источник

Class Reference

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.

Источник

Оцените статью