com.ibm.as400.resource
Class ChangeableResource

java.lang.Object
  extended by com.ibm.as400.resource.Resource
      extended by com.ibm.as400.resource.ChangeableResource
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
NetServer, NetServerShare, RIFSFile, RJavaProgram, RJob, RPrinter, RSoftwareResource, RUser

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

public abstract class ChangeableResource
extends Resource

The ChangeableResource represents a system resource. This is an abstract subclass of Resource which adds the ability to change attribute values of a system resource. Attribute changes are cached internally until they are committed or canceled. This allows you to change many attribute values at once. Every attribute is identified using an attribute ID. Any given subclass of ChangeableResource will normally document the attribute IDs that it supports.

One example of a concrete subclass of ChangeableResource is RJob, which represents a server job. RJob supports many attribute IDs, each of which can be used to access attribute values. Here is an example which sets two attribute values for an RJob:

// Create an RJob object to refer to a specific job.
AS400 system = new AS400("MYSYSTEM", "MYUSERID", "MYPASSWORD");
RJob job = new RJob(system, "AJOBNAME", "AUSERID", "AJOBNUMBER");

// Set the date format attribute value. job.setAttributeValue(RJob.DATE_FORMAT, RJob.DATE_FORMAT_JULIAN);
// Set the country ID attribute value. job.setAttributeValue(RJob.COUNTRY_ID, RJob.USER_PROFILE);
// Commit both attribute changes. job.commitAttributeChanges();

In addition to using concrete subclasses directly, you can write generic code to work with any ChangeableResource subclass. Such code may improve reusability and maintainability and will work with future ChangeableResource subclasses without modification. Every attribute has an associated attribute meta data object which describes various properties of the attribute. These properties include whether or not the attribute is read only and what the default and possible values are. Here is an example of generic code which resets all attributes of a ChangeableResource to their default values:

