jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Abley <james.ab...@gmail.com>
Subject Re: CacheManager - Cannot Cast BindableRepository to RepositoryImpl
Date Fri, 10 Sep 2010 11:46:23 GMT
On 10 September 2010 10:21, Jukka Zitting <jukka.zitting@gmail.com> wrote:

> Hi,
>
> On Fri, Sep 10, 2010 at 9:51 AM, Gadbury <gadbury@googlemail.com> wrote:
> > All: Is there no straightforward way to configure the Cache Manager when
> > using a BindableRepository?  I have looked but could not find a way to
> > configure the cache in the repository configuration xml.
>
> See JCR-2594 [1] for a way to set the cache limits with system properties.
>
> As suggested by Justin, we of course welcome further improvements in
> this area. :-)
>
> [1] https://issues.apache.org/jira/browse/JCR-2594
>
> BR,
>
> Jukka Zitting
>

James,

<warning>UNSUPPORTED HACK!</warning>

You can  do something like this (from memory and omitting error handling):

Repository repository = RepositoryServiceLocator.INSTANCE.getRepository();
RepositoryImpl impl = null;

if (repository instanceof RepositoryImpl) {
   impl = (RepositoryImpl) repository;
} else if (repository instanceof BindableRepository) {
    for (Field field : repository.getClass().getFields()) {
        if (field.getType().equals(RepositoryImpl.class)) {
            field.setAccessible(true);
            impl = field.get(repository);
            break;
        }
   }
} else if (repository instanceof JCARepositoryHandle) {
   ...
}

if (impl != null) {
    CacheManager manager = impl.getCacheManager();
    ...
}


Hope that helps.

Jukka / Justin, hint taken! I don't do much with Java just now, but I'll try
to submit something.

Cheers,

James

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message