Class ChangeableResource
- java.lang.Object
-
- com.ibm.as400.resource.Resource
-
- com.ibm.as400.resource.ChangeableResource
-
- All Implemented Interfaces:
- java.io.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 ofResource
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(); }If you are extending this class to override the mechanism for getting attribute values, you need to override either
getAttributeUnchangedValue(Object)
orgetAttributeUnchangedValue(Object, int)
, but notgetAttributeValue(Object)
orgetAttributeValue(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 overrideisBidiEnabled()
to return true andgetAttributeUnchangedValue(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[])
orcommitAttributeChanges(Object[], Object[], int[])
, but notcommitAttributeChanges()
,setAttributeValue(Object, Object)
, orsetAttributeValue(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 overrideisBidiEnabled()
to return true andcommitAttributeChanges(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
Constructors Constructor and Description ChangeableResource()
Deprecated.Constructs a ChangeableResource object.ChangeableResource(Presentation presentation, java.lang.Object resourceKey, ResourceMetaData[] attributeMetaData)
Deprecated.Constructs a ChangeableResource object.ChangeableResource(Presentation presentation, java.lang.Object resourceKey, ResourceMetaDataTable attributes)
Deprecated.Constructs a ChangeableResource object.
-
Method Summary
Methods Modifier and Type Method and Description void
cancelAttributeChanges()
Deprecated.Cancels all uncommitted attribute changes.void
commitAttributeChanges()
Deprecated.Commits all attribute changes.protected void
commitAttributeChanges(java.lang.Object[] attributeIDs, java.lang.Object[] values)
Deprecated.Commits the specified attribute changes.protected void
commitAttributeChanges(java.lang.Object[] attributeIDs, java.lang.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(java.lang.Object attributeID, java.lang.Object value)
Deprecated.Fires an attributeValueChanged() ResourceEvent.protected void
fireResourceCreated()
Deprecated.Fires an resourceCreated() ResourceEvent.protected void
fireResourceDeleted()
Deprecated.Fires an resourceDeleted() ResourceEvent.java.lang.Object
getAttributeUnchangedValue(java.lang.Object attributeID)
Deprecated.Returns the value of an attribute, disregarding any uncommitted changes.java.lang.Object
getAttributeUnchangedValue(java.lang.Object attributeID, int bidiStringType)
Deprecated.Returns the value of an attribute, disregarding any uncommitted changes.java.lang.Object
getAttributeValue(java.lang.Object attributeID)
Deprecated.Returns the current value of an attribute.java.lang.Object
getAttributeValue(java.lang.Object attributeID, int bidiStringType)
Deprecated.Returns the current value of an attribute.boolean
hasUncommittedAttributeChanges(java.lang.Object attributeID)
Deprecated.Indicates if an attribute has an uncommitted change.protected void
initializeAttributeValue(java.lang.Object attributeID, java.lang.Object value)
Deprecated.Initializes an attribute value.void
refreshAttributeValues()
Deprecated.Refreshes the values for all attributes.void
setAttributeValue(java.lang.Object attributeID, java.lang.Object value)
Deprecated.Sets the current value of an attribute.void
setAttributeValue(java.lang.Object attributeID, java.lang.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
-
-
-
-
Constructor Detail
-
ChangeableResource
public ChangeableResource()
Deprecated.Constructs a ChangeableResource object.
-
ChangeableResource
public ChangeableResource(Presentation presentation, java.lang.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, java.lang.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(java.lang.Object[] attributeIDs, java.lang.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(java.lang.Object[] attributeIDs, java.lang.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 changesbidiStringTypes
- The bidi string types as defined by the CDRA (Character Data Representataion Architecture). SeeBidiStringType
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(java.lang.Object attributeID, java.lang.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 java.lang.Object getAttributeUnchangedValue(java.lang.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 java.lang.Object getAttributeUnchangedValue(java.lang.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). SeeBidiStringType
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 java.lang.Object getAttributeValue(java.lang.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 classResource
- 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. If the attribute value has an uncommitted change, this returns the changed (uncommitted) value.- Overrides:
getAttributeValue
in classResource
- Parameters:
attributeID
- Identifies the attribute.bidiStringType
- The bidi string type as defined by the CDRA (Character Data Representataion Architecture). SeeBidiStringType
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(java.lang.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(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.- Overrides:
initializeAttributeValue
in classResource
- 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 classResource
- Throws:
ResourceException
- If an error occurs.
-
setAttributeValue
public void setAttributeValue(java.lang.Object attributeID, java.lang.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(java.lang.Object attributeID, java.lang.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). SeeBidiStringType
for more information and valid values.- Throws:
ResourceException
- If an error occurs.
-
-