If whatever is using the properties relys on iteration over the keys
in the props, then it won't pickup any keys from the defaults. But
if it asks with getProperty(), and there is no key for that name in
the top-level props, then it will check the defaults props. And this
only works with getProperty(), won't work with get().
A minor note, if you ever want to extend a Properties to provide
custom behavior, you probably need to override get() and getProperty
(), put the meat into get(), and the make a getProperty() which calls
get(), as the default impl from the sun peeps is for getProperty() to
call super.get(), not get()... which always causes me problems.
--jason
On May 18, 2007, at 1:19 PM, Jacek Laskowski wrote:
Hi,
I'm completely stumped - how does the defaults work in
java.util.Properties class?
If you're curious what I'm after, take a look at IvmTestServer class,
esp. its init method. There's the following snippet:
props.put("java.naming.factory.initial",
"org.apache.openejb.client.LocalInitialContextFactory");
Properties p = new Properties(props);
p.put("openejb.loader", "embed");
new InitialContext( p );
The aim of it is to initialize openejb embedded, but it won't happen
as the props are not consulted by InitialContext constructor (!) When
I changed new InitialContext(p) with new InitialContext(props) it
worked as expected. Why is that? I can't find the answer :(
Jacek
--
Jacek Laskowski
http://www.JacekLaskowski.pl