|
SPT RWT Application API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sptci.rwt.Connections
public class Connections
A serializable wrapper used to represent saved JDBC connections for the application. This class will be serialised to the following file and initialised from the same file during application load:
<sptrwt.data.directory>/connections.xml
© Copyright 2007 Sans Pareil Technologies, Inc.
| Field Summary | |
|---|---|
private TreeMap<String,DatabaseType> |
databases
A map used to quickly look up DatabaseType instances by their
DatabaseType.name. |
static String |
DIRECTORY
The system property used to configure the location of the root directory under which persistent state information for the application is stored. |
static String |
ENCODING
The encoding to use to serialise and deserialise instances of this class. |
static String |
FILE_NAME
The name of the file to which this class will be serialised. |
private String |
fileName
The fully qualified file name to use to serialise this instance into. |
protected static XStream |
xstream
The XStream instance used to serialise
and deserialise instances of this class. |
| Constructor Summary | |
|---|---|
protected |
Connections()
Default constructor. |
| Method Summary | |
|---|---|
void |
add(String name,
ConnectionParameters parameters)
Add the specified connection parameters value object to the application persistent state. |
void |
delete(String name)
Remove the specified database from persistent state. |
void |
delete(String databaseType,
String name)
Remove the specified connection parameters from the application persistent state. |
protected void |
deserialise(String user)
Deserialise the contents of FILE_NAME into this instance. |
Connection |
getConnection(String databaseType,
String name)
Return a Connection for the specified database type
and saved with the specified unique name. |
ConnectionParameters |
getConnectionParameters(String databaseType,
String name)
Return a value object that represents all the connection information for the specified database type and saved with the specified unique name. |
DatabaseType |
getDatabaseType(String name)
Returns the DatabaseType identified by the DatabaseType.name
parameter specified. |
Collection<String> |
getDatabaseTypeNames()
Returns the collection of DatabaseType.name values stored as
key in databases. |
Collection<DatabaseType> |
getDatabaseTypes()
Returns databases. |
static Connections |
getInstance(String user)
Create a new instance of the class for the specified user. |
protected void |
serialise()
Serialise this instance to the FILE_NAME. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String ENCODING
public static final String FILE_NAME
public static final String DIRECTORY
protected static final XStream xstream
XStream instance used to serialise
and deserialise instances of this class.
private final TreeMap<String,DatabaseType> databases
DatabaseType instances by their
DatabaseType.name.
private transient String fileName
| Constructor Detail |
|---|
protected Connections()
| Method Detail |
|---|
public static Connections getInstance(String user)
user
under DIRECTORY.
RuntimeException - If errors are encountered while deserialising
the persistent state of this instance.deserialise(java.lang.String)
public Connection getConnection(String databaseType,
String name)
throws ConnectionException
Connection for the specified database type
and saved with the specified unique name.
databaseType - The name of the database engine.name - The unique name used to identify the saved connection.
null if no saved
information can be found for the specified parameters.
ConnectionException - If errors are encountered while initiating
the connection.getConnectionParameters(java.lang.String, java.lang.String),
ConnectionFactory.open( ConnectionParameters )
public ConnectionParameters getConnectionParameters(String databaseType,
String name)
databaseType - The name of the database engine.name - The unique name used to identify the saved connection.
null if no
matching saved connection is found.
public void add(String name,
ConnectionParameters parameters)
name - The unique name to use to identify the saved connection.parameters - The parameters to be saved to FILE_NAME.serialise()
public void delete(String databaseType,
String name)
databaseType - The database type under which the connection was
saved.name - The unique name to use to identify the saved connection.serialise()public void delete(String name)
name - The name of the database engine to remove from saved state.serialise()
protected void deserialise(String user)
throws RuntimeException
FILE_NAME into this instance.
user - The name of the user to use to construct the full filename.
RuntimeException - If errors are encountered while deserialising
the persistent state. No exceptions are thrown if the file does
not exist.
protected void serialise()
throws RuntimeException
FILE_NAME.
RuntimeException - If errors are encountered while serialising
the instance.public DatabaseType getDatabaseType(String name)
DatabaseType identified by the DatabaseType.name
parameter specified.
name - The name to use to fetch the database type.
name or
null if no such database type exists.public Collection<DatabaseType> getDatabaseTypes()
databases.
public Collection<String> getDatabaseTypeNames()
DatabaseType.name values stored as
key in databases.
|
SPT RWT Application API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||