com.ibm.as400.resource
Class Resource

java.lang.Object
  extended bycom.ibm.as400.resource.Resource
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ChangeableResource, NetServerConnection, NetServerSession, RQueuedMessage

Deprecated. Use packages com.ibm.as400.access and com.ibm.as400.access.list instead.

public abstract class Resource
extends Object
implements Serializable

The Resource class represents a system resource. This is an abstract class which provides generic access to the resource's attributes. Every attribute is identified using an attribute ID. Any given subclass of Resource will normally document the attribute IDs that it supports.

One example of a concrete subclass of Resource is RUser which represents a system user. RUser supports many attribute IDs, each of which can be used to get attribute values. Here is an example which retrieves an attribute value from an RUser:

// Create an RUser object to refer to a specific user.
AS400 system = new AS400("MYSYSTEM", "MYUSERID", "MYPASSWORD");
RUser user = new RUser(system, "AUSERID");

// Get the text description attribute value. String textDescription = (String)user.getAttributeValue(RUser.TEXT_DESCRIPTION);

In addition to using concrete subclasses directly, you can write generic code to work with any Resource subclass. Such code may improve reusability and maintainability and will work with future Resource subclasses without modification. Every attribute has an associated attribute meta data object which describes various properties of the attribute. The attribute meta data can come in handy when writing generic code. Here is an example of generic code which prints the value of every attribute supported by a Resource:

