/*
 *
 * JBoss, the OpenSource J2EE webOS
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package org.jboss.cache.aop;


import org.jboss.cache.PropertyConfigurator;
import org.jboss.cache.aop.PojoCache;

import java.io.InputStreamReader;

/**
 * A standalone dummy server that accepts data from other replicated cache.
 * @deprecated 1.4 User should use the script under tests/script now.
 */
public class Server
{
   PojoCache cache_;

   void initCach() throws Exception
   {
      cache_ = new PojoCache();
      PropertyConfigurator config = new PropertyConfigurator();
      config.configure(cache_, "META-INF/replSync-service.xml"); // read in generic replAsync xml
      cache_.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
      cache_.startService();
   }

   void destroyCache() throws Exception
   {
      cache_.stopService();
      cache_ = null;
   }

   PojoCache getCache()
   {
      return cache_;
   }

   public static void main(String[] args) throws Exception
   {
      Server server = new Server();
      server.initCach();
      boolean isYes = true;
      InputStreamReader reader = new InputStreamReader(System.in);
      while (isYes) {
         System.out.println("To abort hit cntrl-c");
//            System.out.println(server.getCache().printLockInfo());
         try {
            Thread.sleep(10000);
         } catch (Exception ex) {
         }
         ;
      }
      server.destroyCache();
   }
}
