forked from Coded/SIPRP
git-svn-id: https://svn.coded.pt/svn/SIPRP@1818 bb69d46d-e84e-40c8-a05a-06db0d633741
parent
632f023142
commit
7b5b59b025
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package db;
|
||||||
|
|
||||||
|
import com.evolute.utils.Singleton;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author dneves
|
||||||
|
*/
|
||||||
|
public interface DBConstants
|
||||||
|
{
|
||||||
|
public static enum DB { SIPRP, SIPRP_LOCAL };
|
||||||
|
|
||||||
|
public static final String DEFAULT_PROVIDER = Singleton.DEFAULT_OBJECT_PROVIDER;
|
||||||
|
public static final String LOCAL_PROVIDER = "LOCAL_PROVIDER";
|
||||||
|
|
||||||
|
public static final String DEFAULT_DBMANAGER = "DEFAULT_DBMANAGER";
|
||||||
|
public static final String LOCAL_DBMANAGER = "LOCAL_DBMANAGER";
|
||||||
|
|
||||||
|
public static final String SESSION_CONNECTION = "SESSION_CONNECTION";
|
||||||
|
public static final String SESSION_CONNECTION_LOCAL = "SESSION_CONNECTION_LOCAL";
|
||||||
|
|
||||||
|
public static final String SERVER_SIPRP = "server.siprp";
|
||||||
|
public static final String PORT_SIPRP = "port.siprp";
|
||||||
|
public static final String DATABASE_SIPRP = "database.siprp";
|
||||||
|
public static final String USERNAME_SIPRP = "username.siprp";
|
||||||
|
public static final String PASSWORD_SIPRP = "password.siprp";
|
||||||
|
|
||||||
|
public static final String SERVER_SIPRP_LOCAL = "server.siprp_local";
|
||||||
|
public static final String PORT_SIPRP_LOCAL = "port.siprp_local";
|
||||||
|
public static final String DATABASE_SIPRP_LOCAL = "database.siprp_local";
|
||||||
|
public static final String USERNAME_SIPRP_LOCAL = "username.siprp_local";
|
||||||
|
public static final String PASSWORD_SIPRP_LOCAL = "password.siprp_local";
|
||||||
|
|
||||||
|
public static final String CONNECTION_URL = "connection.url";
|
||||||
|
public static final String LOCAL_CONNECTION_URL = "connection.local_url";
|
||||||
|
}
|
||||||
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package db;
|
||||||
|
|
||||||
|
import com.evolute.properties.EvoAbstractPropertiesLoader;
|
||||||
|
import com.evolute.properties.PropertiesException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author dneves
|
||||||
|
*/
|
||||||
|
public class DBPropertiesLoader extends EvoAbstractPropertiesLoader
|
||||||
|
{
|
||||||
|
private static DBPropertiesLoader INSTANCE = null;
|
||||||
|
|
||||||
|
private String connection_url = null;
|
||||||
|
private String local_connection_url = null;
|
||||||
|
|
||||||
|
|
||||||
|
private DBPropertiesLoader()
|
||||||
|
{
|
||||||
|
super( null, null, null, null );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static synchronized DBPropertiesLoader getInstance()
|
||||||
|
{
|
||||||
|
if ( INSTANCE == null )
|
||||||
|
{
|
||||||
|
INSTANCE = new DBPropertiesLoader();
|
||||||
|
}
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void postLoad() throws PropertiesException
|
||||||
|
{
|
||||||
|
String server = findProperty( DBConstants.SERVER_SIPRP );
|
||||||
|
int port = findProperty( DBConstants.PORT_SIPRP, new Integer( -1 ) );
|
||||||
|
String database = findProperty( DBConstants.DATABASE_SIPRP );
|
||||||
|
connection_url = "jdbc:postgresql://" + server + ":" + port + "/" + database;
|
||||||
|
|
||||||
|
server = findProperty( DBConstants.SERVER_SIPRP_LOCAL );
|
||||||
|
port = findProperty( DBConstants.PORT_SIPRP_LOCAL, new Integer( -1 ) );
|
||||||
|
database = findProperty( DBConstants.DATABASE_SIPRP_LOCAL );
|
||||||
|
local_connection_url = "jdbc:postgresql://" + server + ":" + port + "/" + database;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getConnectionURL()
|
||||||
|
{
|
||||||
|
return connection_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocalConnectionURL()
|
||||||
|
{
|
||||||
|
return local_connection_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in new issue