|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectca.sqlpower.wabit.WabitSessionContextImpl
public class WabitSessionContextImpl
This is the canonical headless implementation of WabitSessionContext interface. Other session context implementations that cover more specialized use cases can either extend this one or delegate certain operations to it.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface ca.sqlpower.util.UserPrompterFactory |
|---|
ca.sqlpower.util.UserPrompterFactory.UserPromptType |
| Field Summary | |
|---|---|
protected java.util.List<WabitSession> |
childSessions
|
protected javax.jmdns.JmDNS |
jmdns
|
protected java.util.prefs.Preferences |
prefs
This prefs node stores context specific prefs. |
static java.lang.String |
PREFS_PL_INI_PATH
This is a preference that stores the location of the pl.ini. |
protected boolean |
terminateWhenLastSessionCloses
If this flag is true, this session context will halt the VM when its last session closes. |
| Fields inherited from interface ca.sqlpower.wabit.WabitSessionContext |
|---|
DISABLE_QUERY_AUTO_EXECUTE, NEW_WORKSPACE_URL, WABIT_ENTERPRISE_SERVER_MDNS_TYPE |
| Constructor Summary | |
|---|---|
WabitSessionContextImpl(boolean terminateWhenLastSessionCloses,
boolean useJmDNS,
ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource> initialCollection,
java.lang.String dataSourceCollectionPath,
boolean writeDSCollectionPathToPrefs)
Creates a new Wabit session context. |
|
| Method Summary | |
|---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener l)
|
void |
addServer(WabitServerInfo 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. |
org.olap4j.OlapConnection |
createConnection(ca.sqlpower.sql.Olap4jDataSource dataSource)
This method returns an OlapConnection that has been mapped to an
Olap4jDataSource. |
ca.sqlpower.util.UserPrompter |
createDatabaseUserPrompter(java.lang.String question,
java.util.List<java.lang.Class<? extends ca.sqlpower.sql.SPDataSource>> dsTypes,
ca.sqlpower.util.UserPrompter.UserPromptOptions optionType,
ca.sqlpower.util.UserPrompter.UserPromptResponse defaultResponseType,
java.lang.Object defaultResponse,
ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource> dsCollection,
java.lang.String... buttonNames)
|
WabitSession |
createServerSession(WabitServerInfo 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. |
ca.sqlpower.util.UserPrompter |
createUserPrompter(java.lang.String question,
ca.sqlpower.util.UserPrompterFactory.UserPromptType responseType,
ca.sqlpower.util.UserPrompter.UserPromptOptions optionType,
ca.sqlpower.util.UserPrompter.UserPromptResponse defaultResponseType,
java.lang.Object defaultResponse,
java.lang.String... buttonNames)
Returns a user prompter that always gives the default response, since this is a headless session context and there is no user to ask. |
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.sqlobject.SQLDatabase |
getDatabase(ca.sqlpower.sql.JDBCDataSource dataSource)
|
ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource> |
getDataSources()
Tries to read the plDotIni if it hasn't been done already. |
java.util.List<WabitServerInfo> |
getEnterpriseServers(boolean includeDiscovered)
Returns the list of currently-known enterprise servers. |
javax.jmdns.JmDNS |
getJmDNS()
Returns the JmDNS instance in this session context. |
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(WabitServerInfo serverInfo)
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 activeSession)
Sets the active session that is being viewed or modified. |
protected void |
setPlDotIniPath(java.lang.String plDotIniPath)
|
void |
startLoading()
The DAO can tell this context that it's currently being configured based on a workspace file being loaded. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String PREFS_PL_INI_PATH
protected javax.jmdns.JmDNS jmdns
protected final java.util.List<WabitSession> childSessions
protected boolean terminateWhenLastSessionCloses
protected final java.util.prefs.Preferences prefs
| Constructor Detail |
|---|
public WabitSessionContextImpl(boolean terminateWhenLastSessionCloses,
boolean useJmDNS,
ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource> initialCollection,
java.lang.String dataSourceCollectionPath,
boolean writeDSCollectionPathToPrefs)
throws java.io.IOException,
ca.sqlpower.sqlobject.SQLObjectException
terminateWhenLastSessionCloses - If this flag is true, this session context will halt the VM
when its last session closes.useJmDNS - If this flag is true, then this session will create a JmDNS
instance for searching for Wabit servers.initialCollection - The default collection of data sources for this context.dataSourceCollectionPath - The path to the file representing the data source collection.
This will be used to write changes to the collection to save
the collection's state. If this is null then no data source
collection files will be modified.writeDSCollectionPathToPrefs - If true the location of the data source collection file will
be saved to Java Prefs. If false the current location of the
data source collection file will be left as is.
java.io.IOException - If the startup configuration files can't be read
ca.sqlpower.sqlobject.SQLObjectException - If the pl.ini is invalid.| Method Detail |
|---|
public void registerChildSession(WabitSession child)
registerChildSession in interface WabitSessionContextpublic ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource> getDataSources()
#plDotIni.
getDataSources in interface WabitSessionContextpublic boolean isMacOSX()
isMacOSX in interface WabitSessionContextpublic WabitSession createSession()
WabitSessionContext
createSession in interface WabitSessionContextprotected void setPlDotIniPath(java.lang.String plDotIniPath)
public int getSessionCount()
WabitSessionContext
getSessionCount in interface WabitSessionContextpublic void close()
WabitSessionContext
close in interface WabitSessionContextpublic javax.jmdns.JmDNS getJmDNS()
getJmDNS in interface WabitSessionContextpublic java.util.List<WabitServerInfo> getEnterpriseServers(boolean includeDiscovered)
WabitSessionContext
getEnterpriseServers in interface WabitSessionContextincludeDiscovered - 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.
public void addServer(WabitServerInfo serverInfo)
WabitSessionContextWabitSessionContext.getEnterpriseServers(boolean)
list immediately, and also stored persistently so it will be included in
the enterprise server list in future incarnations of WabitSessionContext.
addServer in interface WabitSessionContextserverInfo - The serverInfo object to add.public void removeServer(WabitServerInfo serverInfo)
WabitSessionContext
removeServer in interface WabitSessionContextpublic void addServerListListener(ServerListListener l)
WabitSessionContext
addServerListListener in interface WabitSessionContextpublic void removeServerListListener(ServerListListener l)
WabitSessionContext
removeServerListListener in interface WabitSessionContextpublic java.util.prefs.Preferences getPrefs()
getPrefs in interface WabitSessionContextpublic java.lang.String getName()
WabitSessionContext
getName in interface WabitSessionContext
public ca.sqlpower.util.UserPrompter createUserPrompter(java.lang.String question,
ca.sqlpower.util.UserPrompterFactory.UserPromptType responseType,
ca.sqlpower.util.UserPrompter.UserPromptOptions optionType,
ca.sqlpower.util.UserPrompter.UserPromptResponse defaultResponseType,
java.lang.Object defaultResponse,
java.lang.String... buttonNames)
createUserPrompter in interface ca.sqlpower.util.UserPrompterFactorypublic java.util.List<WabitSession> getSessions()
WabitSessionContext
getSessions in interface WabitSessionContext
public java.sql.Connection borrowConnection(ca.sqlpower.sql.JDBCDataSource dataSource)
throws ca.sqlpower.sqlobject.SQLObjectException
WabitSessionContextConnection.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.
borrowConnection in interface WabitSessionContextdataSource - The data source this connection comes from.
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.public int getRowLimit()
WabitSessionContext
getRowLimit in interface WabitSessionContextpublic boolean isLoading()
WabitSessionContext
isLoading in interface WabitSessionContextpublic void startLoading()
WabitSessionContext
startLoading in interface WabitSessionContextpublic void endLoading()
WabitSessionContext
endLoading in interface WabitSessionContextpublic ca.sqlpower.sqlobject.SQLDatabase getDatabase(ca.sqlpower.sql.JDBCDataSource dataSource)
getDatabase in interface ca.sqlpower.sqlobject.SQLDatabaseMapping
public org.olap4j.OlapConnection createConnection(ca.sqlpower.sql.Olap4jDataSource dataSource)
throws java.sql.SQLException,
java.lang.ClassNotFoundException,
javax.naming.NamingException
OlapConnectionMappingOlapConnection that has been mapped to an
Olap4jDataSource. This connection should not be closed as other
objects may be using it to access the data source.
createConnection in interface OlapConnectionMappingjava.sql.SQLException
java.lang.ClassNotFoundException
javax.naming.NamingException
public ca.sqlpower.util.UserPrompter createDatabaseUserPrompter(java.lang.String question,
java.util.List<java.lang.Class<? extends ca.sqlpower.sql.SPDataSource>> dsTypes,
ca.sqlpower.util.UserPrompter.UserPromptOptions optionType,
ca.sqlpower.util.UserPrompter.UserPromptResponse defaultResponseType,
java.lang.Object defaultResponse,
ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource> dsCollection,
java.lang.String... buttonNames)
createDatabaseUserPrompter in interface ca.sqlpower.util.UserPrompterFactorypublic WabitSession getActiveSession()
WabitSessionContext
getActiveSession in interface WabitSessionContextpublic void setActiveSession(WabitSession activeSession)
WabitSessionContext
setActiveSession in interface WabitSessionContextpublic void addPropertyChangeListener(java.beans.PropertyChangeListener l)
addPropertyChangeListener in interface WabitSessionContextpublic void removePropertyChangeListener(java.beans.PropertyChangeListener l)
removePropertyChangeListener in interface WabitSessionContextpublic WabitSession createServerSession(WabitServerInfo serverInfo)
WabitSessionContext
createServerSession in interface WabitSessionContext
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||