i3.dragos.core.services.datasources
Class DataSourceURL

java.lang.Object
  extended by i3.dragos.core.services.datasources.DataSourceURL
All Implemented Interfaces:
java.io.Serializable

public final class DataSourceURL
extends java.lang.Object
implements java.io.Serializable

The DataSourceURL uniquely represents a specific data source ("physical DataSourceURL", e.g. location of a database server) or the DataSource and GraphPool object built upon such a data source ("logical DataSourceURL").

A logical DataSourceURL is generated by the GraphPoolFactory to hide the implementation specific data (which may e.g. include the database password) and provide stable identifiers even if the underlying implementation is changed or the database is moved. These DataSourceURLs all have the following form:

       dragos://<server_name>/<graphpool_name>
 

The exact structure of a physical DataSourceURL depends on the implementation using it, the basic form is as follows:

       <implementation_identifier>:<implementation_specific_data>
 
The implementation-identifier is used by the DataSourceFactory to determine and instantiate the corresponding DataSource implementation (as configured in the server.xml file). The implementation then interprets the specific data.

Usually, you will need to deal with physical DatasourceURLs only when configuring the data source (or writing a DataSource implementation yourself), and use only logical DatasourceURLs in an application or extension.

// TODO: the following text is old documentation, update, move or remove when making the DataSourceURL changes proposed by Erhard!

The syntax of a URL is defined as follows:

       database-identifier://[user:password@][host][:port]/database[parameters]
 
Where the different parts of the URL is defined as follows:
database-identifier
Every database is associated with a unique identifier. The identifier must not contain the string "://".
user
The database user that is required to connect to the database. If no user is required it can be dropped.
password
The password that identifies the user. It is left blank if no password is required for the user.
host
The host on which the database server runs. If the database server is running on "localhost" it can be dropped.
port
The port on which the database server is listening for connections. If the database server listen on the default port it can be dropped.
database
The database on the database server that is used to stored the contents of the graph pool.
parameters
Paramers are used to customize the connection to the data source. The parameters are specified in the following format:
          ?key=value[&key=value]*
 

Author:
Boris Boehlen <boehlen@cs.rwth-aachen.de>, Thorsten Hermes <thermes@i3.informatik.rwth-aachen.de>
See Also:
DataSource, DataSourceFactory, GraphPoolFactory, Serialized Form

Constructor Summary
DataSourceURL(java.lang.String datasourceURL)
          Constructs a new URL which uniquely identifies a data source.
 
Method Summary
static DataSourceURL createLogicalDataSourceURL(java.lang.String name)
          creates a logical datasource URL from the unique name of the running DRAGOS instance.
 boolean equals(java.lang.Object obj)
          
 java.lang.String getDatasource()
          Returns the data source name.
 java.lang.String getHost()
          Returns the host of the data source.
 java.lang.String getPassword()
          Returns the password which is used to obtain access to the data source.
 java.lang.String getPort()
          Returns the port on which the data source listens for incoming connections.
 java.util.Properties getProperties()
          Returns the properties for this URL.
 java.lang.String getProtocol()
          Returns the protocol used by the data source.
 java.lang.String getUsername()
          Returns the username which is used to obtain access to the data source.
 int hashCode()
          
 boolean hasProperties()
          Returns true if properties for this URL were definied and false otherwise.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataSourceURL

public DataSourceURL(java.lang.String datasourceURL)
              throws java.net.MalformedURLException
Constructs a new URL which uniquely identifies a data source.

Parameters:
datasourceURL - The URL that identifies a data source.
Throws:
java.net.MalformedURLException - if the URL does not match the syntax.
Method Detail

getProtocol

public java.lang.String getProtocol()
Returns the protocol used by the data source.

Returns:
the protocol used by the data source.

getDatasource

public java.lang.String getDatasource()
Returns the data source name.

Returns:
the data source name.

getHost

public java.lang.String getHost()
Returns the host of the data source.

Returns:
the host of the data source.

getPort

public java.lang.String getPort()
Returns the port on which the data source listens for incoming connections.

Returns:
the port on which the data source listens for incoming connections.

getUsername

public java.lang.String getUsername()
Returns the username which is used to obtain access to the data source.

Returns:
the username which is used to obtain access to the data source.

getPassword

public java.lang.String getPassword()
Returns the password which is used to obtain access to the data source.

Returns:
the password which is used to obtain access to the data source.

getProperties

public java.util.Properties getProperties()
Returns the properties for this URL.

Returns:
the properties for this URL.

hasProperties

public boolean hasProperties()
Returns true if properties for this URL were definied and false otherwise.

Returns:
true if properties for this URL were definied.

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)

Overrides:
equals in class java.lang.Object

createLogicalDataSourceURL

public static DataSourceURL createLogicalDataSourceURL(java.lang.String name)
                                                throws java.net.MalformedURLException
creates a logical datasource URL from the unique name of the running DRAGOS instance.

Parameters:
name - unique name of the running DRAGOS instance
Returns:
a logical datasource URL
Throws:
java.net.MalformedURLException - if the URL cannot be constructed


Copyright © 2002-2008 RWTH Aachen, Department of Computer Science 3 (Software Engineering). All Rights Reserved.