org.h2.server.web
Class WebApp

java.lang.Object
  extended by org.h2.server.web.WebApp
All Implemented Interfaces:
java.util.EventListener, DatabaseEventListener

public class WebApp
extends java.lang.Object
implements DatabaseEventListener

For each connection to a session, an object of this class is created. This class is used by the H2 Console.


Field Summary
protected  java.util.Properties attributes
           
protected  boolean cache
           
protected  java.lang.String headerLanguage
           
protected  long listenerLastEvent
           
protected  int listenerLastState
           
protected  java.lang.String mimeType
           
protected  WebServer server
           
protected  org.h2.server.web.WebSession session
           
protected  boolean stop
           
 
Fields inherited from interface org.h2.api.DatabaseEventListener
STATE_BACKUP_FILE, STATE_CREATE_INDEX, STATE_RECONNECTED, STATE_RECOVER, STATE_SCAN_FILE
 
Method Summary
protected  java.lang.String adminShutdown()
          Stop the application and the server.
 void closingDatabase()
          This method is called before the database is closed normally.
 void diskSpaceIsLow(long stillAvailable)
          This method is called if the disk space is very low.
 void exceptionThrown(java.sql.SQLException e, java.lang.String sql)
          This method is called if an exception occurred.
 void init(java.lang.String url)
          This method is called just after creating the object.
protected  boolean loginAsync(java.lang.String driver, java.lang.String url, java.lang.String user, java.lang.String password)
          Login in a separate thread if possible.
 void opened()
          This method is called after the database has been opened.
 void setProgress(int state, java.lang.String name, int x, int max)
          This method is called for long running events, such as recovering, scanning a file or building an index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

server

protected WebServer server

session

protected org.h2.server.web.WebSession session

attributes

protected java.util.Properties attributes

mimeType

protected java.lang.String mimeType

listenerLastEvent

protected long listenerLastEvent

listenerLastState

protected int listenerLastState

cache

protected boolean cache

stop

protected boolean stop

headerLanguage

protected java.lang.String headerLanguage
Method Detail

adminShutdown

protected java.lang.String adminShutdown()
Stop the application and the server.

Returns:
the page to display

loginAsync

protected boolean loginAsync(java.lang.String driver,
                             java.lang.String url,
                             java.lang.String user,
                             java.lang.String password)
Login in a separate thread if possible.

Parameters:
driver - the driver class
url - the database URL
user - the user name
password - the password
Returns:
false if asynchronous login is not possible

closingDatabase

public void closingDatabase()
Description copied from interface: DatabaseEventListener
This method is called before the database is closed normally. It is save to connect to the database and execute statements at this point, however the connection must be closed before the method returns.

Specified by:
closingDatabase in interface DatabaseEventListener

diskSpaceIsLow

public void diskSpaceIsLow(long stillAvailable)
Description copied from interface: DatabaseEventListener
This method is called if the disk space is very low. One strategy is to inform the user and wait for it to clean up disk space. Another strategy is to send an email to the administrator in this method and then throw a SQLException. The database should not be accessed from within this method (even to close it).

Specified by:
diskSpaceIsLow in interface DatabaseEventListener
Parameters:
stillAvailable - the estimated space that is still available, in bytes (if known)

exceptionThrown

public void exceptionThrown(java.sql.SQLException e,
                            java.lang.String sql)
Description copied from interface: DatabaseEventListener
This method is called if an exception occurred.

Specified by:
exceptionThrown in interface DatabaseEventListener
Parameters:
e - the exception
sql - the SQL statement

init

public void init(java.lang.String url)
Description copied from interface: DatabaseEventListener
This method is called just after creating the object. This is done when opening the database if the listener is specified in the database URL, but may be later if the listener is set at runtime with the SET SQL statement.

Specified by:
init in interface DatabaseEventListener
Parameters:
url - - the database URL

opened

public void opened()
Description copied from interface: DatabaseEventListener
This method is called after the database has been opened. It is save to connect to the database and execute statements at this point.

Specified by:
opened in interface DatabaseEventListener

setProgress

public void setProgress(int state,
                        java.lang.String name,
                        int x,
                        int max)
Description copied from interface: DatabaseEventListener
This method is called for long running events, such as recovering, scanning a file or building an index.

Specified by:
setProgress in interface DatabaseEventListener
Parameters:
state - the state
name - the object name
x - the current position
max - the highest value