code_junkie

Share static singletons through EJB's

Nov 14th, 2011
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. -CacheService
  2. -CacheServiceBean
  3. -getMyObject()
  4. -insertMyObject(MyObject)
  5. -size()
  6.  
  7. -SomeOtherBean
  8. cache = jndiLookup(CacheService)
  9. cache.insertMyObject(x)
  10. cache.size() -> 1
  11.  
  12. @Stateless
  13. public class CacheSessionBean implements CacheSessionLocal {
  14. private static Map<String, Object> cacheMap = new HashMap<String, Object>();
  15.  
  16. public Object getCache(String key) {
  17. return cacheMap.get(key);
  18. }
  19.  
  20. public void putCache(String key, Object o) {
  21. cacheMap.put(key, o);
  22. }
  23. }
Add Comment
Please, Sign In to add comment