In my application there are a lot of application scope values (read most, very 
seldom update/insert/delete), things like all Zip Codes in a country, names of 
all agents, etc. They resides in various different tables in the database. I 
want to _always_ cache them in the memory, once and for all, so that other 
stateful beans can use these values without creating new instances of these 
data wrapper class. For example, 


  | @Stateful
  | @Name("fooAction")
  | @Scope(CONVERSATION)
  | public class FooAction implements Serializable, Foo{
  | 
  |   //here i want to load the in-memory data like all zipcodes....
  |   private SomeBean applicationScopeValues;
  |   .....
  | 
  | }
  | 
  | 

What is the best way?

If I use bijection, I would need to create a stateful bean (or stateless, if 
the data is 100% read-only), annotate the application scope, and then in this 
bean, do things like:


  | 
  | @Stateful
  | @Scope(APPLICATION)
  | @Name("dataStore")
  | public class DataStoreImpl implements Serializable, DataStore{
  | 
  |   //how do I get reference of this list from other action beans if I use
  |   // use the @Out here?
  |   private List<Zipcode> allZipcodes; 
  | 
  |   @Create
  |   public void findAllZipcodes(){
  |     String query ="select z from Zipcode z";
  |     this.allZipcodes = entityManager.createQuery(query).getResultList();
  |   }
  | 
  |   //getters and setters
  | }
  | 
  | 

Then in the FooAction class, I would need to do:

  | @In(create=true) private DataStore dataStore;
  | 

Am I doing right this way? Can I avoid creating multiple instances of the 
DataStore this way? 

Any better options? Thanks very much in advance!!


Regards,
Ellen

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

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

Reply via email to