com.uwyn.rife.database
Class Datasources

java.lang.Object
  extended by com.uwyn.rife.database.Datasources

public class Datasources
extends Object

Contains a collection of Datasource instances that have been created from an XML definition. A Datasources instance can either be created by calling the public constructor or by executing the ParticipantDatasources which participates in the application-wide repository.

Since:
1.0
Version:
$Revision: 3634 $
Author:
Geert Bevin (gbevin[remove] at uwyn dot com)
See Also:
Datasource, Xml2Datasources, Rep, ParticipantDatasources

Field Summary
static String DEFAULT_PARTICIPANT_NAME
           
 
Constructor Summary
Datasources()
          Creates a new empty Datasources instance.
Datasources(String xmlPath, ResourceFinder resourceFinder)
          Creates a new Datasources instance from the definitions in an XML file.
 
Method Summary
 void cleanup()
          Cleans up all connections that have been reserved by this datasource.
 Datasource getDatasource(String name)
          Retrieves the Datasource that corresponds to a provided name.
 Collection<String> getDatasourceNames()
          Retrieves a collection of all the Datasource names that are known by this Datasources instance.
static Datasources getRepInstance()
          Retrieves the Datasources instance that is initialized by the ParticipantDatasources participant in the application-wide repository.
 String getXmlPath()
          Retrieves the path of the XML document that populated this DataSources instance
static boolean hasRepInstance()
          Checks if a ParticipantDatasources participant has been initialized and is available from the application-wide repository.
 void setDatasource(String name, Datasource datasource)
          Stores a Datasource with a provided name to be able to reference it later.
 void storeToXml()
          Stores the XML document with all the data in the current Datasources instance to the same file that populated this instance.
 void storeToXml(File destination)
          Stores the XML document with all the data in the current Datasources instance to the provided file.
 String toXml()
          Creates an XML document with all the data in the current Datasources instance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PARTICIPANT_NAME

public static final String DEFAULT_PARTICIPANT_NAME
See Also:
Constant Field Values
Constructor Detail

Datasources

public Datasources()
            throws DatasourcesException
Creates a new empty Datasources instance.

Throws:
DatasourcesException
Since:
1.0

Datasources

public Datasources(String xmlPath,
                   ResourceFinder resourceFinder)
            throws DatasourcesException,
                   DatasourceNotFoundException
Creates a new Datasources instance from the definitions in an XML file.

Parameters:
xmlPath - the path of the XML resource that will be used for the population
resourceFinder - a ResourceFinder instance that will be used to find the file that corresponds to the provided xmlPath
Throws:
DatasourcesException - when an exception occured during the obtainance of the resource's modification time or during the processing of the XML file
DatasourceNotFoundException
Since:
1.0
Method Detail

hasRepInstance

public static boolean hasRepInstance()
Checks if a ParticipantDatasources participant has been initialized and is available from the application-wide repository.

Returns:
true if this participant is available; or

false otherwise

Since:
1.0
See Also:
getRepInstance()

getRepInstance

public static Datasources getRepInstance()
Retrieves the Datasources instance that is initialized by the ParticipantDatasources participant in the application-wide repository.

Returns:
the requested Datasources instances; or

null if the ParticipantDatasources couldn't be found

Since:
1.0
See Also:
hasRepInstance()

getDatasource

public Datasource getDatasource(String name)
Retrieves the Datasource that corresponds to a provided name.

Parameters:
name - a String that identifies the Datasource that has to be retrieved
Returns:
the requested Datasource instance; or

null if name isn't known

Since:
1.0

setDatasource

public void setDatasource(String name,
                          Datasource datasource)
Stores a Datasource with a provided name to be able to reference it later.

Parameters:
name - a String that identifies the Datasource
datasource - the Datasource instance that has to be stored
Since:
1.0

getDatasourceNames

public Collection<String> getDatasourceNames()
Retrieves a collection of all the Datasource names that are known by this Datasources instance.

Returns:
the requested Collection
Since:
1.0

getXmlPath

public String getXmlPath()
Retrieves the path of the XML document that populated this DataSources instance

Returns:
the path of the XML document that populated this DataSources instance
Since:
1.0

toXml

public String toXml()
Creates an XML document with all the data in the current Datasources instance

Returns:
the constructed XML document as a String
Since:
1.0

storeToXml

public void storeToXml()
                throws DatasourcesException
Stores the XML document with all the data in the current Datasources instance to the same file that populated this instance.

Throws:
DatasourcesException - when an error occurred during the storage
Since:
1.0

storeToXml

public void storeToXml(File destination)
                throws DatasourcesException
Stores the XML document with all the data in the current Datasources instance to the provided file.

Parameters:
destination - the File in which the data will be stored
Throws:
DatasourcesException - when an error occurred during the storage

cleanup

public void cleanup()
             throws DatabaseException
Cleans up all connections that have been reserved by this datasource.

Throws:
DatabaseException - when an error occured during the cleanup
Since:
1.0


Copyright © 2001-2007 Uwyn sprl/bvba. All Rights Reserved.