Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 692AA11748 for ; Fri, 11 Apr 2014 12:13:43 +0000 (UTC) Received: (qmail 49798 invoked by uid 500); 11 Apr 2014 12:13:41 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 49736 invoked by uid 500); 11 Apr 2014 12:13:40 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 49729 invoked by uid 99); 11 Apr 2014 12:13:40 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Apr 2014 12:13:40 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Apr 2014 12:13:39 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 9D0D323888FE; Fri, 11 Apr 2014 12:13:16 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1586621 - /commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/engine/control/CompositeCacheManager.java Date: Fri, 11 Apr 2014 12:13:16 -0000 To: commits@commons.apache.org From: tv@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140411121316.9D0D323888FE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tv Date: Fri Apr 11 12:13:16 2014 New Revision: 1586621 URL: http://svn.apache.org/r1586621 Log: Clean up lifecycle Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/engine/control/CompositeCacheManager.java Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/engine/control/CompositeCacheManager.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/engine/control/CompositeCacheManager.java?rev=1586621&r1=1586620&r2=1586621&view=diff ============================================================================== --- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/engine/control/CompositeCacheManager.java (original) +++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/engine/control/CompositeCacheManager.java Fri Apr 11 12:13:16 2014 @@ -167,6 +167,11 @@ public class CompositeCacheManager instance = createInstance(); } + if (!instance.isInitialized()) + { + instance.initialize(); + } + if (!instance.isConfigured()) { instance.configure( propsFilename ); @@ -195,6 +200,11 @@ public class CompositeCacheManager instance = createInstance(); } + if (!instance.isInitialized()) + { + instance.initialize(); + } + instance.incrementClients(); return instance; @@ -216,7 +226,7 @@ public class CompositeCacheManager */ protected CompositeCacheManager() { - initialize(); + // empty } /** Creates a shutdown hook and starts the scheduler service */ @@ -631,8 +641,6 @@ public class CompositeCacheManager { synchronized (CompositeCacheManager.class) { - isInitialized = false; - // shutdown all scheduled jobs this.scheduledExecutor.shutdownNow(); @@ -671,7 +679,22 @@ public class CompositeCacheManager freeCache( name ); } + if (shutdownHook != null) + { + try + { + Runtime.getRuntime().removeShutdownHook(shutdownHook); + } + catch (IllegalStateException e) + { + // May fail if the JVM is already shutting down + } + + this.shutdownHook = null; + } + isConfigured = false; + isInitialized = false; } } @@ -882,7 +905,7 @@ public class CompositeCacheManager *

* @param props */ - public void setConfigurationProperties( Properties props ) + void setConfigurationProperties( Properties props ) { this.configurationProperties = props; }