Steve Vangasse wrote:
Thanks Armin. I should have checked the source code.

Switching logging on for CacheDistributor gives the following output:

DEBUG org.apache.ojb.broker.cache.CacheDistributor - Create new ObjectCache implementation for mainConnection

I don't get any of the details that you get.

Maybe OJB doesn't lookup the cache in your test. Which OJB version do you use?


The reason I thought it was not having any effect was because the classes I am trying to exclude from the cache are still being cached. Switching on logging for the org.apache.ojb.broker.cache package shows this:

DEBUG org.apache.ojb.broker.cache.MaterializationCache - Push to cache: com.shopformat.customer.Customer{600022}


This is the expected behavior. Internal OJB use three grades of caches:
Materialisation Cache (used while object materialization to avoid endless loops on circular references), first and second level cache (if enabled). Thus the MC is mandatory for correct object materialization.

After materialization the MC push all objects to the ObjectCache implementation.


I am using the following in my class descriptor:

<class-descriptor class="com.shopformat.customer.Customer" table="customer">
<object-cache class="org.apache.ojb.broker.cache.ObjectCacheEmptyImpl"/>
......
</class-descriptor>

In this case class Custom will never be cached (MC push objects to a NOOP-class ObjectCacheEmptyImpl).



I assumed the classes without this line will then fall back on the settings of the ObjectCacheDescriptor that was set programatically.

correct, by default the cache implementation declared on jdbc-connection-descriptor level is used (if not set, ObjectCacheEmptyImpl is used as default cache implementation in ObjectCacheDescriptor).


Can you think of any reason why my Customer class is still being cached? I am getting this log output:

INFO org.apache.ojb.broker.cache.CacheDistributor - Specified cache class org.apache.ojb.broker.cache.ObjectCacheEmptyImpl does not implement interface org.apache.ojb.broker.cache.ObjectCacheInternal and will be wrapped by a helper class

Does that mean that it is ignoring the ObjectCacheEmptyImpl class?


This only mean that it was wrapped by a helper class with additional internal used methods. ObjectCacheEmptyImpl itself will be used for caching.

regards,
Armin

Thanks,

Steve Vangasse

Boardshop.co.uk - Board Sports Equipment and Clothing for the UK and Europe
www.boardshop.co.uk
0870 0600 688



----- Original Message ----- From: "Armin Waibel" <[EMAIL PROTECTED]>
To: "OJB Users List" <ojb-user@db.apache.org>
Sent: Thursday, August 10, 2006 1:55 PM
Subject: Re: Setting ObjectCacheDescriptor programatically


Hi Steve,

this seems to be a bug in the #toXML() method of JdbcConnectionDescriptor (the cascade call to ObjectCacheDescriptor is missing). I will fix this. But this doesn't affect the stability/usability of OJB.

To check the usage of your specified ObjectCacheDescriptor set the log level of class CacheDistributor to DEBUG/INFO (if you use OJB's own simple Logger change entry in OJB-logging.properties).

Then you should get something like:

[org.apache.ojb.broker.cache.CacheDistributor] INFO:
<====
Setup new object cache instance on CONNECTION LEVEL for
PersistenceBroker: [EMAIL PROTECTED]
descriptorBasedCache: false
Connection jcdAlias: default
Calling class: class org.apache.ojb.broker.StoredProcedureTest$Customer
ObjectCache: [EMAIL PROTECTED] org.apache.ojb.broker.cache.ObjectCacheTwoLevelImpl,Properties={autoSync=true, cacheExcludes=, copyStrategy=org.apache.ojb.broker.cache.ObjectCacheTwoLevelImpl$CopyStrategyImpl, cachingKeyType=0, forceProxies=false, timeout=900, applicationCache=org.apache.ojb.broker.cache.ObjectCacheDefaultImpl, useSoftReferences=true}]
====>

Please let me know if this doesn't work.

regards,
Armin

Steve Vangasse wrote:
I'm having trouble setting up a JdbcConnectionDescriptor programatically. I'm adding a ConnectionPoolDescriptor, SequenceDescriptor and an ObjectCacheDescriptor to the JdbcConnectionDescriptor but the ObjectCacheDescriptor doesn't appear when I call JdbcConnectionDescriptor.toXML() and doesn't have any effect when the application is running. Here is my code:

********

JdbcConnectionDescriptor jcd = new JdbcConnectionDescriptor();
jcd.setJcdAlias("mainConnection");
jcd.setDatasourceName("java:comp/env/jdbc/mainConnection");
jcd.setDbms("MySQL");
jcd.setJdbcLevel(3.0);
jcd.setBatchMode(false);
jcd.setUseAutoCommit(1);
jcd.setIgnoreAutoCommitExceptions(false);

ObjectCacheDescriptor ocd = new ObjectCacheDescriptor(ObjectCacheTwoLevelImpl.class); ocd.addAttribute("applicationCache", "org.apache.ojb.broker.cache.ObjectCacheDefaultImpl"); ocd.addAttribute("copyStrategy", "org.apache.ojb.broker.cache.ObjectCacheTwoLevelImpl$CopyStrategyImpl");
ocd.addAttribute("timeout", "900");
ocd.addAttribute("autoSync", "true");
ocd.addAttribute("cachingKeyType", "1");
ocd.addAttribute("useSoftReferences", "true");
log.debug(ocd.toXML());

ConnectionPoolDescriptor cpd = new ConnectionPoolDescriptor();
cpd.setLogAbandoned(true);
cpd.setValidationQuery("SELECT 1");

jcd.setConnectionPoolDescriptor(cpd);
jcd.setObjectCacheDescriptor(ocd);
jcd.setSequenceDescriptor(new SequenceDescriptor(jcd, SequenceManagerNativeImpl.class));
connectionRepository.addDescriptor(jcd);

log.debug(jcd.toXML());
*********

I can't use an XML file for reasons I won't go into here. Can anyone see what I might be doing wrong here? Has anyone else attempted to do this? Any help would be much appreciated.

Thanks,

Steve Vangasse

Boardshop.co.uk - Board Sports Equipment and Clothing for the UK and Europe
www.boardshop.co.uk
0870 0600 688


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to