diff --git a/trunk/PlanosActuacao/src/db/DBConstants.java b/trunk/PlanosActuacao/src/db/DBConstants.java new file mode 100644 index 00000000..91408006 --- /dev/null +++ b/trunk/PlanosActuacao/src/db/DBConstants.java @@ -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"; +} diff --git a/trunk/PlanosActuacao/src/db/DBPropertiesLoader.java b/trunk/PlanosActuacao/src/db/DBPropertiesLoader.java new file mode 100644 index 00000000..ec62fc2b --- /dev/null +++ b/trunk/PlanosActuacao/src/db/DBPropertiesLoader.java @@ -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; + } + +}