List Info

Thread: Lack of lifecycle methods in CacheLoaderConfig classes




Lack of lifecycle methods in CacheLoaderConfig classes
user name
2008-05-14 16:26:09
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
_______________________________________________
jbosscache-dev mailing list
jbosscache-devlists.jboss.org
https://lists.jboss.org/mailman/listinfo/jbosscache-dev

Re: Lack of lifecycle methods in CacheLoaderConfig classes
user name
2008-05-14 16:58:44
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
_______________________________________________
jbosscache-dev mailing list
jbosscache-devlists.jboss.org
https://lists.jboss.org/mailman/listinfo/jbosscache-dev

Re: Lack of lifecycle methods in CacheLoaderConfig classes
user name
2008-05-15 07:11:43
On 14 May 2008, at 22:58, Galder Zamarreno wrote:

> 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;
>   }

+1 - this is my preferred approach, rather than adding
lifecycles to  
config elements or to get users to pass in SQL queries.

Cheers,
--
Manik Surtani
Lead, JBoss Cache
manikjboss.org






_______________________________________________
jbosscache-dev mailing list
jbosscache-devlists.jboss.org
https://lists.jboss.org/mailman/listinfo/jbosscache-dev

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )