felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1029818 - /felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProviderManager.java
Date Mon, 01 Nov 2010 20:07:00 GMT
Author: cziegeler
Date: Mon Nov  1 20:07:00 2010
New Revision: 1029818

URL: http://svn.apache.org/viewvc?rev=1029818&view=rev
Log:
FELIX-2679 : Detect AnnotationTagProvider's through META-INF/services

Modified:
    felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProviderManager.java

Modified: felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProviderManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProviderManager.java?rev=1029818&r1=1029817&r2=1029818&view=diff
==============================================================================
--- felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProviderManager.java
(original)
+++ felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProviderManager.java
Mon Nov  1 20:07:00 2010
@@ -19,8 +19,6 @@
 package org.apache.felix.scrplugin.tags.annotation;
 
 
-import java.security.CodeSource;
-import java.security.ProtectionDomain;
 import java.util.*;
 
 import javax.imageio.spi.ServiceRegistry;
@@ -68,7 +66,7 @@ public class AnnotationTagProviderManage
         while ( serviceIter.hasNext() )
         {
             final AnnotationTagProvider provider = serviceIter.next();
-            this.addProvider(provider, false);
+            this.addProvider(provider);
         }
 
         // add custom providers defined in pom
@@ -86,33 +84,9 @@ public class AnnotationTagProviderManage
     }
 
     /**
-     * Try to get the location (class loader) from the object.
-     */
-    private String getLocation(final Object obj)
-    {
-        try {
-            final ProtectionDomain pd = obj.getClass().getProtectionDomain();
-            if ( pd != null && pd.getCodeSource() != null )
-            {
-                final CodeSource cs = pd.getCodeSource();
-                if ( cs.getLocation() != null )
-                {
-                    return cs.getLocation().toExternalForm();
-                }
-            }
-        }
-        catch (final SecurityException se)
-        {
-            // ignore this
-        }
-        // by default return the class laoder
-        return obj.getClass().getClassLoader().toString();
-    }
-
-    /**
      * Add a provider (if not already available)
      */
-    private void addProvider(final AnnotationTagProvider provider, final boolean silent)
+    private void addProvider(final AnnotationTagProvider provider)
     {
         // check if this provider is already loaded
         final String key = provider.getClass().getName();
@@ -120,21 +94,6 @@ public class AnnotationTagProviderManage
         {
             this.annotationTagProviders.put(key, provider);
         }
-        else
-        {
-            if ( !silent )
-            {
-                // now check if the location of the providers (classloader) is different
-                // and log a warning
-                final AnnotationTagProvider usedProvider = this.annotationTagProviders.get(key);
-                if ( !usedProvider.equals(provider) )
-                {
-                    this.log.warn("Ignoring provider " + provider + " from location " + getLocation(provider)
+
-                            ". Using previously found version from " + getLocation(usedProvider));
-                }
-
-            }
-        }
     }
 
     private void loadProvider( final ClassLoader classLoader, final String className, final
boolean silent )
@@ -146,7 +105,7 @@ public class AnnotationTagProviderManage
             Class<?> clazz = classLoader.loadClass( className );
             try
             {
-                addProvider( ( AnnotationTagProvider ) clazz.newInstance(), silent );
+                addProvider( ( AnnotationTagProvider ) clazz.newInstance() );
             }
             catch ( ClassCastException e )
             {



Mime
View raw message