com.ibm.as400.resource

Class Resource

  • java.lang.Object
    • com.ibm.as400.resource.Resource
  • All Implemented Interfaces:
    java.io.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 java.lang.Object
    implements java.io.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 Detail

      • Resource

        public Resource()
        Deprecated. 
        Constructs a Resource object.
      • Resource

        public Resource(Presentation presentation,
                java.lang.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,
                java.lang.Object resourceKey,
                ResourceMetaData[] attributeMetaData,
                java.util.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,
                java.lang.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(java.beans.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(java.beans.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(java.lang.Object other)
        Deprecated. 
        Indicates if this resource is equal to an object.
        Overrides:
        equals in class java.lang.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(java.lang.String propertyName,
                              java.lang.Object oldValue,
                              java.lang.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(java.lang.String propertyName,
                              java.lang.Object oldValue,
                              java.lang.Object newValue)
                                   throws java.beans.PropertyVetoException
        Deprecated. 
        Fires a vetoable change event.
        Parameters:
        propertyName - The property name.
        oldValue - The old value.
        newValue - The new value.
        Throws:
        java.beans.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(java.lang.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 java.lang.Object getAttributeValue(java.lang.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 java.lang.Object getAttributeValue(java.lang.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 Representation 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 java.lang.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(java.lang.Object attributeID,
                                    java.lang.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(java.beans.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(java.beans.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(java.lang.Object resourceKey)
        Deprecated. 
        Sets the resource key.
        Parameters:
        resourceKey - The resource key.
      • setSystem

        public void setSystem(AS400 system)
                       throws java.beans.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:
        java.beans.PropertyVetoException - If the property change is vetoed.
      • toString

        public java.lang.String toString()
        Deprecated. 
        Returns the presentation full name, if any.
        Overrides:
        toString in class java.lang.Object
        Returns:
        The presentation full name, if any.