1 Reply Latest reply on Jan 8, 2009 3:56 AM by troy.sellers

    Pojo cache not getting objects out

    troy.sellers

      Hi All,


      I have included the JBoss 1.4 cache and am trying to use the pojo cache.


      From components.xml


      <cache:jboss-pojo-cache-provider configuration="META-INF/treecache.xml"/>




      From action.java



      import org.jboss.cache.aop.PojoCache;
      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Scope;
      import org.jboss.seam.cache.CacheProvider;
      import com.yum.matador.entity.StoreMenu;
      
      @Name("menu")
      @Scope(ScopeType.CONVERSATION)
      public class Menu {
      
          @In CacheProvider<PojoCache> cacheProvider;
      
          
          /**
           * Gets the menu for a particular store. First it tries the cache, if it does not 
           * exist then the menu is retrieved from the Gateway and added to the cache.
           * 
           * @param storeId
           * @return
           * @throws GatewayFault
           * @throws RemoteException
           */
          public StoreMenu getMenu(String storeId) throws GatewayFault, RemoteException {
      
              StoreMenu menu = (StoreMenu)cacheProvider.get("menu", storeId);
              
              if (menu == null) {
                      logger.info("Setting menu object into cache");
                      menu = retrieveMenu(storeId);
                      cacheProvider.put("menu", storeId, menu);
              } else {
                      logger.info("Using cached menu");
              }
              
              return menu;
          }




      When I run my application on first load of page I see the following in the log


      13:13:18,993 WARN  [TreeCache] Using deprecated configuration element 'UseMarshalling'.  See 'UseRegionBasedMarshalling' instead.
      13:13:19,071 INFO  [TreeCache] parseConfig(): PojoCacheConfig is empty
      13:13:20,384 INFO  [Menu] Setting menu object into cache


      When it runs over this code again to get the menu again it doesn't seem to get this out of the cache, but has to create it again.
      13:13:18,993 WARN  [TreeCache] Using deprecated configuration element 'UseMarshalling'.  See 'UseRegionBasedMarshalling' instead.
      13:13:19,071 INFO  [TreeCache] parseConfig(): PojoCacheConfig is empty
      13:13:20,384 INFO  [Menu] Setting menu object into cache


      My Pojo ...



      import java.util.List;
      
      import org.jboss.cache.aop.annotation.PojoCacheable;
      
      @PojoCacheable
      public class StoreMenu {
          private String storeId;
          private List<Variety> pizzaList;
          private List<ProductWrapper> more4AllList;
          private List<ProductWrapper> pastaList;
          private List<ProductWrapper> sidesList;
          private List<ProductWrapper> drinksList;
          
          public StoreMenu(String storeId) {
              this.storeId = storeId;
          }
          
          public String getStoreId() {
              return storeId;
          }
      
          public void setStoreId(String storeId) {
              this.storeId = storeId;
          }
      
          public List<Variety> getPizzaList() {
              return pizzaList;
          }
          
          public void setPizzaList(List<Variety> pizzaList) {
              this.pizzaList = pizzaList;
          }
          
          public List<ProductWrapper> getMore4AllList() {
              return more4AllList;
          }
          
          public void setMore4AllList(List<ProductWrapper> more4AllList) {
              this.more4AllList = more4AllList;
          }
          
          public List<ProductWrapper> getPastaList() {
              return pastaList;
          }
          
          public void setPastaList(List<ProductWrapper> pastaList) {
              this.pastaList = pastaList;
          }
          
          public List<ProductWrapper> getSidesList() {
              return sidesList;
          }
          
          public void setSidesList(List<ProductWrapper> sidesList) {
              this.sidesList = sidesList;
          }
      
          public List<ProductWrapper> getDrinksList() {
              return drinksList;
          }
      
          public void setDrinksList(List<ProductWrapper> drinksList) {
              this.drinksList = drinksList;
          }   
      }



      Can anyone offer some advice on how to figure this one out?


      Cheers,
      Troy