1 4 package com.nightlabs.ipanema.jdo; 5 6 import java.util.Set ; 7 8 import com.nightlabs.ipanema.jdo.cache.Cache; 9 10 13 public abstract class JDOObjectProvider 14 { 15 private Cache cache = Cache.sharedInstance(); 16 17 public JDOObjectProvider() 18 { 19 } 20 21 26 protected Object retrieveJDOObject( 27 String scope, Object objectID, String [] fetchGroups) 28 throws Exception 29 { 30 throw new UnsupportedOperationException ("method 'retrieveJDOObject(String scope, Object objectID, String[] fetchGroups)' not implemented!"); 31 } 32 33 36 protected Object retrieveJDOObject( 37 String scope, Object objectID, Set fetchGroups) 38 throws Exception 39 { 40 throw new UnsupportedOperationException ("method 'retrieveJDOObject(String scope, Object objectID, Set fetchGroups)' not implemented!"); 41 } 42 43 protected synchronized Object getJDOObject( 44 String scope, Object objectID, Set fetchGroups) 45 { 46 try { 47 Object res = cache.get(scope, objectID, fetchGroups); 48 if (res == null) { 49 res = retrieveJDOObject(scope, objectID, fetchGroups); 50 cache.put(scope, objectID, fetchGroups); 51 } 52 return res; 53 } catch (Exception x) { 54 throw new RuntimeException (x); 55 } 56 } 57 58 protected synchronized Object getJDOObject( 59 String scope, Object objectID, String [] fetchGroups) 60 { 61 try { 62 Object res = cache.get(scope, objectID, fetchGroups); 63 if (res == null) { 64 res = retrieveJDOObject(scope, objectID, fetchGroups); 65 cache.put(scope, res, fetchGroups); 66 } 67 return res; 68 } catch (Exception x) { 69 throw new RuntimeException (x); 70 } 71 } 72 73 } 74 | Popular Tags |