I believe Steve is on the right track. As he is saying
http://pastebin.com/m6add9d4b
describes the "second pull" approach which he have been talking about in
one of the earlier
mails. This is very similar to what I had in mind as well, except I
thought about sub-classing
java.util.Properties.
--Hardy
On Wed, 03 Feb 2010 14:26:59 -0300, Steve Ebersole <steve(a)hibernate.org>
wrote:
I specifically said I did not want to "consolidate the constants
in a
single place". Not in terms of this anyway. Because we will not know
them all ahead of time. Again, I don't see the difference between what
you mention and what would be needed for caching.
Emmanuel was asking specifically about the specific "second pull
approach", which is the context of my answer. There, given the way
y'all decided to form these property names, the only real option is to
process all properties starting with "hibernate.search" since that's the
most common base.
For caching (and search would fit here), I'd expect something like:
interface PropertyConsumer {
public boolean consumes(String name);
public void consume(String name, Object value);
}
class ConfigPropertySet {
...
void consumeProperties(PropertyConsumer consumer) {
Iterator itr = fullPropertySet.entries().iterator();
while ( itr.hasNext() ) {
Map.Entry entry = (Map.Entry) itr.next();
final String name = entry.getKey();
if ( consumer.consumes( name ) ) {
register( name, entry.getValue() ):
consumer.consume( name, entry.getValue() );
}
}
}
}
Or maybe even just:
interface PropertyConsumer {
public boolean consume(String name, Object value);
}
class ConfigPropertySet {
...
void consumeProperties(PropertyConsumer consumer) {
Iterator itr = fullPropertySet.entries().iterator();
while ( itr.hasNext() ) {
Map.Entry entry = (Map.Entry) itr.next();
final String name = entry.getKey();
if ( consumer.consume( name, entry.getValue() ) ) {
register( name, entry.getValue() ):
}
}
}
}