com.ibm.broker.config.proxy

Class DeploymentDescriptor

  • java.lang.Object
    • com.ibm.broker.config.proxy.DeploymentDescriptor


  • public class DeploymentDescriptor
    extends java.lang.Object

    Represents a deployment descriptor. While a deployment descriptor is not deployable in itself, it is used to override properties of message flows inside a broker archive file.

    To manipulate deployment descriptors programatically, you must first either create one from scratch or load the existing file from the broker archive:

         BarFile b = BarFile.loadBarFile("C:\\MyBars\\test.bar");
         DeploymentDescriptor d = new DeploymentDescriptor();
             // [modify d here]
         b.setDeploymentDescriptor(d);
         b.save();
    or
         BarFile b = BarFile.loadBarFile("C:\\MyBars\\test.bar");
         DeploymentDescriptor d = b.getDeploymentDescriptor();
             // [modify d here]
         b.save();
     

    A number of methods in this class require a property identifier to be supplied. Property identifiers are a way of addressing a specific property that exists within a specific flow inside the Bar file. The format of the property identifier is FLOWNAME#NODENAME.PROPERTYNAME (FLOWNAME#PROPERTYNAME for message flow properties), where the '#' is the value of FLOW_NODE_DELIMITER, and the '.' is the value of NODE_PROPERTY_DELIMITER. However, unless you are creating a deployment descriptor from scratch it is normally possible to discover the available property identifiers using the getPropertyNames() and getOverriddenPropertyNames() methods.

    The active deployment descriptor for a BarFile is always found in the Bar file's META-INF directory as the file 'broker.xml'. Manipulating the deployment descriptor implies manipulating this file. Changes are only persisted to the local filesystem if the BarFile.save() or BarFile.saveAs() is called.

    com.ibm.broker.config.proxy.DeploymentDescriptor

    Responsibilities A representation of a deployment descriptor. Provides the ability to change values in the deployment descriptor
    Internal Collaborators None
    
     Change Activity:
     -------- ----------- -------------   ------------------------------------
     Reason:  Date:       Originator:     Comments:
     -------- ----------- -------------   ------------------------------------
     45166    2007-06-05  HDMPL           v6.1 Release
     51619.8  2008-12-16  HDMPL           v7 Release (no changes)
     80006    2012-04-26  HDCAB           v8 release:                                        
                                             Added DeploymentDescriptor(String fileName) constructor
                                             Added getSourceFilename()
     
     
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String FLOW_NODE_DELIMITER
      The String that separates the flow name from the node name inside property identifiers.
      static java.lang.String NODE_PROPERTY_DELIMITER
      The String that separates the node name from the property name inside property identifiers.
    • Constructor Summary

      Constructors 
      Constructor and Description
      DeploymentDescriptor()
      Instantiates a blank DeploymentDescriptor object with no overridden properties.
      DeploymentDescriptor(java.io.InputStream inputStream)
      Instantiates a new DeploymentDescriptor object that describes the deployment descriptor file with the supplied contents.
      DeploymentDescriptor(java.lang.String fileName)
      Instantiates a new DeploymentDescriptor object that describes the deployment descriptor file from the named fileName.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      java.io.InputStream getContents()
      Returns the deployment descriptor physical format as an InputStream
      org.w3c.dom.Document getDeploymentDescriptorXML()
      Returns the raw XML document that describes the contents of the deployment descriptor.
      java.lang.String getFilename()
      Returns the static name of the deployment descriptor file, as it appears in the Bar file.
      java.util.Enumeration<java.lang.String> getOverriddenPropertyIdentifiers()
      Returns an Enumeration of all the fully-qualified property identifiers that have been overridden in this deployment descriptor.
      java.lang.String getOverride(java.lang.String propertyIdentifier)
      Returns the current value of an override given a fully-qualified property identifier.
      java.util.Enumeration<java.lang.String> getPropertyIdentifiers()
      Returns an Enumeration of all the fully-qualified property identifiers that are described in this deployment descriptor, regardless of whether they have been overridden.
      java.lang.String getSourceFilename()
      Returns the name of the source deployment descriptor file that was used to construct this DeploymentDescriptor.
      int replacePropertyValue(java.lang.String oldPropertyValue, java.lang.String newPropertyValue)
      Sets or removes an override property in the deployment descriptor.
      void setOverride(java.lang.String propertyIdentifier, java.lang.String newPropertyValue)
      Sets or removes an override property in the deployment descriptor.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • FLOW_NODE_DELIMITER

        public static final java.lang.String FLOW_NODE_DELIMITER
        The String that separates the flow name from the node name inside property identifiers.
        See Also:
        Constant Field Values
      • NODE_PROPERTY_DELIMITER

        public static final java.lang.String NODE_PROPERTY_DELIMITER
        The String that separates the node name from the property name inside property identifiers.
        See Also:
        Constant Field Values
    • Constructor Detail

      • DeploymentDescriptor

        public DeploymentDescriptor(java.io.InputStream inputStream)
                             throws org.xml.sax.SAXException,
                                    javax.xml.parsers.ParserConfigurationException,
                                    java.io.IOException
        Instantiates a new DeploymentDescriptor object that describes the deployment descriptor file with the supplied contents.
        Parameters:
        inputStream - Intended contents of the deployment descriptor
        Throws:
        org.xml.sax.SAXException - if the deployment descriptor XML document is invalid
        javax.xml.parsers.ParserConfigurationException - if there is a problem with the XML parser
        java.io.IOException - if the deployment descriptor could not be read
      • DeploymentDescriptor

        public DeploymentDescriptor()
        Instantiates a blank DeploymentDescriptor object with no overridden properties.
      • DeploymentDescriptor

        public DeploymentDescriptor(java.lang.String fileName)
                             throws org.xml.sax.SAXException,
                                    javax.xml.parsers.ParserConfigurationException,
                                    java.io.IOException
        Instantiates a new DeploymentDescriptor object that describes the deployment descriptor file from the named fileName.
        Parameters:
        fileName - the name of the file that contains a deployment descriptor
        Throws:
        org.xml.sax.SAXException - if the deployment descriptor XML document is invalid
        javax.xml.parsers.ParserConfigurationException - if there is a problem with the XML parser
        java.io.IOException - if the deployment descriptor could not be read
    • Method Detail

      • getFilename

        public java.lang.String getFilename()
        Returns the static name of the deployment descriptor file, as it appears in the Bar file.
        Returns:
        String
      • getSourceFilename

        public java.lang.String getSourceFilename()
        Returns the name of the source deployment descriptor file that was used to construct this DeploymentDescriptor. If no source file was used then null is returned.
        Returns:
        String containing the source file name
      • getContents

        public java.io.InputStream getContents()
        Returns the deployment descriptor physical format as an InputStream
        Returns:
        InputStream contents of the deployment descriptor
      • setOverride

        public void setOverride(java.lang.String propertyIdentifier,
                                java.lang.String newPropertyValue)
                         throws java.lang.IllegalArgumentException
        Sets or removes an override property in the deployment descriptor.

        This method will attempt to override a property whose fully-qualified name is the value of propertyIdentifier (e.g. "sampleFlow#MQOutput.queueManagerName"). If the property had not previously been overridden, then a new override is added to the deployment descriptor.

        If the value of newPropertyValue is null, this method removes the first override that is found after following the above algorithm. This means that the property value specified in the message flow definition will be used.

        Changes to the deployment descriptor are not saved to the local filesystem unless BarFile.save() or BarFile.saveAs() is called.

        Parameters:
        propertyIdentifier - The fully-qualified identifier of the property to override
        newPropertyValue - New value to assign to the override.
        Throws:
        java.lang.IllegalArgumentException - if the value of propertyIdentifier was not in the correct format.
      • replacePropertyValue

        public int replacePropertyValue(java.lang.String oldPropertyValue,
                                        java.lang.String newPropertyValue)
        Sets or removes an override property in the deployment descriptor.

        This method will attempt to find any values of the supplied oldPropertyValue parameter as a property value in the deployment descriptor (e.g. "OLD_QUEUE_NAME").

        All occurrences of the old property value will be replaced with the newPropertyValue unless newPropertyValue is null, in which case this method removes any overrides that are found.

        Changes to the deployment descriptor are not saved to the local filesystem unless BarFile.save() or BarFile.saveAs() is called.

        Parameters:
        oldPropertyValue - The old property value to override
        newPropertyValue - New value to assign to the override
        Returns:
        int The number of occurrences that were replaced or removed.
      • getOverride

        public java.lang.String getOverride(java.lang.String propertyIdentifier)
        Returns the current value of an override given a fully-qualified property identifier. If the property whose name has been supplied has not been overridden in the deployment descriptor, null is returned. (This just means that the property has not been overridden; the property may still have been defined in the message flow.)
        Parameters:
        propertyIdentifier - Name of the property whose override value is required
        Returns:
        String value of the overridden property
      • getOverriddenPropertyIdentifiers

        public java.util.Enumeration<java.lang.String> getOverriddenPropertyIdentifiers()
        Returns an Enumeration of all the fully-qualified property identifiers that have been overridden in this deployment descriptor.
        Returns:
        Enumeration Fully qualified property identifiers
      • getPropertyIdentifiers

        public java.util.Enumeration<java.lang.String> getPropertyIdentifiers()
        Returns an Enumeration of all the fully-qualified property identifiers that are described in this deployment descriptor, regardless of whether they have been overridden.

        The number of property identifiers returned by this method depends on the way the the deployment descriptor was generated. Deployment descriptors generated by the Message Broker Toolkit will contain a complete set of overridable properties for each flow in the Bar file. Deployment descriptors created programatically using the empty constructor will not list any overridable properties unless they have been set manually.

        Returns:
        Enumeration of fully qualified property identifer Strings.
      • getDeploymentDescriptorXML

        public org.w3c.dom.Document getDeploymentDescriptorXML()
        Returns the raw XML document that describes the contents of the deployment descriptor. It is not usually necessary to call this method; use the other public methods in this class to manipulate the deployment descriptor more easily.
        Returns:
        Document