com.sun.sgs.app
Interface AppListener


public interface AppListener

Listener for application-level events. This listener is called when the application is started for the first time, and when client sessions log in.

An implementation of a AppListener should implement the Serializable interface, so that application listeners can be stored persistently. When an application is started for the the first time, its initialize method is called and it is then persisted. If a given listener has mutable state that can be changed after this point, it should also implement the ManagedObject interface. An implementation must be public and non-abstract, and have a public, no-argument constructor.

The methods of this listener are called within the context of a Task being executed by the TaskManager. If, during such an execution, a task invokes one of this listener's methods and that method throws an exception, that exception implements ExceptionRetryStatus, and its shouldRetry method returns true, then the TaskManager will make further attempts to retry the task that invoked the listener's method. It will continue those attempts until either an attempt succeeds or it notices an exception is thrown that is not retryable.

For a full description of task execution behavior, see the documentation for TaskManager.scheduleTask(Task).


Method Summary
 void initialize(Properties props)
          Notifies this listener that the application has been started for the first time.
 ClientSessionListener loggedIn(ClientSession session)
          Notifies this listener that the specified client session has logged in, and returns a ClientSessionListener for that session.
 

Method Detail

initialize

void initialize(Properties props)
Notifies this listener that the application has been started for the first time. This gives the application an opportunity to perform any necessary initialization.

Parameters:
props - application-specific configuration properties

loggedIn

ClientSessionListener loggedIn(ClientSession session)
Notifies this listener that the specified client session has logged in, and returns a ClientSessionListener for that session. The returned listener should implement Serializable so that it can be stored persistently. If the returned listener does not implement Serializable, then the client session is disconnected without completing the login process.

The returned ClientSessionListener is notified as follows:

The session passed to this method is persisted in the data manager. The application may remove the session from the data manager in order to disconnect the session. If the application does not remove the specified client session, the client session is removed when the disconnected method invoked on the returned listener completes.

A return value of null has special meaning, indicating that the specified client session should not complete the login process and should be disconnected immediately.

Parameters:
session - a client session
Returns:
a (serializable) listener for the client session, or null to indicate that the session should be terminated without completing the login process.

Project Darkstar, Version 0.9.9.6
2009-05-08 15:39:40

Copyright © 2007-2009 Sun Microsystems, Inc. All rights reserved