ca.sqlpower.wabit
Interface WabitSessionContext

All Superinterfaces:
OlapConnectionMapping, ca.sqlpower.sqlobject.SQLDatabaseMapping, ca.sqlpower.util.UserPrompterFactory
All Known Subinterfaces:
WabitSwingSessionContext
All Known Implementing Classes:
WabitSessionContextImpl, WabitSwingSessionContextImpl

public interface WabitSessionContext
extends ca.sqlpower.util.UserPrompterFactory, ca.sqlpower.sqlobject.SQLDatabaseMapping, OlapConnectionMapping

A WabitSessionContext provides the basic non-session-specific services that all Wabit code can depend upon. Each live session belongs to exactly one session context, which is where the non-session-specific preferences are stored. The session context manages the lifecycle of the sessions that belong to it.

The session context is also a UserPrompterFactory (as are each of the sessions it owns). The session context should be used as a user prompter factory for alerts and questions that are not directly related to a live session, such as questions and warnings that arise during application startup as well as when in the process of opening a Wabit workspace file.


Nested Class Summary
 
Nested classes/interfaces inherited from interface ca.sqlpower.util.UserPrompterFactory
ca.sqlpower.util.UserPrompterFactory.UserPromptType
 
Field Summary
static java.lang.String DISABLE_QUERY_AUTO_EXECUTE
          A constant for storing the global preference for disabling automatic execution of queries
static java.lang.String NEW_WORKSPACE_URL
           
static java.lang.String WABIT_ENTERPRISE_SERVER_MDNS_TYPE
          The service type to look for when discovering enterprise servers on the local network.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
           
 void addServer(ca.sqlpower.enterprise.client.SPServerInfo serverInfo)
          Adds a new user-configured server specification to this context.
 void addServerListListener(ServerListListener l)
          This listener will be notified when server information is added or removed from the server list.
 java.sql.Connection borrowConnection(ca.sqlpower.sql.JDBCDataSource dataSource)
          Borrows a connection to the given data source from this session's connection pool.
 void close()
          This will attempt to close all of the currently opened sessions and stop the app.
 WabitSession createServerSession(ca.sqlpower.enterprise.client.SPServerInfo serverInfo)
          This will create an appropriate server session for the current context.
 WabitSession createSession()
          This will create an appropriate local session for the current context.
 void endLoading()
          The DAO can tell this context that it's no longer being configured based on a workspace file being loaded.
 WabitSession getActiveSession()
          Returns the session that the user is currently viewing or editing.
 ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource> getDataSources()
           
 java.util.List<ca.sqlpower.enterprise.client.SPServerInfo> getEnterpriseServers(boolean includeDiscoveredServers)
          Returns the list of currently-known enterprise servers.
 javax.jmdns.JmDNS getJmDNS()
          Returns this context's JmDNS client instance.
 java.lang.String getName()
          Returns the name for this session context.
 java.util.prefs.Preferences getPrefs()
          Returns the preferences node used by this session context.
 int getRowLimit()
          Returns the number of rows that should be retrieved from the database for any result set.
 int getSessionCount()
          Returns the number of active sessions in the context.
 java.util.List<WabitSession> getSessions()
          Returns an unmodifiable list of the active sessions in the context.
 boolean isLoading()
          Tells whether or not this session is currently being configured by a DAO.
 boolean isMacOSX()
          returns true if the OS is Mac
 void registerChildSession(WabitSession child)
          Adds the given Wabit session to the list of child sessions for this context.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
           
 void removeServer(ca.sqlpower.enterprise.client.SPServerInfo si)
          Removes a new user-configured server specification from this context.
 void removeServerListListener(ServerListListener l)
          This listener will stop being notified when server information is added or removed from the server list.
 void setActiveSession(WabitSession session)
          Sets the active session that is being viewed or modified.
 void startLoading()
          The DAO can tell this context that it's currently being configured based on a workspace file being loaded.
 
Methods inherited from interface ca.sqlpower.util.UserPrompterFactory
createDatabaseUserPrompter, createUserPrompter
 
Methods inherited from interface ca.sqlpower.sqlobject.SQLDatabaseMapping
getDatabase
 
Methods inherited from interface ca.sqlpower.wabit.OlapConnectionMapping
createConnection
 

Field Detail

WABIT_ENTERPRISE_SERVER_MDNS_TYPE

static final java.lang.String WABIT_ENTERPRISE_SERVER_MDNS_TYPE
The service type to look for when discovering enterprise servers on the local network. This is the fully-qualified name of the service, as in _wabitenterprise._tcp.local..

See Also:
Constant Field Values

DISABLE_QUERY_AUTO_EXECUTE

static final java.lang.String DISABLE_QUERY_AUTO_EXECUTE
A constant for storing the global preference for disabling automatic execution of queries

See Also:
Constant Field Values

NEW_WORKSPACE_URL

static final java.lang.String NEW_WORKSPACE_URL
See Also:
Constant Field Values
Method Detail

getDataSources

ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource> getDataSources()

registerChildSession

void registerChildSession(WabitSession child)
Adds the given Wabit session to the list of child sessions for this context. This is normally done by the sessions themselves, so you shouldn't need to call this method from your own code.

