"[EMAIL PROTECTED]" wrote : That looks like it should work.  The cache should 
be participating in the tx as a Synchronization, and when the tx rolls back, 
the cache modifications should roll back.
  | 
  | What specifically do you do in "cacheoperation"?

the session bean method will invoke this method. forgive for the disorder code.

  | 
  |     public String checkAccess(String key1) throws Exception {
  |             String key = key1.substring(0,2);
  |             String value = key1;
  |             String command = key1.substring(2,5);
  |             TreeCache cache = CacheFactory.getCache();
  | 
  |                     
  |                     if("add".equals(command)){
  |                             Address add = 
((Person)cache.get("/test/p1","p1")).getAddress();
  |                             add.setCity(value);             
  |                             cache.put("/test/a1","a1" ,add);
  |                             
  |                             if("pp".equals(key)){
  |                                     
System.out.println("Gettttttttttttttbefore:a1=" + cache.get("/test/a1","a1"));
  |                                     throw new Exception("throw exception 
for rollback");
  |                             }
  | 
  |                     }
  |                     else{
  |                             boolean inCache = cache.exists("/test/" + 
key,key);
  |                             boolean inLoader = 
false;//cache.getCacheLoader().exists(Fqn.fromString("/test/" + key));
  |                             System.out.println("Exists in cache:" + inCache 
+ "     exists in loader:" + inLoader);
  |                             Object o = (cache.get("/test/" + key,key));
  |                             if(o != null)
  |                                     value = o.toString();
  |                             System.out.println("Get:" + key + "=" + value);
  |                     }
  |                      
  | 
  |         System.out.println("Gettttttttttttttafter:a1=" + 
cache.get("/test/a1","a1"));
  | 
  |         return value;
  |     }
  | 
CacheFactory.getCache()

  | 
  |     public static synchronized TreeCache getCache(){
  |             if(CACHE != null) return CACHE;
  |             initCache();
  |             return CACHE;
  |     }
  |     
  | 
  |     private static void initCache(){
  |             try{
  |                     CACHE = new TreeCache();
  |                     PropertyConfigurator pc = new PropertyConfigurator();
  |                     pc.configure(CACHE, "tree-service.xml");
  | 
  |                     CACHE.startService();
  |                     
  |                     Person p1 = new Person();
  |                     p1.setName("P1");
  |                     Person p2 = new Person();
  |                     p2.setName("P2");
  |                     Address add = new Address();
  |                     add.setCity("SZ");
  |                     add.setStreet("NR");
  |                     add.setZip(3009884);
  |                     p1.setAddress(add);
  |                     p2.setAddress(add);
  |                     
  |                     CACHE.put("/test/p1","p1", p1);
  |                     CACHE.put("/test/p2", "p2", p2);
  |                     CACHE.put("/test/a1", "a1",add);
  |             }
  |             catch(Exception e){
  |                     e.printStackTrace();
  |             } 
  |     }
  | 

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3966356#3966356

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3966356
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to