Merge branch 'guard-slow-logging' into 'ibm-trunk'
Guard slow logging
See merge request !66
diff --git a/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/ProviderBean.java b/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/ProviderBean.java
index 688ff61..8a8d452 100644
--- a/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/ProviderBean.java
+++ b/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/ProviderBean.java
@@ -20,6 +20,7 @@
package org.apache.yoko.osgi.locator;
+import java.util.logging.Level;
import java.util.logging.Logger;
import org.osgi.framework.Bundle;
@@ -47,7 +48,8 @@
Register providerRegistry,
Integer priority) {
bundleProviderLoader = new BundleProviderLoader(key, className, bundle, priority == null? -1: priority);
- log.finer("ProviderBean: " + bundleProviderLoader);
+ if (log.isLoggable(Level.FINER))
+ log.finer("ProviderBean: " + bundleProviderLoader);
this.providerRegistry = providerRegistry;
}
diff --git a/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/ProviderRegistryImpl.java b/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/ProviderRegistryImpl.java
index 31dfa31..28fa885 100644
--- a/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/ProviderRegistryImpl.java
+++ b/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/ProviderRegistryImpl.java
@@ -55,7 +55,8 @@
* @param provider The loader used to resolve the provider class.
*/
public void registerProvider(BundleProviderLoader provider) {
- log(Level.FINE, "registering provider " + provider);
+ if (log.isLoggable(Level.FINE))
+ log.log(Level.FINE, "registering provider " + provider);
providers.register(provider);
}
@@ -65,7 +66,8 @@
* @param provider The provider registration instance
*/
public void unregisterProvider(BundleProviderLoader provider) {
- log(Level.FINE, "unregistering provider " + provider);
+ if (log.isLoggable(Level.FINE))
+ log.log(Level.FINE, "unregistering provider " + provider);
providers.unregister(provider);
}
@@ -76,7 +78,8 @@
* @param provider The loader used to resolve the provider class.
*/
public void registerService(BundleProviderLoader provider) {
- log(Level.FINE, "registering service " + provider);
+ if (log.isLoggable(Level.FINE))
+ log.log(Level.FINE, "registering service " + provider);
serviceProviders.register(provider);
}
@@ -86,7 +89,8 @@
* @param provider The provider registration instance
*/
public void unregisterService(BundleProviderLoader provider) {
- log(Level.FINE, "unregistering service " + provider);
+ if (log.isLoggable(Level.FINE))
+ log.log(Level.FINE, "unregistering service " + provider);
serviceProviders.unregister(provider);
}
@@ -242,10 +246,6 @@
return null;
}
- private void log(Level level, String message) {
- log.log(level, message);
- }
-
/**
* Holder class for information about a given collection of
* id to provider mappings. Used for both the providers and
@@ -298,7 +298,8 @@
private synchronized BundleProviderLoader getLoader(String id) {
// synchronize on the registry instance
if (registry != null) {
- log.fine("registry: " + registry);
+ if (log.isLoggable(Level.FINE))
+ log.fine("registry: " + registry);
// return the first match, if any
List<BundleProviderLoader> list = registry.get(id);
if (list != null && !list.isEmpty()) {
diff --git a/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/ServiceBean.java b/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/ServiceBean.java
index 7876495..b42f3fe 100644
--- a/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/ServiceBean.java
+++ b/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/ServiceBean.java
@@ -20,6 +20,7 @@
package org.apache.yoko.osgi.locator;
+import java.util.logging.Level;
import java.util.logging.Logger;
import org.osgi.framework.Bundle;
@@ -47,7 +48,8 @@
Register providerRegistry,
Integer priority) {
bundleProviderLoader = new BundleProviderLoader(key, className, bundle, priority == null? -1: priority);
- log.finer("ServiceBean: " + bundleProviderLoader);
+ if (log.isLoggable(Level.FINER))
+ log.finer("ServiceBean: " + bundleProviderLoader);
this.providerRegistry = providerRegistry;
}