[jboss-dev-forums] [Design of JBossCache] - POJOization of config elements

bstansberry@jboss.com do-not-reply at jboss.com
Wed Oct 18 12:43:13 EDT 2006


Branching off from http://www.jboss.com/index.html?module=bb&op=viewtopic&t=92700 as that thread's a bit wide ranging :)

It's nice if individual BuddyLocator, CacheLoader and EvictionPolicy impls can provide POJO config classes; i.e. classes that expose bean properties, rather than config solely via a Properties object.  This should be optional; i.e. an impl must be able to configure itself via Properties, but if it has an impl-specific config class that the MC can use, that's good too.

This leads to some API changes.  I'll use BuddyLocator as an example.

First, we add a new BuddyLocatorConfig class.


  | public static class BuddyLocatorConfig {
  | 
  |    public String getBuddyLocatorClass() {...}
  |    public void setBuddyLocatorClass(String className) {...}
  | 
  |    public Properties getBuddyLocatorProperties() {...}
  |    public void setBuddyLocatorProperties(Properties properties) {...}
  | 
  | }
  | 

Specific BuddyLocator impls can have their own type-specific subclass of this with their own java bean properties, but they must be able to configure themselves via the base superclass w/ its Properties as well.

So, BuddyLocator interface becomes:


  | public interface BuddyLocator
  | {
  |    public BuddyLocatorConfig getConfig();
  |    public void init(BuddyLocatorConfig config);
  |    public List locateBuddies(Map buddyPoolMap, List currentMembership, IpAddress dataOwner);
  | }
  | 

Basically init() takes a BuddyLocatorConfig instead of Properties; plus I added a getter for the config.

Similar concept would apply to CacheLoader and EvictionPolicy.  For CacheLoader, the equivalent to BuddyLocatorConfig already exists with IndividualCacheLoaderConfig; it's just not directly injected into a CacheLoader.  So for the CacheLoader interface setConfig() would take IndividualCacheLoaderConfig instead of Properties, plus I'd add a getter for the config as well.

Haven't looked int detail at EvictionPolicy, but expect the same concept to apply there.

Comments?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3979144#3979144

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3979144



More information about the jboss-dev-forums mailing list