Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Chapter 7 Using the OIG Application Bean : OIG Application Bean

OIG Application Bean
ects2AppBean Class
The Object Integration Gateway application JavaBean, ects2AppBean, is a standalone implementation of all the functions provided by the Gateway EJB base class. You use the Gateway application bean in a non-EJB environment where a standalone application or custom application server has to access the Gateway.
Constructors
 
No-args constructor. Requires that you set session initialization parameters manually.
ects2AppBean(String alias, String sessParms, String mode)
alias - A session pool alias name.
sessParms - Session parameters.
mode - Set to “pooled” for session pooling.
ects2AppBean(String alias, java.util.Hashtable sessParms, String mode)
alias - A session pool alias name.
sessParms - Session parameters.
mode - Set to “pooled” for session pooling.
Methods
 
addSessionParm(String persistKey,
String value)
Adds a persistent data item to the session data collection.
Adds a set of persistent data items to the session data collection.
Close the current TIBCO Object Service Broker session.
Note  A running transaction is rolled back prior to the session being closed.
String getDocument(String docname)
throws ects2AppBeanException
Returns the XML document from the last run method call. The XML document must be of type ROWSET or MSSCHEMA.
String getDocumentFromTable(String
tableName) throws ects2AppBeanException
Returns the named table’s XML document from the message area.
Returns the HTML documents returned from the last Object Integration Gateway interaction.
Returns a persistent data item from the session data collection.
WebRowSet getTable()
throws ects2AppBeanException
Returns a com.ObjectStar.jdbc.rowset.WebRowSet object via the “pass data to client” option of the Object Integration Gateway Transaction definition.
WebRowSet getTable(String docname)
throws ects2AppBeanException
Converts an XML document from the last run method call to a WebRowSet object, and returns the WebRowSet object. The XML document must be of type ROWSET or MSSCHEMA.
WebRowSet getTable(String tableName)
throws ects2AppBeanException
Returns a com.ObjectStar.jdbc.rowset.WebRow
WebRowSet getTableFromDoc(String docname)
throws ects2AppBeanException
Returns a com.ObjectStar.jdbc.rowset.WebRowSet object constructed by parsing an XML document from the current interaction.
Returns a java.util.LinkedList containing the table of contents from the last Object Integration Gateway interaction. The table of contents can be used in diagnostic or recovery code to find out what the interaction returned when unexpected results are encountered.
Returns a boolean indication of whether there is a current session or not.
openApplication()
throws ects2AppBeanException
Opens an unpooled application based on default parameters.
openApplication(boolean pooled)
throws ects2AppBeanException
Opens a pooled or unpooled application based on default parameters.
openApplication(String sessparms, boolean pooled)
throws ects2AppBeanException
Opens a pooled or unpooled application based on default parameters.
openApplication(java.util.Hashtable
sessParms, boolean pooled)
throws ects2AppBeanException
Opens a pooled or unpooled application based on default parameters.
removeSessionParm(String persistKey)
throws ects2AppBeanException
Deletes a persistent data item from the session data collection.
Deletes all persistent data items from the session data collection.
runRule(String ectsRuleName)
throws ects2AppBeanException
Runs a TIBCO Object Service Broker rule. The rule runs within the context of the Object Integration Gateway framework and can programmatically interact with all normal Gateway objects. This method is provided as a way of accomplishing some discreet rules processing within the context of an explicitly started transaction.
runTrans(String transname)
throws ects2AppBeanException
runXMLDoc(String docname)
throws ects2AppBeanException
setDocument(String docname, String document)
throws ects2AppBeanException
Stages one or more XML documents for sending to the Gateway on the next run method call.
setDocument(String docname, WebRowSet wrs)
throws java.sql.SQLException
Stages one or more XML documents for sending to the Gateway on the next run method call.
setDocumentFromFile(String docName,
java.lang.String fileName)
throws ects2AppBeanException
Stores a file-based XML document so that the next interaction sends it to the Gateway for parsing.
setTable(WebRowSet wrs)
throws java.sql.SQLException
Passes the contents of a WebRowSet object to a TIBCO Object Service Broker data table. The method converts the WebRowSet to an XML document so that when the next Gateway object is invoked, the XML document is sent along with any other parameters and loaded into a TIBCO Object Service Broker data table. Since no table name argument is provided, the data table from which the WebRowSet was created is updated.
setTable(WebRowSet wrs, String tablename)
throws java.sql.SQLException
Passes the contents of a WebRowSet object to a TIBCO Object Service Broker data table. The method converts the WebRowSet to an XML document so that when the next Gateway object is invoked, the XML document is sent along with any other parameters and loaded into a TIBCO Object Service Broker data table. Since a table name argument is provided, the specified data table is updated.
Sets user data (name-value pairs) passed with run method calls. Multiple name-value pairs must be separated using commas. A value that contains a space character must be enclosed in single quotation marks.
setUserData(String name, String value)
throws java.rmi.RemoteException
Sets user data (name-value pairs) passed with run method calls. Each call to this method adds a name-value pair to the userdata collection passed on the next interaction. There are no restrictions on the naming of user data; the same name can be used multiple times.
Sets the value of the USERID session initialization parameter.
startTran(boolean update)
throws ects2AppBeanException
Explicitly starts an Object Integration Gateway transaction. When started, a transaction can span multiple interactions of types runRule and runXMLDoc. Data updated as a result of these interactions is committed when the stopTran(true) method is called. The runTrans interaction is always atomic and any updates related to it are committed as part of a nested transaction.
stopTran(boolean commit)
throws ects2AppBeanException
ects2AppBean Code Example
This example illustrates a simple compound transaction. If rules TEST_A and TEST_B update tables, and if these updates are pending, they are committed at the stopTrans statement.
package examples;
import com.Amdahl.Cli.*;
import com.ObjectStar.ects.*;
public class Ex1 implements Runnable {
ects2AppBean appBean = null;
java.util.Hashtable map = new java.util.Hashtable();
/** Creates a new instance of traceback */
public Ex1() {
    }
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Ex1 me = new Ex1();
new java.lang.Thread(me).start();
    }
