com.ibm.broker.plugin

Class MbNode

  • java.lang.Object
    • com.ibm.broker.plugin.MbNode
  • Direct Known Subclasses:
    MbInputNode


    public abstract class MbNode
    extends java.lang.Object
    MbNode provides utility methods allowing a plugin node to interact with the broker. The skeleton code for a plugin node is shown on the MbNodeInterface page.
    See Also:
    MbNodeInterface
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class and Description
      static class  MbNode.JDBC_TransactionType
      Transaction type.
    • Constructor Summary

      Constructors 
      Constructor and Description
      MbNode()
      Default constructor
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      static byte[] base64Decode(java.lang.String base64Text)
      This method decodes a Base64 encoded String to a byte array.
      static java.lang.String base64Encode(byte[] clearText)
      This method encodes a byte array to a Base64 encoded String.
      MbInputTerminal createInputTerminal(java.lang.String name)
      Creates an input terminal on the node with the specified name.
      MbOutputTerminal createOutputTerminal(java.lang.String name)
      Creates an output terminal on the node with the specified name.
      MbSQLStatement createSQLStatement(java.lang.String dataSourceName, java.lang.String statement)
      Creates an MbSQLStatement object described in createSQLStatement The transaction type defaults to MbSQLStatement.SQL_TRANSACTION_AUTO
      MbSQLStatement createSQLStatement(java.lang.String dataSourceName, java.lang.String statement, int transactionType)
      Creates an SQL expression object representing the statement specified by the statement argument, using the syntax as defined for the compute message flow processing node.
      java.util.Vector<MbRoute> getAllRoutes()
      Returns a Vector containing the label nodes associated with this message flow.
      java.lang.String getAttribute(java.lang.String attributeName)
      Gets the value of an attribute on a specific node instance.
      MbBroker getBroker()
      Returns an MbBroker object reflecting the broker state associated with this MbNode.
      MbConfigObject getConfigObject()
      Retrieves the config object for the node, this is created by the initialize() method call.
      MbExecutionGroup getExecutionGroup()
      Returns an MbExecutionGroup object reflecting the broker state associated with this MbNode.
      MbInputTerminal getInputTerminal(java.lang.String terminalName)
      Returns an MbInputTerminal matching the name passed as an argument, or null if the terminal does not exist.
      java.util.Vector<MbInputTerminal> getInputTerminals()
      Returns a Vector containing the input terminals associated with this node.
      java.sql.Connection getJDBCType4Connection(java.lang.String datasourceName, MbNode.JDBC_TransactionType transactionType)
      This method allows this node to obtain a JDBC Type 4 Connection.
      MbMessageFlow getMessageFlow()
      Returns an MbMessageFlow object reflecting the broker state associated with this MbNode.
      java.lang.String getName()
      Returns the name (label) of the node.
      MbOutputTerminal getOutputTerminal(java.lang.String terminalName)
      Returns an MbOutputTerminal matching the name passed as an argument, or null if the terminal does not exist.
      java.util.Vector<MbOutputTerminal> getOutputTerminals()
      Returns a Vector containing the output terminals associated with this node.
      com.ibm.broker.plugin.MbPolicy getPolicy(java.lang.String policyType, java.lang.String policyName)
      This method allows a node to lookup a policy based on the supplied name and type.
      java.lang.String getPolicyName()
      Gets the name of the policy associated with this node
      MbRoute getRoute(java.lang.String labelName)
      Returns an MbRoute object matching the label name passed as an argument, or null if the label does not exist.
      java.lang.Object getUserDefinedAttribute(java.lang.String name)
      Gets the value of a user defined attribute on a specific node instance.
      void onPreSetupValidation()
      onPreSetupValidation() will be called when the message flow is about to be started so that the node can validate its configuration before being setup.
      void onSetup()
      onSetup() will be called when the message flow is about to be started.
      void onStart()
      onStart() will be called when the message flow is starting its threads ready to process messages.
      void onStop(boolean wait)
      onStop() will be called when the message flow is stopping its threads such that no further messages will be processed until it is started again
      void onTearDown()
      onTearDown() will be called when this node is either being updated with a new configuration or is about to be deleted
      void reinitialize(MbConfigObject mco) 
      void setAttribute(java.lang.String attributeName, java.lang.String attributeValue)
      Sets the value of an attribute on a specific node instance.
      java.lang.String toString()
      Returns a String representation of the MbNode.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • MbNode

        public MbNode()
        Default constructor
    • Method Detail

      • createInputTerminal

        public MbInputTerminal createInputTerminal(java.lang.String name)
                                            throws MbException
        Creates an input terminal on the node with the specified name. This must only be called in the node's constructor. Calling this anywhere else will cause MbTerminalCreationException to be thrown.
        Parameters:
        name - The name of the terminal.
        Returns:
        The new input terminal.
        Throws:
        MbException
      • createOutputTerminal

        public MbOutputTerminal createOutputTerminal(java.lang.String name)
                                              throws MbException
        Creates an output terminal on the node with the specified name. This must only be called in the node's constructor. Calling this anywhere else will cause MbTerminalCreationException to be thrown.
        Parameters:
        name - The name of the terminal.
        Returns:
        The new output terminal.
        Throws:
        MbException
      • createSQLStatement

        public MbSQLStatement createSQLStatement(java.lang.String dataSourceName,
                                                 java.lang.String statement)
                                          throws MbException
        Creates an MbSQLStatement object described in createSQLStatement The transaction type defaults to MbSQLStatement.SQL_TRANSACTION_AUTO
        Parameters:
        dataSourceName - The ODBC data source name to be used if the statement references an external database. If no database is to be used then supply an empty string "".
        statement - Specifies the SQL expression to be created, using the syntax defined for the compute message flow processing node.
        Returns:
        The new SQL expression object
        Throws:
        MbException
      • createSQLStatement

        public MbSQLStatement createSQLStatement(java.lang.String dataSourceName,
                                                 java.lang.String statement,
                                                 int transactionType)
                                          throws MbException
        Creates an SQL expression object representing the statement specified by the statement argument, using the syntax as defined for the compute message flow processing node. The MbSQLStatement object returned can be used to execute the statement using its execute or select method. Multiple SQL expression objects can be create in a single message flow processing node. Although these objects can be created at any time, they will be typically created when the node is instantiated, within the node constructor or within an attribute set method if the statement is to be passed in as a node attribute.
        Parameters:
        dataSourceName - The ODBC data source name to be used if the statement references an external database.
        statement - Specifies the SQL expression to be created, using the syntax defined for the compute message flow processing node.
        transactionType - Specifies whether a database commit will be performed after the statement is executed. Valid values are:
        • MbSQLStatement.SQL_TRANSACTION_AUTO
        • MbSQLStatement.SQL_TRANSACTION_COMMIT
        The former value specifies that a database commit will be performed at the completion of the message flow (that is, as a fully globally coordinated or partially globally coordinated transaction). The latter value specifies that a commit will be performed atfer execution of the statement, and within the execute or select method (that is, the message flow is partially broker coordinated).
        Returns:
        The new SQL expression object
        Throws:
        MbException
        See Also:
        "MQSeries Integrator: Using the Control Center"
      • getInputTerminals

        public java.util.Vector<MbInputTerminal> getInputTerminals()
        Returns a Vector containing the input terminals associated with this node.
        Returns:
        Vector containing MbInputTerminal objects.
      • getOutputTerminals

        public java.util.Vector<MbOutputTerminal> getOutputTerminals()
        Returns a Vector containing the output terminals associated with this node.
        Returns:
        Vector containing MbOutputTerminal objects.
      • getInputTerminal

        public MbInputTerminal getInputTerminal(java.lang.String terminalName)
        Returns an MbInputTerminal matching the name passed as an argument, or null if the terminal does not exist.
        Parameters:
        terminalName - The name of the input terminal.
        Returns:
        The MbInputTerminal associcated with the name, or null if one does not exist in this node.
      • getOutputTerminal

        public MbOutputTerminal getOutputTerminal(java.lang.String terminalName)
        Returns an MbOutputTerminal matching the name passed as an argument, or null if the terminal does not exist.
        Parameters:
        terminalName - The name of the output terminal.
        Returns:
        The MbOutputTerminal associcated with the name, or null if one does not exist in this node.
      • getRoute

        public MbRoute getRoute(java.lang.String labelName)
                         throws MbException
        Returns an MbRoute object matching the label name passed as an argument, or null if the label does not exist.
        Parameters:
        labelName - The name of the label property in the Label node.
        Returns:
        The MbRoute associcated with the label name, or null if one does not exist in this message flow.
        Throws:
        MbException
      • getAllRoutes

        public java.util.Vector<MbRoute> getAllRoutes()
                                               throws MbException
        Returns a Vector containing the label nodes associated with this message flow.
        Returns:
        Vector containing MbRoute objects.
        Throws:
        MbException
      • getBroker

        public MbBroker getBroker()
                           throws MbException
        Returns an MbBroker object reflecting the broker state associated with this MbNode.
        Returns:
        The MbBroker object.
        Throws:
        MbException
      • getExecutionGroup

        public MbExecutionGroup getExecutionGroup()
                                           throws MbException
        Returns an MbExecutionGroup object reflecting the broker state associated with this MbNode.
        Returns:
        The MbExecutionGroup object.
        Throws:
        MbException
      • getMessageFlow

        public MbMessageFlow getMessageFlow()
                                     throws MbException
        Returns an MbMessageFlow object reflecting the broker state associated with this MbNode. NOTE: This is cached at the time of the first call.
        Returns:
        The MbMessageFlow object.
        Throws:
        MbException
      • getAttribute

        public java.lang.String getAttribute(java.lang.String attributeName)
                                      throws MbException
        Gets the value of an attribute on a specific node instance. This can be used to get the values of default broker attributes for the node. User attributes should be declared using standard JavaBean property get/set methods as described in MbNodeInterface. This method should not be called in the node constructor.
        Parameters:
        attributeName - The name of the attribute.
        Returns:
        The value associated with the attribute represented as a String.
        Throws:
        MbException
      • setAttribute

        public void setAttribute(java.lang.String attributeName,
                                 java.lang.String attributeValue)
                          throws MbException
        Sets the value of an attribute on a specific node instance. This can be used to set the values of default broker attributes for the node. User attributes should be declared using standard JavaBean property get/set methods as described in MbNodeInterface. This method should not be called in the node constructor.
        Parameters:
        attributeName - The name of the attribute.
        attributeValue - The new value of the attribute.
        Throws:
        MbException
      • getConfigObject

        public MbConfigObject getConfigObject()
        Retrieves the config object for the node, this is created by the initialize() method call.
        Throws:
        MbException
      • toString

        public java.lang.String toString()
        Returns a String representation of the MbNode.
        Overrides:
        toString in class java.lang.Object
        Returns:
        The String representation of the MbNode.
      • onPreSetupValidation

        public void onPreSetupValidation()
                                  throws MbException
        onPreSetupValidation() will be called when the message flow is about to be started so that the node can validate its configuration before being setup.
        Throws:
        MbException
      • onSetup

        public void onSetup()
                     throws MbException
        onSetup() will be called when the message flow is about to be started. This start-up phase can be used to cache any information the node needs to process its messages
        Throws:
        MbException
      • onStart

        public void onStart()
                     throws MbException
        onStart() will be called when the message flow is starting its threads ready to process messages.
        Throws:
        MbException
      • onStop

        public void onStop(boolean wait)
                    throws MbException
        onStop() will be called when the message flow is stopping its threads such that no further messages will be processed until it is started again
        Parameters:
        wait - Indicates if this node should wait for any of its actions to take place
        Throws:
        MbException
      • onTearDown

        public void onTearDown()
                        throws MbException
        onTearDown() will be called when this node is either being updated with a new configuration or is about to be deleted
        Throws:
        MbException
      • getUserDefinedAttribute

        public java.lang.Object getUserDefinedAttribute(java.lang.String name)
        Gets the value of a user defined attribute on a specific node instance.
        Parameters:
        name - The name of the user defined attribute.
        Returns:
        A java object representing the User defined attribute.
      • getPolicyName

        public java.lang.String getPolicyName()
        Gets the name of the policy associated with this node
        Returns:
        The name of the policy, or an empty string of no policy attached
      • getName

        public java.lang.String getName()
        Returns the name (label) of the node. The label is not assigned until the message flow configuration is complete. This method should not be called in the node constructor.
        Returns:
        The name of the node
      • base64Decode

        public static byte[] base64Decode(java.lang.String base64Text)
        This method decodes a Base64 encoded String to a byte array.
        Parameters:
        base64Text - a String to be decoded.
        Returns:
        a byte array that represents the Base64 decoded text.
      • base64Encode

        public static java.lang.String base64Encode(byte[] clearText)
        This method encodes a byte array to a Base64 encoded String.
        Parameters:
        clearText - a byte array to be encoded.
        Returns:
        a String that represents the encoded text.
      • getJDBCType4Connection

        public java.sql.Connection getJDBCType4Connection(java.lang.String datasourceName,
                                                          MbNode.JDBC_TransactionType transactionType)
                                                   throws MbException
        This method allows this node to obtain a JDBC Type 4 Connection. Database changes made using this connection can be globally coordinated by the Message Flow. The node should not explicitly commit or rollback changes using this Connection Object. Also the Connection cannot be shared between message flow instances. The following code snippet is a common idiom:
           ...
           Connection myConn = getJDBCType4Connection(myDB2DatasourceName,MB_TRANSACTION_AUTO);
        
           // Example of using the Connection :
           Statement select = myConn.createStatement;
           Result result = select.executeQuery("SELECT customer_id, tesValue FROM Test);
           ...
           
        Parameters:
        datasourceName - The datasource name that matches a broker JDBC provider service already configured using the command mqsicreateconfigurableservice or any existing service modified using the command mqsichangeproperties.
        transactionType - The transaction coordination level input that determines when changes made against the datasource are committed or rolled back. Currently there is only one permiited value : MB_TRANSACTION_AUTO which inherits the transaction level from the message flow.
        Returns:
        A handle to a java.sql.Connection.
        Throws:
        MbException
      • getPolicy

        public com.ibm.broker.plugin.MbPolicy getPolicy(java.lang.String policyType,
                                                        java.lang.String policyName)
                                                 throws MbException
        This method allows a node to lookup a policy based on the supplied name and type. An MbPolicy object is returned if the policy is found or null if the policy does not exist.
        Parameters:
        policyType - The type of the policy to search for.
        plicyName - The name of the policy to search for.
        Returns:
        A MbPolicy object which represents the policy.
        Throws:
        MbException
IBM Integration BusTM
JavaTM Plugin Node API