Hello,
I'm quite new to the EJB technology.
My problem is, how to handle a property file?
Let's say I have a custom 'property.xml' (that holds some application specific constants) somewhere in my EJB jar or in a related jar (so it is in the classapth).
Usually (not with EJB) I would write a class (let's name it 'Props', see below) which reads the property file once and initialize some public static members.
In an object (see below 'MyClass') I would then use 'Props.memberName' if I want to have access to a constant property.
.
class with public static constants members; read the file only once; properties are in memory ...
public class Props
public static String FOO = null;
static
{
Properties props = new Properties();
try
{
props.loadFromXML(CConstants.class.getClass().getClassLoader().getResourceAsStream("propertyFile.xml"));
FOO = props.getProperty("FOO");
}
catch(Exception e){...}
}
}
The class that uses the properties<br>
public class MyClass
{
...
public void doSomething()
{
...
String s = Props.FOO + " BAR";
...
}
...
}
But unfortunately static things are not allowed in EJB ...
What is the preferred way to get access to the properties?
To read the file each time an EJB is used, will cause much disc-I/O and xml parsing (this is very unefficient).
Is there no mechanism to read such things once only?
I would be very pleased to get an answer, because I don't know how to solve this problem
Thanks