Reading property file in JCD?
Hi,
I need to read property file which contains N number of key and value pairs and after reading the same I need to pass the value to output OTD.
My Idea is I would be putting the file under logical host installed firectry and using I System.getproperty("configdir") I would be able to read the file.
But I am always getting FileNotFoundException.If I give the actual path like C:\logicalhost\aaa.properties I am able to read the file.
So How could I get the root dir of logical host.Is there any method to be used for getting the same.
or
If you have any idea to read the property file please let me know.
Thanks,
Renga
# 1
There are several way to do this. Most rely on the properties file being available in the classpath and using the classloader to load it. This is not where the story ends, however. You will likely need to take steps to prevent the properties file, particularly a sizeable one, from being re-read each time your collaboration gets invoked.
Let me have you email address, to michaelDOTczapskiATsunDOTcom, and I will send you a document, with pictures, that discusses this topic at some length.
Let me bemoan here the fact that this list, and other lists like the ones at ittoolbox.com and elsewhere, does not appear to permit attachments such as documents or pictures. This makes it very difficult to help people when help is a document or a picture away.
# 3
One thing you could do is to configure the JVM options by adding each System Property you need as a JVM option in the following format: -Dname=value, restart the IS and your code of System.getProperty(name) would work.
You may also put the property file in a Jar file, import it into your project, and use the classloader to load the properties.
Attaching a stream to a property file one way or another will more than likely not work unless you change the security policy of the IS, and be aware of the potential dangers of using java.io operations in a EJB container (which is singled out as a must-not in EJB specifications), because JCDs are assembled into EJBs afterall.