[jbosscache-dev] [JBCACHE-1342] Lack of lifecycle methods in CacheLoaderConfig classes

Galder Zamarreno galder.zamarreno at redhat.com
Wed May 14 17:58:44 EDT 2008


There's two other workarounds for this:

- Create SQL strings on the fly, when get operations are called:

    public String getSelectChildNamesSql()
    {
       if (selectChildNamesSql == null)
       {
          setSelectChildNamesSql("select " + fqnColumn + " from " + 
table + " where " + parentColumn + "=?");
       }

       return selectChildNamesSql;
    }

    public void setSelectChildNamesSql(String selectChildNamesSql)
    {
       testImmutability("selectChildNamesSql");
       this.selectChildNamesSql = selectChildNamesSql;
    }

- Or instead of setting individual fields, set sqls via individual 
properties. For example, rather than:

<property name="table">jbosscache</property>
<property name="fqnColumn">fqn</property>
<property name="parentColumn">parentfqn</property>

write:

<property name="selectChildNamesSql">select fqn from jbosscache where 
parentfqn=?</property>

taking in account that:

selectChildNamesSql = "select " + fqnColumn + " from " + table + " where 
" + parentColumn + "=?";

The latter option is probably the most flexible one from a users point 
of view, but this type of configuration is not possible via standalone 
XML configuration, so would probably only add to the confusion.

Cheers,

Galder Zamarreno wrote:
> Hi all,
> 
> Re: http://jira.jboss.com/jira/browse/JBCACHE-1342
> 
> I've converted JDBCCacheLoaderConfig into a JavaBean class, however I 
> have some lifecycle issues now. setProperties() method within it, as 
> well as setting individual fields, also creates composite fields such 
> as: insertNodeSql, selectChildNamesSql...etc
> 
> If we want to create JDBCCacheLoaderConfig beans via individual 
> properties, rather than the setProperties() method we need some kind of 
> create step where we know that properties have already been set, and we 
> can use the create step to create the sql queries.
> 
> The bigger problem I suppose is that from what I can see setProperties() 
> is only really called after parsing the XML configuration, but this does 
> not happen for AS, as the configuration is parsed by the MC. I can see 
> quite a few bugs arising from this area, iow untested configurations. In 
> fact, I just came across another one: 
> http://jira.jboss.com/jira/browse/JBCACHE-1346
> 
> The JBossCache wikis are not available at the moment and I'm not sure 
> whether lifecycle annotations are explained somewhere else, so that we 
> can integrate the cache loader configurations into the cache lifecycle.
> 
> Cheers,

-- 
Galder Zamarreño
Sr. Software Maintenance Engineer
JBoss, a division of Red Hat



More information about the jbosscache-dev mailing list