jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gadbury <gadb...@googlemail.com>
Subject Re: CacheManager - Cannot Cast BindableRepository to RepositoryImpl
Date Mon, 13 Sep 2010 10:07:18 GMT

Thanks Jukka and James for your replies.

James: During iteration of repository's fields, It never finds a field type
that equals RepositoryImpl.class.  If I inspect repository, it has a private
member called repository.  I have tried using
BindableRepository.class.getFields() and .getDeclaredFields().

I changed the code to this.  This works for me.  Not sure if that means it
is good code though!


	Repository repository = RepositoryServiceLocator.INSTANCE.getRepository();
	RepositoryImpl impl = null; 
	
	if (repository instanceof RepositoryImpl) 
	{
		impl = (RepositoryImpl) repository;
	} 
	else if (repository instanceof BindableRepository) 
	{
		for (Field field : BindableRepository.class.getDeclaredFields())
		{
			if (field.getType().equals(JackrabbitRepository.class)) 
			{
				field.setAccessible(true);
				impl = (RepositoryImpl) field.get(repository);
				break; 
			}
		}
		
		//Field privateRepositoryField =
BindableRepository.class.getDeclaredField("repository");
		//privateRepositoryField.setAccessible(true);
		//impl = (RepositoryImpl) privateRepositoryField.get(repository);
	}

	if (impl != null) 
	{
		CacheManager manager = impl.getCacheManager();
		
		manager.setMaxMemory			(256 * 1024 * 1024); 	// default is 16 * 1024 *
1024
		manager.setMaxMemoryPerCache	(64 * 1024 * 1024); 	// default is 4 * 1024 *
1024
		manager.setMinMemoryPerCache	(1 * 1024 * 1024); 		// default is 128 *
1024]
	}	

Commented out is another method I was using to access the repository field.

Not sure which way would be best.  I figured the commented out way assumes
that the field will always be called "repository" so could break more
easily.

Cheers,

James
-- 
View this message in context: http://jackrabbit.510166.n4.nabble.com/CacheManager-Cannot-Cast-BindableRepository-to-RepositoryImpl-tp2533300p2537181.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.

Mime
View raw message