Re: Setting ObjectCacheDescriptor programatically

Armin Waibel <[email protected]>
Newsgroups gmane.comp.jakarta.ojb.user
Message-ID <[email protected]>
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: org.apache.ojb.broker.core.PersistenceBrokerImpl@13c0b53
descriptorBasedCache: false
Connection jcdAlias: default
Calling class: class org.apache.ojb.broker.StoredProcedureTest$Customer
ObjectCache: 
org.apache.ojb.broker.metadata.ObjectCacheDescriptor@1abcc03[ObjectCache=class 
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]
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.