SilverStream
Application Server 3.5

com.sssw.srv.busobj
Class AgoDataSourceEvent

java.lang.Object
 |
 +--java.util.EventObject
       |
       +--com.sssw.srv.busobj.AgoBusinessObjectEvent
             |
             +--com.sssw.srv.busobj.AgoInvokedEvent
                   |
                   +--com.sssw.srv.busobj.AgoDataSourceEvent
All Implemented Interfaces:
Serializable

public class AgoDataSourceEvent
extends AgoInvokedEvent

The AgoDataSourceEvent object is passed into the invokeQuery event of a DataSourceListener. In addition to its inherited methods, it adds the ability to set the ResultSet to be returned by the invokeQuery and some utility methods to get a ResultSet by excuting an SQL statement.

See Also:
AgiDataSourceListener, Serialized Form

Fields inherited from class java.util.EventObject
source
 
Constructor Summary
AgoDataSourceEvent()
           
 
Method Summary
 void executeSQL(AgiDatabase db, String s)
          This method is provided for the convenience of Data Source Object designers.
 void executeSQL(String dbname, String s)
          This method is provided for the convenience of Data Source Object designers.
 void setDataSource(AgaData agaData)
          Permits the Data Source Object to return one of its own AgaData's as its data source.
 void setDataSource(AgiDataSource dataSource)
          This is an advanced API, and will be appropriate for specialized applications.
 void setResultSet(ResultSet rs)
          Sets the ResultSet to be returned by the invokeQuery event of a DataSource Object
 void setResultSet(ResultSet rs, AgiDatabase db, Connection c, Statement st)
          Sets the ResultSet to be returned by the invokeQuery event of a DataSource Object
 
Methods inherited from class com.sssw.srv.busobj.AgoInvokedEvent
decodeURLEncodedForm, getParameter, setResult, setResult, setResultMimeType
 
Methods inherited from class com.sssw.srv.busobj.AgoBusinessObjectEvent
getAgaData, getDatabase, getDatabaseURL, getServer, getSession, getUser, runAgData, updateTransactionally, userInGroup
 
Methods inherited from class java.util.EventObject
getSource, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AgoDataSourceEvent

public AgoDataSourceEvent()
Method Detail

setResultSet

public void setResultSet(ResultSet rs)
Sets the ResultSet to be returned by the invokeQuery event of a DataSource Object
Parameters:
rs - the ResultSet to be returned by the event.
Usage:

Use this flavor of the method when generating a ResultSet object without calling JDBC to do it. When JDBC is called to execute a SQL statement (e.g., a prepared Statement or a stored procedure) the other flavor of this method should be used. That method will ensure that the connection and statement are closed after the last row of data is fetched from the ResultSet. Otherwise you cannot determine when that row is fetched and when to close these resources.


setResultSet

public void setResultSet(ResultSet rs,
                         AgiDatabase db,
                         Connection c,
                         Statement st)
Sets the ResultSet to be returned by the invokeQuery event of a DataSource Object
Parameters:
rs - the ResultSet to be returned by the event.
db - the database the ResultSet came from
c - the connection used to get the ResultSet
st - the statement used to get the ResultSet
Usage:

Use this flavor of the method if a JDBC connection to a database was used and a SQL statement called directly to generate a ResultSet to be returned by the invokeQuery event (e.g., calling a prepared statement or a stored procedure). If this method is used, the connection and statement will be closed appropriately after the last row is fetched from the ResultSet.

Example:
     String query = (String)evt.getParameter();
     AgiDatabase db = evt.getDatabase();
     java.sql.Connection conn = db.getConnection(true);
     PreparedStatement stmt = conn.prepareStatement(query);
     ResultSet rs = stmt.executeQuery();
     evt.setResultSet(rs, db, conn, stmt);
     evt.setResult("Success");
 

executeSQL

public void executeSQL(String dbname,
                       String s)
                throws AgoApiException
This method is provided for the convenience of Data Source Object designers. It gives you a way to execute an arbitrary SQL string against the database the business object resides in. It takes care of allocating the connection, preparing and executing the statement, and saving the result set into the event. Note that the statement must not have any unbound parameters.
Parameters:
dbname - the database name.
s - the SQL statement.
Usage:
Call AgoInvokedEvent.setResult() to return a value to the calling program.
See Also:
AgiDataSourceListener.invokeQuery(AgoDataSourceEvent e), AgoInvokedEvent, AgoDataSourceEvent.executeSQL(AgiDatabase db, String s)

executeSQL

public void executeSQL(AgiDatabase db,
                       String s)
                throws AgoApiException
This method is provided for the convenience of Data Source Object designers. It gives you a way to execute an arbitrary SQL string against the database the business object resides in. It takes care of allocating the connection, preparing and executing the statement, and saving the result set into the event. Note that the statement must not have any unbound parameters.
Parameters:
dbname - the database as an AgiDatabase object (which you can get by using evt.getDataBase() as the param.)
s - the SQL statement.
Usage:
Call AgoInvokedEvent.setResult() to return a value to the calling program.
See Also:
AgiDataSourceListener.invokeQuery(AgoDataSourceEvent e), AgoInvokedEvent, AgoDataSourceEvent.executeSQL(String dbname, String s)

setDataSource

public void setDataSource(AgaData agaData)
Permits the Data Source Object to return one of its own AgaData's as its data source. This allows the DSO to be used as a "reusable data set". SilverStream detaches the data source from the AgaData and passes it back to the caller.

setDataSource

public void setDataSource(AgiDataSource dataSource)
This is an advanced API, and will be appropriate for specialized applications. It permits the Data Source Object to return an AgiDataSource directly instead of returning a ResultSet.
Parameters:
dataSource - an AgiDataSource

SilverStream
Application Server 3.5