karaf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guillaume Nodet <gno...@gmail.com>
Subject Re: svn commit: r1038127 - /karaf/trunk/shell/commands/src/main/java/org/apache/karaf/shell/commands/info/InfoBundleTrackerCustomizer.java
Date Tue, 23 Nov 2010 14:26:01 GMT
FWIW, when I have to reformat a file, i tend to use two different
commits (one for remormatting without any change, and another one with
the chagnes), else there's really no way to understand what the commit
do.

On Tue, Nov 23, 2010 at 15:20,  <iocanel@apache.org> wrote:
> Author: iocanel
> Date: Tue Nov 23 14:20:33 2010
> New Revision: 1038127
>
> URL: http://svn.apache.org/viewvc?rev=1038127&view=rev
> Log:
> [KARAF-243] Some statements are now logged as debug.
>
> Modified:
>    karaf/trunk/shell/commands/src/main/java/org/apache/karaf/shell/commands/info/InfoBundleTrackerCustomizer.java
>
> Modified: karaf/trunk/shell/commands/src/main/java/org/apache/karaf/shell/commands/info/InfoBundleTrackerCustomizer.java
> URL: http://svn.apache.org/viewvc/karaf/trunk/shell/commands/src/main/java/org/apache/karaf/shell/commands/info/InfoBundleTrackerCustomizer.java?rev=1038127&r1=1038126&r2=1038127&view=diff
> ==============================================================================
> --- karaf/trunk/shell/commands/src/main/java/org/apache/karaf/shell/commands/info/InfoBundleTrackerCustomizer.java
(original)
> +++ karaf/trunk/shell/commands/src/main/java/org/apache/karaf/shell/commands/info/InfoBundleTrackerCustomizer.java
Tue Nov 23 14:20:33 2010
> @@ -16,10 +16,6 @@
>  */
>  package org.apache.karaf.shell.commands.info;
>
> -import java.util.Dictionary;
> -import java.util.Properties;
> -import java.util.StringTokenizer;
> -
>  import org.osgi.framework.Bundle;
>  import org.osgi.framework.BundleContext;
>  import org.osgi.framework.BundleEvent;
> @@ -28,77 +24,85 @@ import org.osgi.util.tracker.BundleTrack
>  import org.slf4j.Logger;
>  import org.slf4j.LoggerFactory;
>
> +import java.util.Dictionary;
> +import java.util.Properties;
> +import java.util.StringTokenizer;
> +
>  /**
>  * @author splatch
> - * Bundle tracker which check manifest headers for informations.
> + *         Bundle tracker which check manifest headers for informations.
>  */
>  public class InfoBundleTrackerCustomizer implements BundleTrackerCustomizer {
>
> -       /**
> -        * Logger.
> -        */
> -       private Logger logger = LoggerFactory.getLogger(InfoBundleTrackerCustomizer.class);
> -
> -       /**
> -        * Bundle context.
> -        */
> -       private final BundleContext context;
> -
> -       public InfoBundleTrackerCustomizer(BundleContext context) {
> -               this.context = context;
> -       }
> -
> -       /**
> -        * {@inheritDoc}
> -        */
> -       @SuppressWarnings("unchecked")
> -       public Object addingBundle(Bundle bundle, BundleEvent event) {
> -               Dictionary headers = bundle.getHeaders();
> -               String headerEntry = (String) headers.get("Karaf-Info");
> -
> -               InfoProvider provider = createInfo(headerEntry);
> -               if (provider == null) {
> -                       logger.info("Ignore incorrect info {} provided by
bundle {}",
> -                                       headerEntry, bundle.getSymbolicName());
> -                       return null;
> -               }
> -               return bundle.getBundleContext().registerService(InfoProvider.class.getName(),
> -                               provider, null);
> -       }
> -
> -       public void modifiedBundle(Bundle bundle, BundleEvent event, Object object)
{
> -       }
> -
> -       public void removedBundle(Bundle bundle, BundleEvent event, Object object)
{
> -               if (object instanceof ServiceRegistration) {
> -                       ServiceRegistration service = (ServiceRegistration)
object;
> -                       service.unregister();
> -               }
> -       }
> -
> -       private InfoProvider createInfo(String entry) {
> -               if (entry == null) {
> -                       return null;
> -               }
> -
> -               StringTokenizer tokenizer = new StringTokenizer(entry, ";=");
> -               if (tokenizer.countTokens() < 3) {
> -                       return null;
> -               }
> -
> -               String name = tokenizer.nextToken();
> -               Properties properties = new Properties();
> -
> -               do {
> -                       String property = tokenizer.nextToken();
> -                       if (tokenizer.hasMoreTokens()) {
> -                               properties.put(property, tokenizer.nextElement());
> -                       } else {
> -                               logger.debug("Ignore property {} without
value", property);
> -                       }
> -               } while (tokenizer.hasMoreTokens());
> +    /**
> +     * Logger.
> +     */
> +    private Logger logger = LoggerFactory.getLogger(InfoBundleTrackerCustomizer.class);
> +
> +    /**
> +     * Bundle context.
> +     */
> +    private final BundleContext context;
> +
> +    public InfoBundleTrackerCustomizer(BundleContext context) {
> +        this.context = context;
> +    }
> +
> +    /**
> +     * {@inheritDoc}
> +     */
> +    @SuppressWarnings("unchecked")
> +    public Object addingBundle(Bundle bundle, BundleEvent event) {
> +        Dictionary headers = bundle.getHeaders();
> +        String headerEntry = (String) headers.get("Karaf-Info");
> +
> +        InfoProvider provider = createInfo(headerEntry);
> +        if (provider == null) {
> +            if (logger.isDebugEnabled()) {
> +                logger.debug("Ignore incorrect info {} provided by bundle {}",
> +                        headerEntry, bundle.getSymbolicName());
> +            }
> +            return null;
> +        }
> +        return bundle.getBundleContext().registerService(InfoProvider.class.getName(),
> +                provider, null);
> +    }
> +
> +    public void modifiedBundle(Bundle bundle, BundleEvent event, Object object) {
> +    }
> +
> +    public void removedBundle(Bundle bundle, BundleEvent event, Object object) {
> +        if (object instanceof ServiceRegistration) {
> +            ServiceRegistration service = (ServiceRegistration) object;
> +            service.unregister();
> +        }
> +    }
> +
> +    private InfoProvider createInfo(String entry) {
> +        if (entry == null) {
> +            return null;
> +        }
> +
> +        StringTokenizer tokenizer = new StringTokenizer(entry, ";=");
> +        if (tokenizer.countTokens() < 3) {
> +            return null;
> +        }
> +
> +        String name = tokenizer.nextToken();
> +        Properties properties = new Properties();
> +
> +        do {
> +            String property = tokenizer.nextToken();
> +            if (tokenizer.hasMoreTokens()) {
> +                properties.put(property, tokenizer.nextElement());
> +            } else {
> +                if (logger.isDebugEnabled()) {
> +                    logger.debug("Ignore property {} without value", property);
> +                }
> +            }
> +        } while (tokenizer.hasMoreTokens());
>
> -               return new PojoInfoProvider(name, properties);
> -       }
> +        return new PojoInfoProvider(name, properties);
> +    }
>
>  }
>
>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com

Mime
View raw message