SilverStream
Application Server 3.5

com.sssw.srv.busobj
Class AgoBusinessObjectEvent

java.lang.Object
 |
 +--java.util.EventObject
       |
       +--com.sssw.srv.busobj.AgoBusinessObjectEvent
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AgoClusterServerStartEvent, AgoClusterServerStopEvent, AgoHttpErrorEvent, AgoHttpRequestEvent, AgoInvokedEvent, AgoMailEvent, AgoScheduledEvent, AgoServerDeactivatedEvent, AgoServerDeactivatingEvent, AgoServerErrorEvent, AgoServerStartEvent, AgoServerStopEvent, AgoTableEvent, AgoUserLoginEvent, AgoUserLogoutEvent

public class AgoBusinessObjectEvent
extends EventObject

Base class of all business object event objects

See Also:
Serialized Form

Fields inherited from class java.util.EventObject
source
 
Constructor Summary
AgoBusinessObjectEvent()
           
 
Method Summary
 AgaData getAgaData(String name)
          Returns the named AgaData.
 AgiDatabase getDatabase()
          Returns the AgiDatabase object which contains this business object.
 URL getDatabaseURL()
          Returns the URL of the database the business object is in.
 AgiServer getServer()
          Returns an object implementing the AgiServer interface providing access to other parts of the server.
 HttpSession getSession()
          Returns the session of this event.
 String getUser()
          Returns the name of the user associated with the event's session.
 void runAgData(AgiDataRunner r, AgiRowCursor agData)
          Walks through an AgaData calling a method before the rows are processed; a method for each row of the AgaData and a method after all rows have been processed
 void updateTransactionally(AgaData[] dataObjects)
          Updates two or more AgaData objects in a single transaction.
 boolean userInGroup(String groupName)
          Test whether the current user is in the specified group.
 
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

AgoBusinessObjectEvent

public AgoBusinessObjectEvent()
Method Detail

runAgData

public void runAgData(AgiDataRunner r,
                      AgiRowCursor agData)
               throws AgoSecurityException,
                      AgoTransientSystemException,
                      AgoUnrecoverableSystemException
Walks through an AgaData calling a method before the rows are processed; a method for each row of the AgaData and a method after all rows have been processed
Parameters:
r - the AgiDataRunner to be called.
agData - the agData to run.
Usage:

This method is typically used by business objects which were upgraded from version 1.X agents. It merely provides a simple looping mechanism to walk through an AgaData calling a method for each row of data. It is useful when executing the same code over several different AgaDatas. That code can be encapsulated in an object and this method called mulitiple times with different AgaDatas, avoiding the needto write the loop multiple times.

See Also:
AgiDataRunner, AgiRowCursor, AgoSecurityException, AgoTransientSystemException, AgoUnrecoverableSystemException

getUser

public String getUser()
Returns the name of the user associated with the event's session. If the user has not logged into this session, the getUser() method returns "Anonymous".
Example:

This example illustrates how to obtain the current user.

      String user = ControlName1.getUser();
 
See Also:
AgoBusinessObjectEvent.userInGroup(String groupName)

getSession

public HttpSession getSession()
Returns the session of this event. Some events such as InvokedListeners have an implicit session associated, that is, the session of the caller that invoked the business object. Other events such as ServerListeners use the default server session in its place.

In SilverStream 3.0 this method changed to return an HttpSession instead of an AgiSession, to be conformant with the Servlet 2.1 specification.

Usage:

Typically the session is used to store data for the user for the life of the session, using the methods putValue() and getValue() on the Session object.

Example:

An example of incrementing an integer counter stored with the session:

 	HttpSession sess = evt.getSession();
         Integer i = (Integer)sess.getValue("counter");
         int value = i.intValue();
         sess.putValue("counter", new Integer(value+1));
 
See Also:
AgiSession

getServer

public AgiServer getServer()
Returns an object implementing the AgiServer interface providing access to other parts of the server.
Usage:

The AgiServer object is usually used to get a list of databases on the server or access to AgiDatabases objects which allow other business objects to be invoked, servlet URLs to be created and deleted, etc.

Example:
 	AgiServer srv = evt.getServer();
 
See Also:
AgiServer

getDatabase

public AgiDatabase getDatabase()
Returns the AgiDatabase object which contains this business object.
Usage:

This is equivalent to calling evt.getServer().getDatabase("dbName") but doesn't require the name of the database to be hardcoded. As such it is the preferable way of getting the current database. This way the business object will continue to work properly when published to another database.

Example:
         AgiDatabase db = evt.getDatabase();
 

userInGroup

public boolean userInGroup(String groupName)
Test whether the current user is in the specified group.
Parameters:
groupName - name of the group to test inclusion for.
Returns:
true if user is member of the group, false if not.
Example:

This example checks if the user is an administrator.

      boolean admin = evt.userInGroup("Administrators");
      if (admin) {
          // do whatever
      }
 

updateTransactionally

public void updateTransactionally(AgaData[] dataObjects)
                           throws AgoSecurityException,
                                  AgoTransientSystemException,
                                  AgoUnrecoverableSystemException,
                                  AgoInvalidDataException,
                                  AgoMissingDataException,
                                  AgoDataConcurrencyException
Updates two or more AgaData objects in a single transaction. The updates are processed in the order in which they were made. As with any SilverStream transaction, if any operation contained within the transaction cannot complete, then the entire transaction fails.
Parameters:
dataObjects - an array of all the AgaData objects to be updated in the single transaction.
See Also:
AgaData, AgoSecurityException, AgoTransientSystemException, AgoUnrecoverableSystemException, AgoInvalidDataException, AgoMissingDataException, AgoDataConcurrencyException

getDatabaseURL

public URL getDatabaseURL()
Returns the URL of the database the business object is in.
Usage:

Use this URL to build absolute URLs on the fly.


getAgaData

public AgaData getAgaData(String name)
Returns the named AgaData. AgaDatas must be defined and named via the business object designer for this business object.
Parameters:
name - the name of the AgaData to obtain. This must be the same as the name specified in the Property Inspector.
Usage:

It is not necessary to instantiate the AgaData object, but it must be declared. The AgaData must be navigated using the navigation and dataset management methods available through the AgiRowSetManager, and AgiRowCursor interfaces.

Note that this works for all AgaDatas but that Table Listeners principally use AgaRowDatas and have their own methods for getting at them. See the event objects: AgoRowInsertedEvent, AgoRowDeletedEvent, and AgoRowModifiedEvent for details.

Example:

This example from an Invoked business object illustrates how to declare the AgaData called myData. This code would appear in the invoked event.

         AgaData myData=evt.getAgaData("AgaData1");
 
See Also:
AgaData, AgiRowSetManager, AgiRowCursor, AgoRowInsertEvent, AgoRowDeleteEvent, AgoRowModifyEvent

SilverStream
Application Server 3.5