1 Reply Latest reply on May 19, 2006 2:37 PM by Phi Nguyen

    TcpCacheServer and TreeCache

    Phi Nguyen Newbie

      How do I configure my TcpCacheServer and TreeCache throught XML file? I seems not to find any example. My TcpCacheServer is running on localhost with port 12121 and the TreeCache associated with it is implemeting the FileCacheLoader. Below is my snip code but doesn't work. Thanks.

      Thread runner = new Thread()
      {
      public void run()
      {
      try {
      System.out.println("Starting TcpCacheServer");
      cache_server=new TcpCacheServer();
      //cache_server.setBindAddress("127.0.0.1");
      //cache_server.setPort(12121);

      config = new PropertyConfigurator();
      config.configure(cache_server, "PrimaryCacheLoader.xml");
      //cache_server.setConfig("PrimaryCacheLoader.xml");
      cache_server.createService();

      System.out.println("connection: " + cache_server.getConnections());
      System.out.println("serverName: " + cache_server.getMBeanServerName());
      System.out.println("cache name: " + cache_server.getCacheName());

      cache_server.startService();


      //register to get invalidation
      //cache_server.getCache().addTreeCacheListener(new TreeCacheListenerImpl(PrimaryCacheObject.this));
      }
      catch(Exception ex) {
      ex.printStackTrace();
      }
      }
      };

        • 1. Re: TcpCacheServer and TreeCache
          Phi Nguyen Newbie

          Got this working by sepearting the config. Below is the code:

          Thread runner = new Thread()
          {
          public void run()
          {
          try {
          System.out.println("Starting TcpCacheServer");
          cache_server=new TcpCacheServer();
          // configure the TcpCacheServer
          config = new PropertyConfigurator();
          config.configure(cache_server, "PrimaryCacheLoader.xml");

          //Create new Cache
          tree = new TreeCache();
          // configure the new TreeCache
          config.configure(tree, "PrimaryTreeCache.xml");
          tree.startService();

          //tree.addTreeCacheListener(listener);
          cache_server.setCache(tree);

          cache_server.createService();
          cache_server.startService();
          }
          catch(Exception ex) {
          ex.printStackTrace();
          }
          }
          };