void printAllAttributeValues(Resource resource) throws ResourceException
{
    // Get the attribute meta data.
    ResourceMetaData[] attributeMetaData = resource.getAttributeMetaData();
    
// Loop through all attributes and print the values. for(int i = 0; i < attributeMetaData.length; ++i) { Object attributeID = attributeMetaData[i].getID(); Object value = resource.getAttributeValue(attributeID); System.out.println("Attribute " + attributeID + " = " + value); } }

Every Resource and attribute meta data object has an associated Presentation object which provides translated information about the Resource or attribute. You can use the Presentation information to present Resources and attributes to end users. This example prints a Resource and attribute using their Presentations:

void printSingleAttributeValue(Resource resource, Object attributeID) throws ResourceException
{
    // Get the presentation for the Resource and print its full name.
    Presentation resourcePresentation = resource.getPresentation();
    System.out.println(resourcePresentation.getFullName());
    
// Get the attribute meta data and the associated Presention. ResourceMetaData attributeMetaData = resource.getAttributeMetaData(attributeID); Presentation attributePresentation = attributeMetaData.getPresentation();
// Get the attribute value and print it. Object value = resource.getAttributeValue(attributeID); System.out.println(attributePresentation.getName() + " = " + value); }

The Resource abstract class only provides read access to the attribute values. ChangeableResource, which is a subclass of Resource, adds methods which provide write access to the attribute values.

Subclass notes:

If you are extending this class to override the mechanism for getting attribute values, consider whether you need to support bidirectional character conversion. If you do not plan to support bidirectional character conversion, then you only need to override getAttributeValue(Object). If you do plan to support bidirectional character conversion, then you need to override isBidiEnabled() to return true and getAttributeValue(Object, int).

In either case, the overriding method should call the superclass's method of the same name and perform extra processing only when null is returned:

    public Object getAttributeValue(Object attributeID)
    throws ResourceException
    {
        // Call the superclass first.
        Object value = super.getAttributeValue(attributeID);
        if (value == null) {

// Establish the connection if needed. if (! isConnectionEstablished()) establishConnection();
// Go get the attribute value. value = ...; } return value; }

See Also:
ResourceList, Serialized Form

Constructor Summary
Resource()
          Deprecated. Constructs a Resource object.
Resource(Presentation presentation, Object resourceKey, ResourceMetaData[] attributeMetaData)
          Deprecated. Constructs a Resource object.
Resource(Presentation presentation, Object resourceKey, ResourceMetaData[] attributeMetaData, Dictionary values)
          Deprecated. Constructs a Resource object.
Resource(Presentation presentation, Object resourceKey, ResourceMetaDataTable attributes)
          Deprecated. Constructs a Resource object.
 
Method Summary
 void addActiveStatusListener(ActiveStatusListener listener)
          Deprecated. Adds an ActiveStatusListener.
 void addPropertyChangeListener(PropertyChangeListener listener)
          Deprecated. Adds a PropertyChangeListener.
 void addResourceListener(ResourceListener listener)
          Deprecated. Adds a ResourceListener.
 void addVetoableChangeListener(VetoableChangeListener listener)
          Deprecated. Adds a VetoableChangeListener.
protected  boolean arePropertiesFrozen()
          Deprecated. Indicates if properties are frozen.
 boolean equals(Object other)
          Deprecated. Indicates if this resource is equal to an object.
protected  void establishConnection()
          Deprecated. Establishes the connection to the system, if any.
protected  void fireAttributeValuesRefreshed()
          Deprecated. Fires an attributeValuesRefreshed() ResourceEvent.
protected  void fireBusy()
          Deprecated. Fires a busy active status event.
protected  void fireIdle()
          Deprecated. Fires a idle active status event.
protected  void firePropertyChange(String propertyName, Object oldValue, Object newValue)
          Deprecated. Fires a property change event.
protected  void fireVetoableChange(String propertyName, Object oldValue, Object newValue)
          Deprecated. Fires a vetoable change event.
protected  void freezeProperties()
          Deprecated. Freezes any property changes.
 ResourceMetaData[] getAttributeMetaData()
          Deprecated. Returns the attribute meta data.
 ResourceMetaData getAttributeMetaData(Object attributeID)
          Deprecated. Returns the attribute meta data for a specific attribute.
 Object getAttributeValue(Object attributeID)
          Deprecated. Returns the current value of an attribute.
 Object getAttributeValue(Object attributeID, int bidiStringType)
          Deprecated. Returns the current value of an attribute.
 Presentation getPresentation()
          Deprecated. Returns the presentation information.
 Object getResourceKey()
          Deprecated. Returns the resource key.
 AS400 getSystem()
          Deprecated. Returns the system.
protected  void initializeAttributeValue(Object attributeID, Object value)
          Deprecated. Initializes an attribute value.
protected  boolean isBidiEnabled()
          Deprecated. Indicates if this resource is enabled for bidirectional character conversion.
protected  boolean isConnectionEstablished()
          Deprecated. Indicates if a connection to the system is established, if any.
 void refreshAttributeValues()
          Deprecated. Refreshes the values for all attributes.
 void removeActiveStatusListener(ActiveStatusListener listener)
          Deprecated. Removes an ActiveStatusListener.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Deprecated. Removes a PropertyChangeListener.
 void removeResourceListener(ResourceListener listener)
          Deprecated. Removes a ResourceListener.
 void removeVetoableChangeListener(VetoableChangeListener listener)
          Deprecated. Removes a VetoableChangeListener.
protected  void setPresentation(Presentation presentation)
          Deprecated. Sets the presentation.
protected  void setResourceKey(Object resourceKey)
          Deprecated. Sets the resource key.
 void setSystem(AS400 system)
          Deprecated. Sets the system.
 String toString()
          Deprecated. Returns the presentation full name, if any.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Resource

public Resource()
Deprecated. 
Constructs a Resource object.


Resource

public Resource(Presentation presentation,
                Object resourceKey,
                ResourceMetaData[] attributeMetaData)
Deprecated. 
Constructs a Resource object.

Parameters:
presentation - The presentation.
resourceKey - The resource key.
attributeMetaData - The attribute meta data, or null if not applicable.

Resource

public Resource(Presentation presentation,
                Object resourceKey,
                ResourceMetaData[] attributeMetaData,
                Dictionary values)
Deprecated. 
Constructs a Resource object.

Parameters:
presentation - The presentation.
resourceKey - The resource key.
attributeMetaData - The attribute meta data, or null if not applicable.
values - The attribute values. The keys are attribute IDs and the elements are attribute values. The attribute IDs and values must be consistent according to the attribute meta data.

Resource

public Resource(Presentation presentation,
                Object resourceKey,
                ResourceMetaDataTable attributes)
Deprecated. 
Constructs a Resource object.

Parameters:
presentation - The presentation.
resourceKey - The resource key, or null if it is not set.
attributes - The attribute meta data.
Method Detail

addActiveStatusListener

public void addActiveStatusListener(ActiveStatusListener listener)
Deprecated. 
Adds an ActiveStatusListener.

Parameters:
listener - The listener.

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Deprecated. 
Adds a PropertyChangeListener. The specified PropertyChangeListener's propertyChange() method will be called each time the value of any bound property is changed.

Parameters:
listener - The listener.

addResourceListener

public void addResourceListener(ResourceListener listener)
Deprecated. 
Adds a ResourceListener.

Parameters:
listener - The listener.

addVetoableChangeListener

public void addVetoableChangeListener(VetoableChangeListener listener)
Deprecated. 
Adds a VetoableChangeListener. The specified VetoableChangeListener's vetoableChange() method will be called each time the value of any constrained property is changed.

Parameters:
listener - The listener.

arePropertiesFrozen

protected boolean arePropertiesFrozen()
Deprecated. 
Indicates if properties are frozen. If this is true, property changes should not be made. Properties are not the same thing as attributes. Properties are basic pieces of information which must be set to make the object usable, such as the system or other properties that identify the resource on the system.

Returns:
true if properties are frozen, false otherwise.

equals

public boolean equals(Object other)
Deprecated. 
Indicates if this resource is equal to an object.

Parameters:
other - The object.
Returns:
true if this resource is equal to the object, false otherwise.

establishConnection

protected void establishConnection()
                            throws ResourceException
Deprecated. 
Establishes the connection to the system, if any. Subclasses can override this method and put all connection initialization code here. It is assumed that all properties have been set when this method is called. Any subclass that overrides this method should include a call to super.establishConnection().

Throws:
ResourceException - If an error occurs.

fireAttributeValuesRefreshed

protected void fireAttributeValuesRefreshed()
Deprecated. 
Fires an attributeValuesRefreshed() ResourceEvent.


fireBusy

protected void fireBusy()
Deprecated. 
Fires a busy active status event. This indicates that a potentially long-running operation has started.


fireIdle

protected void fireIdle()
Deprecated. 
Fires a idle active status event. This indicates that a potentially long-running operation has ended.


firePropertyChange

protected void firePropertyChange(String propertyName,
                                  Object oldValue,
                                  Object newValue)
Deprecated. 
Fires a property change event.

Parameters:
propertyName - The property name.
oldValue - The old value.
newValue - The new value.

fireVetoableChange

protected void fireVetoableChange(String propertyName,
                                  Object oldValue,
                                  Object newValue)
                           throws PropertyVetoException
Deprecated. 
Fires a vetoable change event.

Parameters:
propertyName - The property name.
oldValue - The old value.
newValue - The new value.
Throws:
PropertyVetoException - If the property change is vetoed.

freezeProperties

protected void freezeProperties()
                         throws ResourceException
Deprecated. 
Freezes any property changes. After this is called, property changes should not be made. Properties are not the same thing as attributes. Properties are basic pieces of information which must be set to make the object usable, such as the system or other properties that identify the resource on the system.

Subclasses can override this method and put initialization code here that is dependent on properties being set. Any subclass that overrides this method should include a call to super.freezeProperties().

Throws:
ResourceException - If an error occurs.

getAttributeMetaData

public ResourceMetaData getAttributeMetaData(Object attributeID)
Deprecated. 
Returns the attribute meta data for a specific attribute.

Parameters:
attributeID - Identifies the attribute.
Returns:
The attribute meta data.

getAttributeMetaData

public ResourceMetaData[] getAttributeMetaData()
Deprecated. 
Returns the attribute meta data. The array will contain an element for every supported attribute.

Returns:
The attribute meta data. The array has zero elements if there are no attributes.

getAttributeValue

public Object getAttributeValue(Object attributeID)
                         throws ResourceException
Deprecated. 
Returns the current value of an attribute.

Parameters:
attributeID - Identifies the attribute.
Returns:
The attribute value, or null if the attribute value is not available.
Throws:
ResourceException - If an error occurs.
See Also:
Subclass notes

getAttributeValue

public Object getAttributeValue(Object attributeID,
                                int bidiStringType)
                         throws ResourceException
Deprecated. 
Returns the current value of an attribute.

Parameters:
attributeID - Identifies the attribute.
bidiStringType - The bidi string type as defined by the CDRA (Character Data Representataion Architecture). See BidiStringType for more information and valid values.
Returns:
The attribute value, or null if the attribute value is not available.
Throws:
ResourceException - If an error occurs.
See Also:
Subclass notes

getPresentation

public Presentation getPresentation()
Deprecated. 
Returns the presentation information.

Returns:
The presentation information.

getResourceKey

public Object getResourceKey()
Deprecated. 
Returns the resource key. The resource key uniquely identifies the resource. The resource key may not be set if the resource's properties are not set.

Returns:
The resource key, or null if the resource key has not been set.

getSystem

public AS400 getSystem()
Deprecated. 
Returns the system.

Returns:
The system.

initializeAttributeValue

protected void initializeAttributeValue(Object attributeID,
                                        Object value)
Deprecated. 
Initializes an attribute value. This is intended for use by the subclass when it is initializing attribute values.

Parameters:
attributeID - Identifies the attribute.
value - The attribute value. This cannot be null.

isBidiEnabled

protected boolean isBidiEnabled()
Deprecated. 
Indicates if this resource is enabled for bidirectional character conversion. The default implementation always returns false. Subclasses that are enabled for bidirectional character conversion should override this method to return true.

Returns:
Always false.
See Also:
Subclass notes

isConnectionEstablished

protected boolean isConnectionEstablished()
Deprecated. 
Indicates if a connection to the system is established, if any.

Returns:
true if a connection is established, false otherwise.

refreshAttributeValues

public void refreshAttributeValues()
                            throws ResourceException
Deprecated. 
Refreshes the values for all attributes.

Throws:
ResourceException - If an error occurs.

removeActiveStatusListener

public void removeActiveStatusListener(ActiveStatusListener listener)
Deprecated. 
Removes an ActiveStatusListener.

Parameters:
listener - The listener.

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Deprecated. 
Removes a PropertyChangeListener.

Parameters:
listener - The listener.

removeResourceListener

public void removeResourceListener(ResourceListener listener)
Deprecated. 
Removes a ResourceListener.

Parameters:
listener - The listener.

removeVetoableChangeListener

public void removeVetoableChangeListener(VetoableChangeListener listener)
Deprecated. 
Removes a VetoableChangeListener.

Parameters:
listener - The listener.

setPresentation

protected void setPresentation(Presentation presentation)
Deprecated. 
Sets the presentation.

Parameters:
presentation - The presentation.

setResourceKey

protected void setResourceKey(Object resourceKey)
Deprecated. 
Sets the resource key.

Parameters:
resourceKey - The resource key.

setSystem

public void setSystem(AS400 system)
               throws PropertyVetoException
Deprecated. 
Sets the system. This does not change the job on the system. Instead, it changes the system to which this object references. This cannot be changed if the object has established a connection to the system.

Parameters:
system - The system.
Throws:
PropertyVetoException - If the property change is vetoed.

toString

public String toString()
Deprecated. 
Returns the presentation full name, if any.

Returns:
The presentation full name, if any.