alternative to dfc.properties

8.1k Views Asked by At

We're connecting to documentum server from Java progream (using dfc.jar) to pull the documents. In order to connect to the server, it requires us to make dfc.properties available in the classpath. We already have one master properties file, so want to avoid having one more. Instead, we want to put the properties inside the other properties file and then use them while connecting to the documentum server. I could find how to use docbroker host and port from Java code, i.e. using IDfTypedObject.

IDfLoginInfo loginInfoObj = clientX.getLoginInfo();
loginInfoObj.setUser(user);
loginInfoObj.setPassword(pwd);

IDfClient client = new DfClient();

IDfTypedObject cfg = client.getClientConfig();
cfg.setString("primary_host", "myhost");
cfg.setInt("primary_port", myport);

IDfSession docbase_session = client.newSession(docbase, loginInfoObj);

Like primary_host and primary_port are being set in the code, is there a way to set through code, the following properties from dfc.properties? dfc.globalregistry.repository dfc.globalregistry.username dfc.globalregistry.password

3

There are 3 best solutions below

0
On BEST ANSWER

Despite the fact that you need to have connection information for global registry you really don't need to have those details correct. Of course unless you want to use BOF (TBO/SBO) features.

In your case, if you don't need it (BOFs), just leave dfc.properties in place with dummy data for global registry and continue to use code for dynamically setting docbroker connection details.

2
On

The DFC properties must be in its own file. This file can however reside outside the application itself.

Option 1: Include

Put an include statement in the beginning of the dfc.properties in your classpath to point at the external configuration, like this:

#include /path/to/external/dfc.properties

You can even use hybrid approaches by including several files and/or appending/overwriting in your app's dfc.properties:

#include /path/to/common/dfc.properties
#include /path/to/more/specific/dfc.properties     # may or may not override
<app specific parameters go here>                  # may or may not override

Option 2: Environment variable

Set the environment variable dfc.properties.file to point at your external dfc.properties. Change your appserver's startup to something like this:

java ... –Ddfc.properties.file=/path/to/external/dfc.properties ...

If you're using Tomcat, you can do this by setting a system variable on the OS itself:

set JAVA_OPTS=–Ddfc.properties.file=/path/to/external/dfc.properties

To summarize

I would not recommend setting DFC parameters in code. Best practice is to have a dedicated configuration file outside the application. Beware that your execution enviroment (JVM) must have access to the file system as necessary. This applies to both alternatives above.

0
On

Just to add that if using the classpath to define the location of the main dfc.properties then the dfc.properties file needs to be in a jar or zip file or it will be ignored.