You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2009/07/13 09:18:41 UTC

svn commit: r793474 - in /felix/trunk: scr-annotations/src/main/java/org/apache/felix/scr/annotations/ scrplugin/src/main/java/org/apache/felix/scrplugin/ scrplugin/src/main/java/org/apache/felix/scrplugin/om/ scrplugin/src/main/java/org/apache/felix/s...

Author: cziegeler
Date: Mon Jul 13 07:18:41 2009
New Revision: 793474

URL: http://svn.apache.org/viewvc?rev=793474&view=rev
Log:
FELIX-1229 : Add support for new modified method.

Added:
    felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Modified.java   (with props)
Modified:
    felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Activate.java
    felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Deactivate.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/Constants.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java

Modified: felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Activate.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Activate.java?rev=793474&r1=793473&r2=793474&view=diff
==============================================================================
--- felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Activate.java (original)
+++ felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Activate.java Mon Jul 13 07:18:41 2009
@@ -25,7 +25,7 @@
  * to activate the component.
  * Please note that this annotation only marks the method name which is
  * put into the configuration. The DS implementation will still use its
- * search strategy to find the method.
+ * search strategy to find the method based on the name.
  */
 @Target( { ElementType.METHOD })
 @Retention(RetentionPolicy.SOURCE)

Modified: felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Deactivate.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Deactivate.java?rev=793474&r1=793473&r2=793474&view=diff
==============================================================================
--- felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Deactivate.java (original)
+++ felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Deactivate.java Mon Jul 13 07:18:41 2009
@@ -25,7 +25,7 @@
  * to deactivate the component.
  * Please note that this annotation only marks the method name which is
  * put into the configuration. The DS implementation will still use its
- * search strategy to find the method.
+ * search strategy to find the method based on the name.
  */
 @Target( { ElementType.METHOD })
 @Retention(RetentionPolicy.SOURCE)

Added: felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Modified.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Modified.java?rev=793474&view=auto
==============================================================================
--- felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Modified.java (added)
+++ felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Modified.java Mon Jul 13 07:18:41 2009
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.scr.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ * The <code>Modified</code> annotation defines the method which is used
+ * to update the component.
+ * Please note that this annotation only marks the method name which is
+ * put into the configuration. The DS implementation will still use its
+ * search strategy to find the method based on the name.
+ */
+@Target( { ElementType.METHOD })
+@Retention(RetentionPolicy.SOURCE)
+@Documented
+public @interface Modified {
+
+}

Propchange: felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Modified.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Modified.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Modified.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/Constants.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/Constants.java?rev=793474&r1=793473&r2=793474&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/Constants.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/Constants.java Mon Jul 13 07:18:41 2009
@@ -68,6 +68,9 @@
     // The component activate method name (V1.1)
     public static final String COMPONENT_DEACTIVATE = "deactivate";
 
+    // The component modified method name (V1.1)
+    public static final String COMPONENT_MODIFIED = "modified";
+
     public static final String PROPERTY = "scr.property";
 
     public static final String PROPERTY_NAME = "name";

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=793474&r1=793473&r2=793474&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 Mon Jul 13 07:18:41 2009
@@ -485,6 +485,10 @@
             component.setSpecVersion(Constants.VERSION_1_1);
             component.setDeactivate(tag.getNamedParameter(Constants.COMPONENT_DEACTIVATE));
         }
+        if ( tag.getNamedParameter(Constants.COMPONENT_MODIFIED) != null ) {
+            component.setSpecVersion(Constants.VERSION_1_1);
+            component.setModified(tag.getNamedParameter(Constants.COMPONENT_MODIFIED));
+        }
 
         // whether metatype information is to generated for the component
         final String metaType = tag.getNamedParameter(Constants.COMPONENT_METATYPE);

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java?rev=793474&r1=793473&r2=793474&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java Mon Jul 13 07:18:41 2009
@@ -72,6 +72,9 @@
     /** Deactivation method. (V1.1) */
     protected String deactivate;
 
+    /** Modified method. (V1.1) */
+    protected String modified;
+
     /** The spec version. */
     protected int specVersion;
 
@@ -231,6 +234,21 @@
     public void setActivate(final String value) {
         this.activate = value;
     }
+
+    /**
+     * Set the name of the modified method (or null for default)
+     */
+    public void setModified(final String value) {
+        this.modified = value;
+    }
+
+    /**
+     * Get the name of the modified method (or null for default)
+     */
+    public String getModified() {
+        return this.modified;
+    }
+
     /**
      * Validate the component description.
      * If errors occur a message is added to the issues list,
@@ -269,6 +287,9 @@
                     this.checkLifecycleMethod(specVersion, javaClass, activateName, true, iLog);
                     this.checkLifecycleMethod(specVersion, javaClass, deactivateName, false, iLog);
 
+                    if ( this.modified != null && specVersion == Constants.VERSION_1_1 ) {
+                        this.checkLifecycleMethod(specVersion, javaClass, this.modified, true, iLog);
+                    }
                     // ensure public default constructor
                     boolean constructorFound = true;
                     JavaMethod[] methods = javaClass.getMethods();

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java?rev=793474&r1=793473&r2=793474&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java Mon Jul 13 07:18:41 2009
@@ -139,6 +139,9 @@
                 if ( a.getType().getJavaClass().getFullyQualifiedName().equals(Deactivate.class.getName()) ) {
                     map.put(Constants.COMPONENT_DEACTIVATE, jm.getName());
                 }
+                if ( a.getType().getJavaClass().getFullyQualifiedName().equals(Modified.class.getName()) ) {
+                    map.put(Constants.COMPONENT_MODIFIED, jm.getName());
+                }
             }
         }
 

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java?rev=793474&r1=793473&r2=793474&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java Mon Jul 13 07:18:41 2009
@@ -75,12 +75,15 @@
     /** Component: The name attribute. */
     private static final String COMPONENT_ATTR_NAME = "name";
 
-    /** Component: The immediate attribute. */
+    /** Component: The activate attribute. */
     private static final String COMPONENT_ATTR_ACTIVATE = "activate";
 
-    /** Component: The immediate attribute. */
+    /** Component: The deactivate attribute. */
     private static final String COMPONENT_ATTR_DEACTIVATE = "deactivate";
 
+    /** Component: The modified attribute. */
+    private static final String COMPONENT_ATTR_MODIFIED = "modified";
+
     private static final String IMPLEMENTATION = "implementation";
 
     private static final String IMPLEMENTATION_QNAME = IMPLEMENTATION;
@@ -190,6 +193,7 @@
             IOUtils.addAttribute(ai, COMPONENT_ATTR_POLICY, component.getConfigurationPolicy());
             IOUtils.addAttribute(ai, COMPONENT_ATTR_ACTIVATE, component.getActivate());
             IOUtils.addAttribute(ai, COMPONENT_ATTR_DEACTIVATE, component.getDeactivate());
+            IOUtils.addAttribute(ai, COMPONENT_ATTR_MODIFIED, component.getModified());
         }
 
         IOUtils.indent(contentHandler, 1);
@@ -415,6 +419,7 @@
                         this.currentComponent.setConfigurationPolicy(attributes.getValue(COMPONENT_ATTR_POLICY));
                         this.currentComponent.setActivate(attributes.getValue(COMPONENT_ATTR_ACTIVATE));
                         this.currentComponent.setDeactivate(attributes.getValue(COMPONENT_ATTR_DEACTIVATE));
+                        this.currentComponent.setModified(attributes.getValue(COMPONENT_ATTR_MODIFIED));
                     }
                 } else if (localName.equals(IMPLEMENTATION)) {
                     // Set the implementation class name (mandatory)