6 Replies Latest reply on Nov 30, 2007 6:48 AM by erkin kanlioglu

    Hot Deployment -Object Cache

    erkin kanlioglu Newbie

      Hi

      How can I develop a small cache without losing hot deployment functionality of JBOSS ? Ans suggestion will be appreciated.

      I'm planing to write code similar to following but it will not assure hot deployment will work properly.... (Example is written by me.. And I know it can written better :) )

      import java.lang.ref.SoftReference;
      import java.util.concurrent.ConcurrentHashMap;

      abstract class BaseClass {
      public abstract String test();
      }

      class AClass extends BaseClass{
      public String test(){
      return "A";
      }
      }

      class BClass extends BaseClass {
      public String test(){
      return "B";
      }
      }


      public class SmallCache{
      private static ConcurrentHashMap<Integer,SoftReference> testMap = new ConcurrentHashMap<Integer, SoftReference>();

      public static BaseClass getInstance(int type){
      SoftReference sf = testMap.get(type);
      if(sf == null)
      {
      switch(type)
      {
      case 1: testMap.put(type, new SoftReference(new AClass()));
      break;
      case 2: testMap.put(type, new SoftReference(new BClass()));
      break;
      default:
      System.out.println("Ignore it for now");
      }
      }

      return sf.get();
      }

      }