return(dblibSvc);
}
// Try to get dblib as an OSGI service
- BundleContext bctx = null;
- ServiceReference sref = null;
- Bundle bundle = FrameworkUtil.getBundle(SqlResource.class);
-
- if (bundle != null) {
- bctx = bundle.getBundleContext();
- }
-
- if (bctx != null) {
- sref = bctx.getServiceReference(DBLIB_SERVICE);
- }
-
- if (sref == null) {
- LOG.warn("Could not find service reference for DBLIB service (" + DBLIB_SERVICE + ")");
- } else {
- dblibSvc = (DbLibService) bctx.getService(sref);
- if (dblibSvc == null) {
+ try {
+ BundleContext bctx = null;
+ ServiceReference sref = null;
+
+
+
+ Bundle bundle = FrameworkUtil.getBundle(SqlResource.class);
+
+ if (bundle != null) {
+ bctx = bundle.getBundleContext();
+ }
+
+ if (bctx != null) {
+ sref = bctx.getServiceReference(DBLIB_SERVICE);
+ }
+
+ if (sref == null) {
LOG.warn("Could not find service reference for DBLIB service (" + DBLIB_SERVICE + ")");
+ } else {
+ dblibSvc = (DbLibService) bctx.getService(sref);
+ if (dblibSvc == null) {
+ LOG.warn("Could not find service reference for DBLIB service (" + DBLIB_SERVICE + ")");
+ }
}
+ } catch (NoClassDefFoundError ex) {
+ LOG.info("OSGI classes not found - must be running outside an OSGi container");
}
+
if (dblibSvc == null) {
// Must not be running in an OSGI container. See if you can load it
// as a
// be the properties passed to DBResourceManager constructor.
// If not, as default just use system properties.
Properties dblibProps = System.getProperties();
- String cfgDir = System.getenv("SDNC_CONFIG_DIR");
+
+ String cfgDir = dblibProps.getProperty("sdnc.config.dir", System.getenv("SDNC_CONFIG_DIR"));
if ((cfgDir == null) || (cfgDir.length() == 0)) {
cfgDir = "/opt/sdnc/data/properties";
File dblibPropFile = new File(cfgDir + "/dblib.properties");
if (dblibPropFile.exists()) {
try {
+ LOG.debug("Loading dblib properties from {}", dblibPropFile.getAbsolutePath());
dblibProps = new Properties();
dblibProps.load(new FileInputStream(dblibPropFile));
} catch (Exception e) {
- LOG.warn("Could not load properties file " + dblibPropFile.getAbsolutePath(), e);
+ LOG.warn("Could not load properties file {}", dblibPropFile.getAbsolutePath(), e);
dblibProps = System.getProperties();
}