On 10 September 2010 10:21, Jukka Zitting <[email protected]> wrote:

> Hi,
>
> On Fri, Sep 10, 2010 at 9:51 AM, Gadbury <[email protected]> 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

Reply via email to