Interface ImaProperties
Properties are defined for the IBM MessageSight JMS client administered objects which are created using ImaJmsFactory. These administered objects implement the ImaProperties interface. The Connection, Session, MessageConsumer, and MessageProducer objects within the IBM MessageSight JMS client also implement the ImaProperties interface with read only properties using the properties of the objects from which they were created.
In the IBM MessageSight JMS client there are three administered objects:
- ConnectionFactory
- The ConnectionFactory implementation in the IBM MessageSight JMS client implements the three connection factory interfaces: ConnectionFactory, TopicConnectionFactory, and QueueConnectionFactory.
- Queue
- The Queue implementation in the IBM MessageSight JMS client implements two destination interfaces: Destination and Queue.
- Topic
- The Topic implementation in the IBM MessageSight JMS client implements two destination interfaces: Destination and Topic.
To get the properties associated with any IBM MessageSight object, you can cast it to ImaProperties, or use ImaJmsFactory.getProperties(). In either case, you should either check that the object is an instance of ImaProperties, or catch the ClassCastException.
Each administered object has a set of properties and these have a simple validation routine. The validation is not done when the property is set, but when validate() is called. The single property validation methods throw a JMSException which is also an ImaJmsException. The multiple property form of validate returns an array of ImaJmsException objects. The properties are valid when the single property validate() methods do not throw exceptions, or when the multiple property form of validate() returns null.
The names of known properties are processed independent of case and the names are mapped to the preferred case when the property is set.
When a connection is created with a userid and password, the property "userid" is set on the connection object.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final booleanDo not include warning messages in the array of strings returned by validate.static final booleanInclude warning messages in the array of strings returned by validate. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddValidProperty(String name, String validator) Adds a property name to the set of properties to validate.voidclear()Clears all properties.booleanChecks if a property has been set.Returns the value of the specified property as an Object.booleangetBoolean(String name, boolean default_value) Returns the value of the specified property as a boolean.intReturns the value of the specified property as an int.Returns the value of the specified property as a String.Returns the set of properties.Sets a property.voidSets multiple properties.Removes a property.intsize()Gets the number of properties in this object.validate(boolean nowarn) Validates all properties for this object.voidValidates the named property.voidValidates the named property and value.
-
Field Details
-
COPYRIGHT
- See Also:
-
WARNINGS
static final boolean WARNINGSInclude warning messages in the array of strings returned by validate.- See Also:
-
NOWARNINGS
static final boolean NOWARNINGSDo not include warning messages in the array of strings returned by validate. Use this setting to ignore warnings.- See Also:
-
-
Method Details
-
clear
void clear() throws javax.jms.JMSExceptionClears all properties.- Throws:
IllegalStateException- If the properties are read onlyjavax.jms.JMSException
-
exists
Checks if a property has been set.- Parameters:
name- The name of the property- Returns:
- true if the property has been set.
-
get
Returns the value of the specified property as an Object. Any serializable object can be returned as a property value for an administered object- Parameters:
name- The name of the property- Returns:
- The object value of the property, or null if it does not exist.
-
getInt
Returns the value of the specified property as an int. If the property is an enumeration, return the value of the enumeration. If the value is a Boolean, return 0 for false and 1 for true.If the property does not exist or cannot be converted to an integer, return the default_value.
- Parameters:
name- The name of the propertydefault_value- The value to return if the property is missing or not an integer.- Returns:
- The integer value of the property, or default_value if the property does not exist or cannot be converted to an integer.
-
getBoolean
Returns the value of the specified property as a boolean. If the property is an enumeration, if the enumerated value is 0 it is false; all other values are true. If the value is an integer, the value 0 is false; all other values are true.If the property does not exist or cannot be converted to a boolean, return the default_value.
- Parameters:
name- The name of the propertydefault_value- The value to return if the property is missing or not a boolean.- Returns:
- The boolean value of the property, or default_value if the property does not exist or cannot be converted to a boolean.
-
getString
Returns the value of the specified property as a String. All properties can be represented as a string, but for complex objects the string is only a reference to the object.- Parameters:
name- The name of the property- Returns:
- The string value of the property. If the property does not exist, return null.
-
propertySet
Returns the set of properties. This set is a copy of the properties at the time of the call.- Returns:
- A Set containing the property names available
-
put
Sets a property.Very little checking is done at the time of the set. It is strongly recommended that a validate method be run on the property either before or after it is set. Any serializable object can be set as a value.
- Parameters:
name- The name of the propertyvalue- The new value for the property- Returns:
- The previous value of the property, which can be null
- Throws:
javax.jms.JMSException- For an internal error of if the object is not serializableIllegalStateException- If the properties are read-only
-
putAll
Sets multiple properties. Any serializable object can be set as a value.- Parameters:
map- A map of property name to property values.- Throws:
javax.jms.JMSException- If any of the property names or values are not validIllegalStateException- If the properties are read-only
-
remove
Removes a property.- Parameters:
name- The name of the property to remove- Returns:
- The previous value of the property, which can be null
- Throws:
IllegalStateException- If the properties are read-only
-
size
int size()Gets the number of properties in this object.- Returns:
- The number of properties in this object.
-
validate
Validates all properties for this object. If no errors are found, a null String array is returned.This form of validate is able to check that combinations of properties are correct.
- Parameters:
nowarn- Do not include warning messages in the array of messages returned.- Returns:
- A set of ImaJmsException objects indicating the errors found. or null if no errors are found.
-
validate
Validates the named property. The error string consists of a message ID followed by a colon (:) followed by the message text.This form of validate can be used to validate a single property. It is not able to validate any case two or more properties are invalid in combination.
- Parameters:
name- The name of a propertynowarn- Do not include warning messages in the array of messages returned.- Throws:
javax.jms.JMSException- With the error which was found. This JMSException will always an instance of ImaJmsException.
-
validate
Validates the named property and value.The error string consists of a message ID followed by a colon (:) followed by the message text.
This form of validate can be used to validate a property before it is set. It can be used in an administration tool.
- Parameters:
name- The name of a propertyvalue- The value to checknowarn- Do not include warning messages in the array of messages returned.- Throws:
javax.jms.JMSException- With the error which was found. This JMSException will always an instance of ImaJmsException.
-
addValidProperty
Adds a property name to the set of properties to validate. When the properties are validated using one of the validate() methods, it is an error to have an unknown property. This method allows you to make the property known and adds a simple validation rule. When a property name is added as a valid property, it is allowed for all instances of the same base object type.The validation of property names is done in a case independent manner. The name as specified is considered the preferred form.
Added properties are not used by the IBM MessageSight JMS client, but are kept along with the system properties for use by an application.
If the name is already a valid property, this method has no effect.
The validator can be a string which begins with one of the characters:
- B Boolean
- The property must be a boolean, or an integer, or a string which is one of: on, off, true, false, enable, disable, 0, 1.
- I Integer
- The property must be a Number or a String which can be converted to an integer.
- U Unsigned integer
- The property must be a Number or a String which can be converted an integer, and must not be negative.
- S String
- The property may be of any type, since all types can be converted to String.
- Parameters:
name- The name of the property to addvalidator- The string indicating the type of the property- Throws:
IllegalStateException- If the properties are read-only
-