A given session should only be registered with one context at a time. The context a session is registered with should generally be the one returned by the session's getContext() method.

There is no "deregsiter" method to remove a session from its context. Sessions fire a lifecycle event when they close down; the context listens to all its registered sessions and removes its references to them when they send a sessionClosing event.


isMacOSX

boolean isMacOSX()
returns true if the OS is Mac


createSession

WabitSession createSession()
This will create an appropriate local session for the current context. Registering the session with the context should be done immediately or shortly after creating the session.


createServerSession

WabitSession createServerSession(ca.sqlpower.enterprise.client.SPServerInfo serverInfo)
This will create an appropriate server session for the current context. Registering the session with the context should be done immediately or shortly after creating the session.


getSessionCount

int getSessionCount()
Returns the number of active sessions in the context.


getSessions

java.util.List<WabitSession> getSessions()
Returns an unmodifiable list of the active sessions in the context.


getJmDNS

javax.jmdns.JmDNS getJmDNS()
Returns this context's JmDNS client instance.


getEnterpriseServers

java.util.List<ca.sqlpower.enterprise.client.SPServerInfo> getEnterpriseServers(boolean includeDiscoveredServers)
Returns the list of currently-known enterprise servers. This list will change over time, and may be empty for the first few seconds after startup.

Parameters:
includeDiscoveredServers - if true, all known servers will be returned whether they were configured explicitly or discovered dynamically. If false, only the explicitly configured servers will be listed.
Returns:
contact information for the known enterprise servers

addServer

void addServer(ca.sqlpower.enterprise.client.SPServerInfo serverInfo)
Adds a new user-configured server specification to this context. The information will be added to the getEnterpriseServers(boolean) list immediately, and also stored persistently so it will be included in the enterprise server list in future incarnations of WabitSessionContext.

Parameters:
serverInfo - The serverInfo object to add.

removeServer

void removeServer(ca.sqlpower.enterprise.client.SPServerInfo si)
Removes a new user-configured server specification from this context. The information will be removed immediately in the current context, and also from persistent storage.

Parameters:
serverInfo - The serverInfo object to remove. If this does not specify a manually-configured serverInfo (one that was returned by getEnterpriseServers(boolean) with an argument of true), this method will have no effect.

getPrefs

java.util.prefs.Preferences getPrefs()
Returns the preferences node used by this session context. This should not normally be used by client code; it is primarily intended for use by alternative session and session context implementations.


close

void close()
This will attempt to close all of the currently opened sessions and stop the app. Each session will close independently and if any one session does not close successfully then the closing operation will stop. Once all sessions have been properly closed the app will terminate. If not all sessions are properly closed the app will not terminate.


getName

java.lang.String getName()
Returns the name for this session context. If this is server session, then return the server's name, returns "Local" otherwise.


borrowConnection

java.sql.Connection borrowConnection(ca.sqlpower.sql.JDBCDataSource dataSource)
                                     throws ca.sqlpower.sqlobject.SQLObjectException
Borrows a connection to the given data source from this session's connection pool. You must call Connection.close() on the returned object as soon as you are finished with it.

Design note: Equivalent to #getDatabase(SPDataSource) .getConnection(). Normally we discourage adding convenience methods to an interface, and this is indeed a convenience method on an interface. The reason for this method is to reinforce the idea that connections to data sources must be obtained via the SQLDatabase object held in the session.

Parameters:
dataSource - The data source this connection comes from.
Returns:
A connection to the given data source, which has been obtained from a connection pool that this session owns.
Throws:
ca.sqlpower.sqlobject.SQLObjectException - if it is not currently possible to connect to the given data source. This could be due to the remote database being unavailable, or an incorrect username or password, a missing JDBC driver, or many other things.

isLoading

boolean isLoading()
Tells whether or not this session is currently being configured by a DAO. It's not normally necessary to know this from outside the session, but this method had to be public because it's part of the interface.


startLoading

void startLoading()
The DAO can tell this context that it's currently being configured based on a workspace file being loaded. When this is the case, certain things (such as GUI updates) will not be performed. If you're not a DAO, it's not necessary or desirable for you to call this method!


endLoading

void endLoading()
The DAO can tell this context that it's no longer being configured based on a workspace file being loaded. When this is the case, certain things (such as GUI updates) will not be performed. If you're not a DAO, it's not necessary or desirable for you to call this method!


getRowLimit

int getRowLimit()
Returns the number of rows that should be retrieved from the database for any result set.


addServerListListener

void addServerListListener(ServerListListener l)
This listener will be notified when server information is added or removed from the server list.


removeServerListListener

void removeServerListListener(ServerListListener l)
This listener will stop being notified when server information is added or removed from the server list.


setActiveSession

void setActiveSession(WabitSession session)
Sets the active session that is being viewed or modified. Some events that depend on a session will act on the active session.


getActiveSession

WabitSession getActiveSession()
Returns the session that the user is currently viewing or editing.


addPropertyChangeListener

void addPropertyChangeListener(java.beans.PropertyChangeListener l)

removePropertyChangeListener

void removePropertyChangeListener(java.beans.PropertyChangeListener l)


Copyright © 2009. All Rights Reserved.