Alternative to dfc.properties
We connect to the Documentum server from Java progream (using dfc.jar) to pull documents. To connect to the server, we need to make dfc.properties available on the classpath. We already have one main properties file, so you want to avoid another one. Instead, we want to place properties inside another properties file and then use them when connecting to the Documentum server. I could find how to use docbroker host and port from Java code i.e. Use 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 set in code, is there a way to set code, following properties from dfc.properties? dfc.globalregistry.repository dfc.globalregistry.username dfc.globalregistry.password
source to share
Even though you need the connection information for the global registry, you really don't need to handle this data correctly. Unless of course you want to use the BOF (TBO / SBO) functions.
In your case, if you don't need it (BOF), just leave the dfc.properties in place with dummy data for the global registry and continue using the code to dynamically set up the docbroker connection details.
source to share
DFC properties must be in their own file. However, this file can be located outside the application itself.
Option 1: Enable
Place an include statement at the beginning dfc.properties
in your classpath to point to foreign configuration, for example:
#include /path/to/external/dfc.properties
You can even use hybrid approaches including multiple files and / or in-app add / rewrite 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 an environment variable dfc.properties.file
to point to external dfc.properties
. Change your application launch to something like this:
java ... โDdfc.properties.file=/path/to/external/dfc.properties ...
If you are using Tomcat, you can do this by setting a system variable in the OS itself:
set JAVA_OPTS=โDdfc.properties.file=/path/to/external/dfc.properties
Summarizing
I would not recommend setting DFC options in code. The best practice is to have a custom configuration file outside of the application. Remember that the runtime (JVM) must have access to the file system as needed. This applies to both of the alternatives above.
source to share