void resetAttributeValues(ChangeableResource resource) throws ResourceException
{
    // Get the attribute meta data.
    ResourceMetaData[] attributeMetaData = resource.getAttributeMetaData();
    
// Loop through all attributes. for(int i = 0; i < attributeMetaData.length; ++i) { // If the attribute is changeable (not read only), then // reset its value to the default. if (! attributeMetaData[i].isReadOnly()) { Object attributeID = attributeMetaData[i].getID(); Object defaultValue = attributeMetaData[i].getDefaultValue(); resource.setAttributeValue(attributeID, defaultValue); } }
// Commit all of the attribute changes. resource.commitAttributeChanges(); }

Subclass notes:

If you are extending this class to override the mechanism for getting attribute values, you need to override either getAttributeUnchangedValue(Object) or getAttributeUnchangedValue(Object, int), but not getAttributeValue(Object) or getAttributeValue(Object, int). This is because getAttributeValue() will automatically call getAttributeUnchangedValue() only when needed.

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 getAttributeUnchangedValue(Object). If you do plan to support bidirectional character conversion, then you need to override isBidiEnabled() to return true and getAttributeUnchangedValue(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 getAttributeUnchangedValue(Object attributeID)
    throws ResourceException
    {
        // Call the superclass first.
        Object value = super.getAttributeUnchangedValue(attributeID);
        if (value == null) {

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

If you are extending this class to override the mechanism for setting attribute values, you need to override either commitAttributeChanges(Object[], Object[]) or commitAttributeChanges(Object[], Object[], int[]), but not commitAttributeChanges(), setAttributeValue(Object, Object), or setAttributeValue(Object, Object, int).

If you do not plan to support bidirectional character conversion, then you only need to override commitAttributeChanges(Object[], Object[]). If you do plan to support bidirectional character conversion, then you need to override isBidiEnabled() to return true and commitAttributeChanges(Object[], Object[], int[])}.

In either case, the overriding method should call the superclass's method of the same name and then perform extra processing:

    protected void commitAttributeChanges(Object[] attributeIDs, Object[] values)
    throws ResourceException
    {
        // Call the superclass first.
        super.commitAttributeChanges(attributeIDs, values);

// Establish the connection if needed. if (! isConnectionEstablished()) establishConnection();
// Commit the attribute changes. // ... }

See Also:
Serialized Form

Constructor Summary
ChangeableResource()
          Deprecated. Constructs a ChangeableResource object.
ChangeableResource(Presentation presentation, Object resourceKey, ResourceMetaData[] attributeMetaData)
          Deprecated. Constructs a ChangeableResource object.
ChangeableResource(Presentation presentation, Object resourceKey, ResourceMetaDataTable attributes)
          Deprecated. Constructs a ChangeableResource object.
 
Method Summary
 void cancelAttributeChanges()
          Deprecated. Cancels all uncommitted attribute changes.
 void commitAttributeChanges()
          Deprecated. Commits all attribute changes.
protected  void commitAttributeChanges(Object[] attributeIDs, Object[] values)
          Deprecated. Commits the specified attribute changes.
protected  void commitAttributeChanges(Object[] attributeIDs, Object[] values, int[] bidiStringTypes)
          Deprecated. Commits the specified attribute changes.
protected  void fireAttributeChangesCanceled()
          Deprecated. Fires an attributeChangesCanceled() ResourceEvent.
protected  void fireAttributeChangesCommitted()
          Deprecated. Fires an attributeChangesCommitted() ResourceEvent.
protected  void fireAttributeValueChanged(Object attributeID, Object value)
          Deprecated. Fires an attributeValueChanged() ResourceEvent.
protected  void fireResourceCreated()
          Deprecated. Fires an resourceCreated() ResourceEvent.
protected  void fireResourceDeleted()
          Deprecated. Fires an resourceDeleted() ResourceEvent.
 Object getAttributeUnchangedValue(Object attributeID)
          Deprecated. Returns the value of an attribute, disregarding any uncommitted changes.
 Object getAttributeUnchangedValue(Object attributeID, int bidiStringType)
          Deprecated. Returns the value of an attribute, disregarding any uncommitted changes.
 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.
 boolean hasUncommittedAttributeChanges(Object attributeID)
          Deprecated. Indicates if an attribute has an uncommitted change.
protected  void initializeAttributeValue(Object attributeID, Object value)
          Deprecated. Initializes an attribute value.
 void refreshAttributeValues()
          Deprecated. Refreshes the values for all attributes.
 void setAttributeValue(Object attributeID, Object value)
          Deprecated. Sets the current value of an attribute.
 void setAttributeValue(Object attributeID, Object value, int bidiStringType)
          Deprecated. Sets the current value of an attribute.
 
Methods inherited from class com.ibm.as400.resource.Resource
addActiveStatusListener, addPropertyChangeListener, addResourceListener, addVetoableChangeListener, arePropertiesFrozen, equals, establishConnection, fireAttributeValuesRefreshed, fireBusy, fireIdle, firePropertyChange, fireVetoableChange, freezeProperties, getAttributeMetaData, getAttributeMetaData, getPresentation, getResourceKey, getSystem, isBidiEnabled, isConnectionEstablished, removeActiveStatusListener, removePropertyChangeListener, removeResourceListener, removeVetoableChangeListener, setPresentation, setResourceKey, setSystem, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ChangeableResource

public ChangeableResource()
Deprecated. 
Constructs a ChangeableResource object.


ChangeableResource

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

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

ChangeableResource

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

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

cancelAttributeChanges

public void cancelAttributeChanges()
                            throws ResourceException
Deprecated. 
Cancels all uncommitted attribute changes. This method fires an attributeChangesCanceled() ResourceEvent.

Throws:
ResourceException - If an error occurs.

commitAttributeChanges

public void commitAttributeChanges()
                            throws ResourceException
Deprecated. 
Commits all attribute changes. This method fires an attributeChangesCommitted() ResourceEvent.

This method gathers information about which attribute changes need to be committed and calls commitAttributeChanges(Object[], Object[]). Subclasses should override commitAttributeChanges(Object[], Object[]) to define how attribute changes are physically committed.

Throws:
ResourceException - If an error occurs.

commitAttributeChanges

protected void commitAttributeChanges(Object[] attributeIDs,
                                      Object[] values)
                               throws ResourceException
Deprecated. 
Commits the specified attribute changes.

Subclasses should override this method to define how attribute changes are physically committed.

Parameters:
attributeIDs - The attribute IDs for the specified attribute changes.
values - The specified attribute changes
Throws:
ResourceException - If an error occurs.
See Also:
Subclass notes

commitAttributeChanges

protected void commitAttributeChanges(Object[] attributeIDs,
                                      Object[] values,
                                      int[] bidiStringTypes)
                               throws ResourceException
Deprecated. 
Commits the specified attribute changes.

Subclasses should override this method to define how attribute changes are physically committed.

Parameters:
attributeIDs - The attribute IDs for the specified attribute changes.
values - The specified attribute changes
bidiStringTypes - The bidi string types as defined by the CDRA (Character Data Representataion Architecture). See BidiStringType for more information and valid values.
Throws:
ResourceException - If an error occurs.
See Also:
Subclass notes

fireAttributeChangesCanceled

protected void fireAttributeChangesCanceled()
Deprecated. 
Fires an attributeChangesCanceled() ResourceEvent.


fireAttributeChangesCommitted

protected void fireAttributeChangesCommitted()
Deprecated. 
Fires an attributeChangesCommitted() ResourceEvent.


fireAttributeValueChanged

protected void fireAttributeValueChanged(Object attributeID,
                                         Object value)
Deprecated. 
Fires an attributeValueChanged() ResourceEvent.

Parameters:
attributeID - Identifies the attribute.
value - The attribute value.

fireResourceCreated

protected void fireResourceCreated()
Deprecated. 
Fires an resourceCreated() ResourceEvent.


fireResourceDeleted

protected void fireResourceDeleted()
Deprecated. 
Fires an resourceDeleted() ResourceEvent.


getAttributeUnchangedValue

public Object getAttributeUnchangedValue(Object attributeID)
                                  throws ResourceException
Deprecated. 
Returns the value of an attribute, disregarding any uncommitted changes.

Subclasses should override this method to implement how attribute values are physically retrieved.

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

getAttributeUnchangedValue

public Object getAttributeUnchangedValue(Object attributeID,
                                         int bidiStringType)
                                  throws ResourceException
Deprecated. 
Returns the value of an attribute, disregarding any uncommitted changes.

Subclasses should override this method to implement how attribute values are physically retrieved.

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

getAttributeValue

public Object getAttributeValue(Object attributeID)
                         throws ResourceException
Deprecated. 
Returns the current value of an attribute. If the attribute value has an uncommitted change, this returns the changed (uncommitted) value.

Overrides:
getAttributeValue in class Resource
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. If the attribute value has an uncommitted change, this returns the changed (uncommitted) value.

Overrides:
getAttributeValue in class Resource
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

hasUncommittedAttributeChanges

public boolean hasUncommittedAttributeChanges(Object attributeID)
Deprecated. 
Indicates if an attribute has an uncommitted change.

Parameters:
attributeID - Identifies the attribute.
Returns:
true if the attribute has a uncommitted change, false otherwise.

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.

Overrides:
initializeAttributeValue in class Resource
Parameters:
attributeID - Identifies the attribute.
value - The attribute value. This cannot be null.

refreshAttributeValues

public void refreshAttributeValues()
                            throws ResourceException
Deprecated. 
Refreshes the values for all attributes. This does not cancel uncommitted changes. This method fires an attributeValuesRefreshed() ResourceEvent.

Overrides:
refreshAttributeValues in class Resource
Throws:
ResourceException - If an error occurs.

setAttributeValue

public void setAttributeValue(Object attributeID,
                              Object value)
                       throws ResourceException
Deprecated. 
Sets the current value of an attribute. The changed value will be uncommitted until changes are committed. This method fires an attributeValueChanged() ResourceEvent.

Parameters:
attributeID - Identifies the attribute.
value - The attribute value. This cannot be null.
Throws:
ResourceException - If an error occurs.

setAttributeValue

public void setAttributeValue(Object attributeID,
                              Object value,
                              int bidiStringType)
                       throws ResourceException
Deprecated. 
Sets the current value of an attribute. The changed value will be uncommitted until changes are committed. This method fires an attributeValueChanged() ResourceEvent.

Parameters:
attributeID - Identifies the attribute.
value - The attribute value. This cannot be null.
bidiStringType - The bidi string type as defined by the CDRA (Character Data Representataion Architecture). See BidiStringType for more information and valid values.
Throws:
ResourceException - If an error occurs.