|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.folt.models.datamodel.DataSourceInstance
public class DataSourceInstance
This class maintains a list of active data sources (instances of data
sources). Data source are added by using createInstance. The class
itself cannot be instantiated.
The main idea is to have only one active instance for each named data source
. This e.g. avoids loading the same data sources several times (in different
threads).
This implements a (enhanced) singleton pattern; not in its classical meaning
where one has really only one instance. In contrasts it pools several
instances of data sources in one hash table. Each data source is stored in
the hash table with a key which identifies a given dat source. As a singleton
there is no method to create a DataSourceInstance. The method
getInstace returns a named data source. getInstance creates one if it
does not exist otherwise returns the one found. getAllDataSourceInstanceNames
returns all active instances.
The data sources themselves are stores in @see
de.folt.models.datamodel.DataSourceStorage, which basically is a class
consisting of the data source and a counter indicating how often the
createInstance method was called. createInstance increase the counter,
removeInsance decreases the counter. The data source is removed from the list
when the counter decrements to zero. The data source remove method is only
called if the removeIfCounterZero boolean of DataSourceStorage is set to true
(which it is per default).
| Method Summary | |
|---|---|
static DataSource |
createInstance(java.lang.String name)
createInstance create an instance of a data source based on its name. |
static DataSource |
createInstance(java.lang.String name,
DataSourceProperties dataModelProperties)
createInstance create an instance of a data source based on its name and model a parameters. |
static DataSource |
createInstance(java.lang.String name,
java.util.Observer observer)
createInstance creates an instance of a data source with and attaches an observer |
static DataSource |
createInstance(java.lang.String name,
java.lang.String configfile)
createInstance create an instance of a data source based on its name. |
static java.lang.String[] |
getAllDataSourceInstanceNames()
getAllDataSourceInstanceNames returns all data source instances |
static int |
getCounter(java.lang.String name)
getCounter get the counter (usage) value for the data source |
static DataSourceStorage |
getDataSourceStorageInstance(java.lang.String name)
getDataSourceStorageInstance get the data storage instance |
static java.util.Vector<java.lang.String[]> |
getDataSourcesWithType()
|
static java.lang.String[] |
getDataSourcesWithType(java.lang.String type)
|
static DataSource |
getInstance(java.lang.String name)
getInstance |
static java.util.Vector<java.lang.String> |
getKnownDataSourceModels()
getKnownDataSourceModels return all the known data source model classes |
static java.util.Vector<java.lang.String> |
getOpenTMSDatabases()
getOpenTMSDatabases get a vector of the openTMS Data Sources |
static void |
main(java.lang.String[] args)
main |
static DataSource |
removeInstance(java.lang.String name)
removeInstance |
static void |
test()
test simple test method for generating DataModelInstances |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static DataSource createInstance(java.lang.String name)
throws OpenTMSException
name - of the data source
OpenTMSException
public static DataSource createInstance(java.lang.String name,
DataSourceProperties dataModelProperties)
throws OpenTMSException
name - the name for the new instancedataModelProperties - the properties associated with the new instance
OpenTMSException
public static DataSource createInstance(java.lang.String name,
java.util.Observer observer)
throws OpenTMSException
name - the data source to createobserver - an observer for the data source
OpenTMSException
public static DataSource createInstance(java.lang.String name,
java.lang.String configfile)
throws OpenTMSException
name - of the data source
OpenTMSExceptionpublic static java.lang.String[] getAllDataSourceInstanceNames()
public static int getCounter(java.lang.String name)
name - the data source name
public static DataSourceStorage getDataSourceStorageInstance(java.lang.String name)
name - the name of the instance
public static DataSource getInstance(java.lang.String name)
name - the name of the data source instance to be retrieved
public static java.util.Vector<java.lang.String> getKnownDataSourceModels()
public static java.util.Vector<java.lang.String> getOpenTMSDatabases()
public static java.util.Vector<java.lang.String[]> getDataSourcesWithType()
public static java.lang.String[] getDataSourcesWithType(java.lang.String type)
public static void main(java.lang.String[] args)
args -
public static DataSource removeInstance(java.lang.String name)
throws OpenTMSException
name - the name of the data model to remove; usually the data model
then closes connections etc.
OpenTMSExceptionpublic static void test()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||