Skip to content
Permalink
Browse files
Guard slow logging
  • Loading branch information
djencks committed May 10, 2016
1 parent 9ca4094 commit 760b9dd2034e50df15fbbc567af8395e28c4373c
Showing 3 changed files with 16 additions and 11 deletions.
@@ -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 @@ public ProviderBean(String key,
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;
}

@@ -55,7 +55,8 @@ public void stop() {
* @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 @@ public void registerProvider(BundleProviderLoader provider) {
* @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 @@ public void unregisterProvider(BundleProviderLoader provider) {
* @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 @@ public void registerService(BundleProviderLoader provider) {
* @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 @@ public Class<?> getServiceClass(String providerId) throws ClassNotFoundException
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 @@ public synchronized void unregister(BundleProviderLoader provider) {
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()) {
@@ -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 @@ public ServiceBean(String key,
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;
}

0 comments on commit 760b9dd

Please sign in to comment.