[infinispan-commits] Infinispan SVN: r1121 - trunk/demos/ec2/src/main/java/org/infinispan/ec2demo.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Wed Nov 11 01:40:57 EST 2009


Author: noelo
Date: 2009-11-11 01:40:57 -0500 (Wed, 11 Nov 2009)
New Revision: 1121

Modified:
   trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/CacheBuilder.java
Log:
Removed shutdown hook 


Modified: trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/CacheBuilder.java
===================================================================
--- trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/CacheBuilder.java	2009-11-10 20:01:21 UTC (rev 1120)
+++ trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/CacheBuilder.java	2009-11-11 06:40:57 UTC (rev 1121)
@@ -3,12 +3,14 @@
  */
 package org.infinispan.ec2demo;
 
+import org.infinispan.Cache;
 import org.infinispan.config.Configuration;
 import org.infinispan.config.GlobalConfiguration;
 import org.infinispan.manager.CacheManager;
 import org.infinispan.manager.DefaultCacheManager;
 import org.infinispan.remoting.transport.jgroups.JGroupsTransport;
-
+import org.infinispan.util.logging.Log;
+import org.infinispan.util.logging.LogFactory;
 import java.io.IOException;
 import java.util.Properties;
 
@@ -16,52 +18,57 @@
  * @author noconnor at redhat.com
  */
 public class CacheBuilder {
-   private CacheManager cache_manager;
+	private CacheManager cache_manager;
+	private static final Log myLogger = LogFactory.getLog(CacheBuilder.class);
 
-   public CacheBuilder(String configFile) throws IOException {
-      String jGroupsFile = System.getProperty("EC2Demo-jgroups-config");
-      if (jGroupsFile == null)
-         throw new RuntimeException("Need to set system property EC2Demo-jgroups-config to point to the jgroups configuration file");
+	public CacheBuilder(String configFile) throws IOException {
+		myLogger.debug("CacheBuilder called with "+configFile);
+		if ((configFile==null)||(configFile.isEmpty()))
+			configFile = System.getProperty("EC2Demo-jgroups-config");
+		
+		if ((configFile==null)||(configFile.isEmpty()))
+			throw new RuntimeException(
+					"Need to either set system property EC2Demo-jgroups-config to point to the jgroups configuration file or pass in the the location of the jgroups configuration file");
 
-      GlobalConfiguration gc = GlobalConfiguration.getClusteredDefault();
-      gc.setClusterName("infinispan-demo-cluster");
-      gc.setTransportClass(JGroupsTransport.class.getName());
-      Properties p = new Properties();
-      p.setProperty("configurationFile", jGroupsFile);
-      gc.setTransportProperties(p);
+		GlobalConfiguration gc = GlobalConfiguration.getClusteredDefault();
+		gc.setClusterName("infinispan-demo-cluster");
+		gc.setTransportClass(JGroupsTransport.class.getName());
+		Properties p = new Properties();
+		p.setProperty("configurationFile", configFile);
+		gc.setTransportProperties(p);
 
-      Configuration c = new Configuration();
-      c.setCacheMode(Configuration.CacheMode.DIST_SYNC);
-      c.setExposeJmxStatistics(true);
-      c.setUnsafeUnreliableReturnValues(true);
-      c.setNumOwners(3);
-      c.setL1CacheEnabled(true);
-      c.setInvocationBatchingEnabled(true);
-      c.setUseReplQueue(true);
-      c.setL1Lifespan(6000000);
-      cache_manager = new DefaultCacheManager(gc, c, false);
-      ShutdownHook shutdownHook = new ShutdownHook(cache_manager);
-      Runtime.getRuntime().addShutdownHook(shutdownHook);
-   }
+		Configuration c = new Configuration();
+		c.setCacheMode(Configuration.CacheMode.DIST_SYNC);
+		c.setExposeJmxStatistics(true);
+		c.setUnsafeUnreliableReturnValues(true);
+		c.setNumOwners(3);
+		c.setL1CacheEnabled(true);
+		c.setInvocationBatchingEnabled(true);
+		c.setUseReplQueue(true);
+		c.setL1Lifespan(6000000);
+		cache_manager = new DefaultCacheManager(gc, c, false);
+		//ShutdownHook shutdownHook = new ShutdownHook(cache_manager);
+		//Runtime.getRuntime().addShutdownHook(shutdownHook);
+	}
 
-   public CacheManager getCacheManager() {
-      return this.cache_manager;
-   }
+	public CacheManager getCacheManager() {
+		return this.cache_manager;
+	}
 
 }
 
 class ShutdownHook extends Thread {
-   private CacheManager currCache;
+	private CacheManager currCache;
 
-   /**
-    * @param cache_manager
-    */
-   public ShutdownHook(CacheManager cache_manager) {
-      currCache = cache_manager;
-   }
+	/**
+	 * @param cache_manager
+	 */
+	public ShutdownHook(CacheManager cache_manager) {
+		currCache = cache_manager;
+	}
 
-   public void run() {
-      System.out.println("Shutting down Cache Manager");
-      currCache.stop();
-   }
+	public void run() {
+		System.out.println("Shutting down Cache Manager");
+		currCache.stop();
+	}
 }



More information about the infinispan-commits mailing list