Caching data from database on a java collaboration
Hi
I implement cache in a java collaboration working with HashMaps. When the first message arrive to java colaboration, this message ititialize a HashMap, the next message use that cache for looking neccesary data.
But when the first message arrive, it take any seconds for initializing hashmap.
I want use static initializers for doing that.
How can I do it?
Thanks on advanced.
Hector
[431 byte] By [
conectora] at [2007-11-26 12:26:45]

# 1
Hi Hector.
The JCD is implemented as a session EJB. As far as I can judge from the deployment descriptor, this is a stateless EJB, which means that caching anything in it is unreliable. The next JCD call can go to other instance of EJB and the first instance may be purged and your cache will disappear.
Taken from ejb-jar.xml
<enterprise-beans >
<session>
<description></description>
<display-name></display-name>
<ejb-name>cmCGPServices_jcdGetAccounts1_XSDService</ejb-name>
<local-home>com.stc.codegen.framework.runtime.DeployedServiceHome</local-home>
<local>com.stc.codegen.framework.runtime.DeployedServiceLocal</local>
<ejb-class>com.stc.codegen.XSDImpl.runtime.ejb.XSDService</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
So my understanding that if you want to cache something you should either write your own _stateful_ session EJB and access it from JCD or use some singleton object again written in pure Java.
Victor
# 3
Hi, ChrisHow can I using hashmaps on static initializers, that is, how can I connect to database in a Java collaboration for caching data, before java collaboration receive the first message?ThanksHector