Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 47316 invoked from network); 16 Nov 2006 15:50:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Nov 2006 15:50:03 -0000 Received: (qmail 45892 invoked by uid 500); 16 Nov 2006 15:50:13 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 45862 invoked by uid 500); 16 Nov 2006 15:50:13 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 45851 invoked by uid 99); 16 Nov 2006 15:50:13 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Nov 2006 07:50:13 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Nov 2006 07:50:02 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 399B41A9846; Thu, 16 Nov 2006 07:49:30 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r475780 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java Date: Thu, 16 Nov 2006 15:49:30 -0000 To: derby-commits@db.apache.org From: djd@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061116154930.399B41A9846@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: djd Date: Thu Nov 16 07:49:28 2006 New Revision: 475780 URL: http://svn.apache.org/viewvc?view=rev&rev=475780 Log: DERBY-927 (partial) Clean up code related to serviceProviders to aid progress towards merging services and storage factories in the monitor. Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java?view=diff&rev=475780&r1=475779&r2=475780 ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java Thu Nov 16 07:49:28 2006 @@ -75,8 +75,11 @@ import java.io.ByteArrayInputStream; import java.io.PrintStream; +import java.util.Collections; import java.util.Hashtable; import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; import java.util.Properties; import java.util.Enumeration; import java.util.StringTokenizer; @@ -107,9 +110,9 @@ /* Fields */ /** - Hashtable of objects that implement PersistentService keyed by their getType() method. + Hash table of objects that implement PersistentService keyed by their getType() method. */ - Hashtable serviceProviders; + private HashMap serviceProviders = new HashMap(); // Vector of class objects of implementations, found in the System, application // and default (modules.properties) properties @@ -390,7 +393,7 @@ } // bootup all the service providers - bootServiceProviders(); + determineSupportedServiceProviders(); // See if automatic booting of persistent services is required boolean bootAll = Boolean.valueOf(PropertyUtil.getSystemProperty(Property.BOOT_ALL)).booleanValue(); @@ -1230,8 +1233,6 @@ if (ps == null) { report("Class " + possibleModule.getName() + " cannot create instance, module ignored."); } else { - if (serviceProviders == null) - serviceProviders = new Hashtable(3, (float) 1.0); serviceProviders.put(ps.getType(), ps); } return true; @@ -1400,30 +1401,26 @@ ** its getType() method. ** ** Once all the implementations have loaded the service providers - ** are booted. If they fail to boot then they aare discarded. - ** E.g. a marimba service provider may detect that its not in - ** a channel so it refuses to boot. + ** are checked to see if they run in the current environment. */ /** - Boot all the service providers, ie. any module that implemented - PersistentService. Upon entry to this call is the hashtable has - PersistentService objects that have been created but not booted. + * Determine which of the set of service providers (PersistentService objects) + * are supported in the current environment. If a PersistentService + * implementation does not implement ModuleControl then it is assumed + * it does support the current environment. Otherwise the canSupport() + * method makes the determination. Any providers that are not supported + * are removed from the list. */ - protected void bootServiceProviders() { + private void determineSupportedServiceProviders() { - if (serviceProviders == null) { - return; - } - - for (Enumeration e = serviceProviders.keys(); e.hasMoreElements(); ) { + for (Iterator i = serviceProviders.values().iterator(); i.hasNext(); ) { - String serviceType = (String) e.nextElement(); - Object provider = serviceProviders.get(serviceType); + Object provider = i.next(); // see if this provider can live in this environment if (!BaseMonitor.canSupport(provider, (Properties) null)) { - serviceProviders.remove(serviceType); + i.remove(); continue; } } @@ -1436,7 +1433,7 @@ are active and calls bootPersistentServices(PersistentService) to boot all the services that that provider knows about. */ - protected void bootPersistentServices() { + private void bootPersistentServices() { Enumeration e = new ProviderEnumeration( applicationProperties); while (e.hasMoreElements()) { PersistentService provider = (PersistentService) e.nextElement(); @@ -2102,7 +2099,8 @@ class ProviderEnumeration implements Enumeration { - private Enumeration serviceProvidersKeys = (serviceProviders == null) ? null : serviceProviders.keys(); + private Enumeration serviceProvidersKeys = (serviceProviders == null) ? null : + Collections.enumeration(serviceProviders.keySet()); private Properties startParams; private Enumeration paramEnumeration; private boolean enumeratedDirectoryProvider;