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.
      MbODMServer getODMServer(java.lang.String policyName)
      This method allows this node to obtain a connection to an ODM server which can be used for executing ODM rulesets.
      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.
      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 onInitialize(MbConfigObject resourceConfiguration)
      onInitialize() will be called when the message flow is initializing.
      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 This method should be overriden by any derived classes which want to perform logic during the 'initialize' phase.
      void onTearDown()
      onTearDown() will be called when this node is either being updated with a new configuration or is about to be deleted This method should be overriden by any derived classes which want to perform logic during the 'initialize' phase.
      void onTerminate()
      onTerminate() will be called when this node is about to be deleted This method should be overriden by any derived classes which want to perform logic during the 'initialize' phase.
      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 - If an exception occurred.
      • 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 - If an exception occurred.
      • 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 - If an exception occurred.
      • 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 - If an exception occurred.
        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 - If an exception occurred.
      • 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 - If an exception occurred.
      • getBroker

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

        public MbExecutionGroup getExecutionGroup()
                                           throws MbException
        Returns an MbExecutionGroup object reflecting the broker state associated with this MbNode.
        Returns:
        The MbExecutionGroup object.
        Throws:
        MbException - If an exception occurred.
      • 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 - If an exception occurred.
      • 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 - If an exception occurred.
      • 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 - If an exception occurred.
      • getConfigObject

        public MbConfigObject getConfigObject()
        Retrieves the config object for the node, this is created by the initialize() method call.
        Returns:
        The ConfigObject belonging to the node.
      • 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.
      • onInitialize

        public void onInitialize(MbConfigObject resourceConfiguration)
                          throws MbException
        onInitialize() will be called when the message flow is initializing. This method should be overriden by any derived classes which want to perform logic during the 'initialize' phase.
        Parameters:
        resourceConfiguration - The ConfigObject representing the node's configuration.
        Throws:
        MbException - If an exception occurred.
      • 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. This method should be overriden by any derived classes which want to perform logic during the 'initialize' phase.
        Throws:
        MbException - If an exception occurred.
      • 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 This method should be overriden by any derived classes which want to perform logic during the 'initialize' phase.
        Throws:
        MbException - If an exception occurred.
      • onStart

        public void onStart()
                     throws MbException
        onStart() will be called when the message flow is starting its threads ready to process messages. This method should be overriden by any derived classes which want to perform logic during the 'initialize' phase.
        Throws:
        MbException - If an exception occurred.
      • 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 This method should be overriden by any derived classes which want to perform logic during the 'initialize' phase.
        Parameters:
        wait - Indicates if this node should wait for any of its actions to take place
        Throws:
        MbException - If an exception occurred.
      • 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 This method should be overriden by any derived classes which want to perform logic during the 'initialize' phase.
        Throws:
        MbException - If an exception occurred.
      • onTerminate

        public void onTerminate()
                         throws MbException
        onTerminate() will be called when this node is about to be deleted This method should be overriden by any derived classes which want to perform logic during the 'initialize' phase.
        Throws:
        MbException - If an exception occurred.
      • 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 if 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 if the JDBC policy "jdbcProviderXASupport" property is set to true, if the "maxConnectionPoolSize" property is greater than zero, or when the flow is using coordinated transactions.

        The Connection object also 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;
           ResultSet 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 - If an exception occurred.
      • getPolicy

        public 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.
        policyName - The name of the policy to search for.
        Returns:
        A MbPolicy object which represents the policy.
        Throws:
        MbException - If an exception occurred.
      • getODMServer

        public MbODMServer getODMServer(java.lang.String policyName)
                                 throws MbException
        This method allows this node to obtain a connection to an ODM server which can be used for executing ODM rulesets.

        This method can only be called in an MbNode's onSetup method; attempting to call it at any other time will result in an exception. The MbODMServer object which is returned should not be shared between nodes or across re-deploys of the same node.

        The following code snippet is a common idiom:
        
           ...
           // Example of using an MbODMServer
           // -------------------------------
           
           // Obtain an MbODMServer connection   
           MbODMServer myODMServer = getODMServer("{DefaultPolicies}:myODMServerPolicy");
           
           // Obtain a rule to execute
           MbODMRuleset myRuleset = myODMServer.getRuleset("/RuleAppName/1.0/rulesetName/1.2");
           
           // Build the rule input parameters
           Map<String,Object> inputParameters = new HashMap<String,Object>();
           ...
           
           // Execute the rule
           MbODMRulesetExecutionResponse myRulesetResponse = myRuleset.execute(inputParameters);
           
           // Process the output parameters
           Map<String,Object> responseParameters = myRulesetResponse.getOutputParameters();
           ...
           
        Parameters:
        policyName - The name of the ODMServer policy to use to load the connection details for the ODM server.
        Returns:
        A handle to a com.ibm.broker.plugin.MbODMServer connection.
        Throws:
        MbException - If an exception occurred
IBM Integration BusTM
JavaTM Plugin Node API