public void run() {
map.put("HOST","localhost");
map.put("PORT","9068");
map.put("USERID","HURON1");
map.put("PASSWORD","HURON1");
appBean = new ects2AppBean();
try {
// Open a pooled session.
appBean.openApplication(map, true);
//Start an update mode transaction
appBean.startTran(true);
//Run TEST_A but do not commit any updates.
appBean.runRule("TEST_A");
//Run TEST_b but do not commit any updates.
appBean.runRule("TEST_B");
//Stop the transaction and commit the data.
appBean.stopTran(true);
appBean.close();
        }catch(ects2AppBeanException aex){
aex.printStackTrace();
        }finally{
appBean.close();
        }
return ;
    }
}
ects2Result Class
The ects2Result class encapsulates the results of all OIG interactions. All documents and error logs returned as a result of an interaction are stored in the ects2Result. In debug mode persistent session data are also stored.
Inner Class
 
The ects2Result encapsulates the results of all Gateway interactions. All documents and error logs returned as a result of an interaction are stored in the ects2Result. In debug mode, persistent session data are also stored.
Methods
 
getTocEntryFromTable() throws com.ObjectStar.ects.ects2ResultException
Returns the table of contents entry for the first table document from the result area.
getTocEntryFromTable(String tableName) throws com.ObjectStar.ects.ects2ResultException
Returns the table of contents entry for the named table from the result area.
getTocEntryXMLDoc() throws com.ObjectStar.ects.ects2ResultException
Returns the table of contents entry for the first XML document in the result area.
getTocEntryXMLDoc(String docName) throws com.ObjectStar.ects.ects2ResultException
Returns the table of contents entry for the named XML document from the result area.
ects2AppBeanException Class
The ects2AppBeanException class is a specialized exception class for the ects2AppBean class. It provides a convenient way of capturing and retrieving exception messages. Many ects2AppBean methods throw an ects2AppBeanException object when an error is detected.
Constructors
 
A constructor requiring error message text and a cause exception. If the cause exception is an ects2sessionbeanException the logs from that exception are accessible from the getlog and print stack trace methods here.
ects2AppBeanException(com.ObjectStar.ects.ects2sessionbeanException sbex)
A constructor requiring an ects2sessionbeanException cause exception.
Methods
 
Returns the text rules error log for this exception, if one exists, formatted as HTML.
Returns the error log information for this exception, if one exists, formatted as either plain text or HTML based on session or user data containing an “HTMLMSG” indication.
Returns the plain text rules error log for this exception if one exists.
Prints error information to the System.err stream. If there is TIBCO Object Service Broker rules error information available it is printed. If not, a Java stacktrace is printed.
Writes error information to the indicated stream. If there is TIBCO Object Service Broker rules error information available it is written. If not, a Java stacktrace is written.
Writes error information to the indicated writer. If there is TIBCO Object Service Broker rules error information available it is written. If not, a Java stacktrace is written.

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved