88
99public class GridEngineConfig {
1010
11- private static GridEngineConfig instance = null ;
11+ private static GridEngineConfig instance = null ;
1212 private static final Logger _log = Logger .getLogger (GridEngineConfig .class .getName ());
13- private final String gePropertiesFile = "GridEngine.properties" ;
14-
15- private String userstrackingDatasource = "jdbc/UserTrackingPool" ; //default value
16- private String hibernateDatasource = "jdbc/gehibernatepool" ; //default value
17-
18- public static synchronized GridEngineConfig getInstance (){
19- if (instance == null )
20- instance = new GridEngineConfig ();
21- return instance ;
22- }
23-
13+ private final String gePropertiesFile = "GridEngine.properties" ;
14+
15+ private String userstrackingDatasource = "jdbc/UserTrackingPool" ;
16+ private String hibernateDatasource = "jdbc/gehibernatepool" ;
17+
18+ public static synchronized GridEngineConfig getInstance () {
19+ if (instance == null )
20+ instance = new GridEngineConfig ();
21+ return instance ;
22+ }
23+
2424 /**
25- * Load the given configuration file which overrides static settings
26- * @param configFile
27- */
28- private GridEngineConfig () {
29- /*
30- Load a configuration file containing GridEngineDaemon settings
31- wich override the static settings defined in the class
32- */
33- loadProperties ();
34- _log .info ("GridEngine config:" + this .toString ());
35- }
25+ * Load the given configuration file which overrides static settings
26+ *
27+ * @param configFile
28+ */
29+ private GridEngineConfig () {
30+ /*
31+ * Load a configuration file containing GridEngineDaemon settings wich
32+ * override the static settings defined in the class
33+ */
34+ loadProperties ();
35+ _log .info ("GridEngine config:" + this .toString ());
36+ }
3637
3738 private void loadProperties () {
38- //
39- InputStream inputStream =null ;
40- Properties prop = new Properties ();
41- try {
42- inputStream = this .getClass ().getClassLoader ().
43- getResourceAsStream (gePropertiesFile );
44-
45- prop .load (inputStream );
46-
47- /*
48- Retrieving configuration values
49- */
50-
51- // APIServer DB settings
52- String prop_usertrackingDatasource = prop .getProperty ("usertracking_datasource" );
53- String prop_hibernateDatasource = prop .getProperty ("hibernate_datasource" );
54-
55- if (prop_usertrackingDatasource !=null ) {
56- this .userstrackingDatasource = prop_usertrackingDatasource ;
57- }
58- if (prop_hibernateDatasource !=null ) {
59- this .hibernateDatasource = prop_hibernateDatasource ;
60- }
61- } catch (NullPointerException e ) {
62- _log .warn ("Unable to load property file; using default settings" );
63- } catch (IOException e ) {
64- _log .warn ("Error reading file: " + e );
65- } catch (NumberFormatException e ) {
66- _log .warn ("Error while reading property file: " + e );
67- }
68- finally {
69- try {
70- if (null != inputStream ) inputStream .close ();
71- } catch (IOException e ) {
72- _log .error ("Error closing configuration file input stream" );
73- }
74- }
39+ //
40+ InputStream inputStream = null ;
41+ Properties prop = new Properties ();
42+ try {
43+ inputStream = this .getClass ().getClassLoader ().getResourceAsStream (gePropertiesFile );
44+
45+ prop .load (inputStream );
46+
47+ /*
48+ * Retrieving configuration values
49+ */
50+
51+ // APIServer DB settings
52+ String prop_usertrackingDatasource = prop .getProperty ("usertracking_datasource" );
53+ String prop_hibernateDatasource = prop .getProperty ("hibernate_datasource" );
54+
55+ if (prop_usertrackingDatasource != null ) {
56+ this .userstrackingDatasource = prop_usertrackingDatasource ;
57+ }
58+ if (prop_hibernateDatasource != null ) {
59+ this .hibernateDatasource = prop_hibernateDatasource ;
60+ }
61+ } catch (NullPointerException e ) {
62+ _log .warn ("Unable to load property file; using default settings" );
63+ } catch (IOException e ) {
64+ _log .warn ("Error reading file: " + e );
65+ } catch (NumberFormatException e ) {
66+ _log .warn ("Error while reading property file: " + e );
67+ } finally {
68+ try {
69+ if (null != inputStream )
70+ inputStream .close ();
71+ } catch (IOException e ) {
72+ _log .error ("Error closing configuration file input stream" );
73+ }
74+ }
7575 }
7676
7777 public String getUserstrackingDatasource () {
@@ -81,12 +81,11 @@ public String getUserstrackingDatasource() {
8181 public String getHibernateDatasource () {
8282 return hibernateDatasource ;
8383 }
84-
84+
8585 @ Override
8686 public String toString () {
87- return "GridEngineConfig [gePropetiesFile=" + gePropertiesFile
88- + ", userstrackingDatasource=" + userstrackingDatasource
89- + ", hibernateDatasource=" + hibernateDatasource + "]" ;
87+ return "GridEngineConfig [gePropetiesFile=" + gePropertiesFile + ", userstrackingDatasource="
88+ + userstrackingDatasource + ", hibernateDatasource=" + hibernateDatasource + "]" ;
9089 }
91-
90+
9291}
0 commit comments