You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by dj...@apache.org on 2006/11/16 16:49:30 UTC
svn commit: r475780 -
/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java
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;