felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r673333 - in /felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin: SCRDescriptorMojo.java tags/JavaClassDescription.java tags/cl/ClassLoaderJavaClassDescription.java tags/qdox/QDoxJavaClassDescription.java
Date Wed, 02 Jul 2008 09:46:11 GMT
Author: cziegeler
Date: Wed Jul  2 02:46:11 2008
New Revision: 673333

URL: http://svn.apache.org/viewvc?rev=673333&view=rev
Log:
FELIX-618 - Search the import list for a service and test if the class in question implements
the interface.

Modified:
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescription.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaClassDescription.java

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java?rev=673333&r1=673332&r2=673333&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
(original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
Wed Jul  2 02:46:11 2008
@@ -346,7 +346,7 @@
 
         component.setEnabled(Boolean.valueOf(getBoolean(tag, Constants.COMPONENT_ENABLED,
true)));
         component.setFactory(tag.getNamedParameter(Constants.COMPONENT_FACTORY));
-        
+
         // FELIX-593: immediate attribute does not default to true all the
         // times hence we only set it if declared in the tag
         if (tag.getNamedParameter(Constants.COMPONENT_IMMEDIATE) != null) {
@@ -404,13 +404,19 @@
         component.setService(service);
         boolean serviceFactory = false;
         for (int i=0; i < services.length; i++) {
-            String name = services[i].getNamedParameter(Constants.SERVICE_INTERFACE);
+            final String name = services[i].getNamedParameter(Constants.SERVICE_INTERFACE);
             if (StringUtils.isEmpty(name)) {
 
                 this.addInterfaces(service, services[i], description);
             } else {
+                // check if the value points to a class/interface
+                // and search through the imports
+                final JavaClassDescription serviceClass = description.getReferencedClass(name);
+                if ( serviceClass == null ) {
+                    throw new MojoExecutionException("Interface '"+ name + "' in class "
+ description.getName() + " does not point to a valid class/interface.");
+                }
                 final Interface interf = new Interface(services[i]);
-                interf.setInterfacename(name);
+                interf.setInterfacename(serviceClass.getName());
                 service.addInterface(interf);
             }
 

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescription.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescription.java?rev=673333&r1=673332&r2=673333&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescription.java
(original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescription.java
Wed Jul  2 02:46:11 2008
@@ -125,4 +125,15 @@
      * @throws MojoExecutionException
      */
     boolean isA(String type) throws MojoExecutionException;
+
+    /**
+     * Search for the class.
+     * If the referenced name is not fully qualified, the imports
+     * of the class are searched.
+     * @param referencedName
+     * @return The java class description or null
+     * @throws MojoExecutionException
+     */
+    JavaClassDescription getReferencedClass(String referencedName)
+    throws MojoExecutionException;
 }

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java?rev=673333&r1=673332&r2=673333&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java
(original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java
Wed Jul  2 02:46:11 2008
@@ -88,6 +88,14 @@
     }
 
     /**
+     * @see org.apache.felix.scrplugin.tags.JavaClassDescription#getReferencedClass(java.lang.String)
+     */
+    public JavaClassDescription getReferencedClass(String referencedName)
+    throws MojoExecutionException {
+        throw new MojoExecutionException("getDescription not support for this class.");
+    }
+
+    /**
      * @see org.apache.felix.scrplugin.tags.JavaClassDescription#getImplementedInterfaces()
      */
     public JavaClassDescription[] getImplementedInterfaces() throws MojoExecutionException
{

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaClassDescription.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaClassDescription.java?rev=673333&r1=673332&r2=673333&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaClassDescription.java
(original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaClassDescription.java
Wed Jul  2 02:46:11 2008
@@ -203,6 +203,28 @@
     }
 
     /**
+     * @see org.apache.felix.scrplugin.tags.JavaClassDescription#getReferencedClass(java.lang.String)
+     */
+    public JavaClassDescription getReferencedClass(final String referencedName) {
+        String className = referencedName;
+        int pos = className.indexOf('.');
+        if ( pos == -1 ) {
+            className = this.searchImport('.' + referencedName);
+        }
+        if ( className == null ) {
+            if ( pos != -1 ) {
+                return null;
+            }
+            className = this.javaClass.getSource().getPackage() + '.' + referencedName;
+        }
+        try {
+            return this.manager.getJavaClassDescription(className);
+        } catch (MojoExecutionException mee) {
+            return null;
+        }
+    }
+
+    /**
      * @see org.apache.felix.scrplugin.tags.JavaClassDescription#getImplementedInterfaces()
      */
     public JavaClassDescription[] getImplementedInterfaces()



Mime
View raw message