felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r572887 - in /felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin: SCRDescriptorMojo.java om/Reference.java
Date Wed, 05 Sep 2007 06:42:20 GMT
Author: cziegeler
Date: Tue Sep  4 23:42:20 2007
New Revision: 572887

URL: http://svn.apache.org/viewvc?rev=572887&view=rev
Log:
Generate bind/unbind only if reference has single cardinality (either optional or required)

Modified:
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Reference.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=572887&r1=572886&r2=572887&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
Tue Sep  4 23:42:20 2007
@@ -514,7 +514,13 @@
             ref.setName(name);
             ref.setInterfacename(type);
             ref.setCardinality(reference.getNamedParameter(Constants.REFERENCE_CARDINALITY));
+            if ( ref.getCardinality() == null ) {
+                ref.setCardinality("1..1");
+            }
             ref.setPolicy(reference.getNamedParameter(Constants.REFERENCE_POLICY));
+            if ( ref.getPolicy() == null ) {
+                ref.setPolicy("static");
+            }
             ref.setTarget(reference.getNamedParameter(Constants.REFERENCE_TARGET));
             final String bindValue = reference.getNamedParameter(Constants.REFERENCE_BIND);
             if ( bindValue != null ) {
@@ -524,23 +530,26 @@
             if ( unbindValue != null ) {
                 ref.setUnbind(unbindValue);
             }
-            // if this is a field we look for the bind/unbind methods
+            // if this is a field with a single cardinality,
+            // we look for the bind/unbind methods
             // and create them if they are not availabe and the component is not abstract
             if ( !component.isAbstract() && this.generateAccessors ) {
                 if ( reference.getField() != null && component.getJavaClassDescription()
instanceof ModifiableJavaClassDescription ) {
-                    boolean createBind = false;
-                    boolean createUnbind = false;
-                    // Only create method if no bind name has been specified
-                    if ( bindValue == null && ref.findMethod(ref.getBind()) == null
) {
-                        // create bind method
-                        createBind = true;
-                    }
-                    if ( unbindValue == null && ref.findMethod(ref.getUnbind()) ==
null ) {
-                        // create unbind method
-                        createUnbind = true;
-                    }
-                    if ( createBind || createUnbind ) {
-                        ((ModifiableJavaClassDescription)component.getJavaClassDescription()).addMethods(name,
type, createBind, createUnbind);
+                    if ( ref.getCardinality().equals("0..1") || ref.getCardinality().equals("1..1")
) {
+                        boolean createBind = false;
+                        boolean createUnbind = false;
+                        // Only create method if no bind name has been specified
+                        if ( bindValue == null && ref.findMethod(ref.getBind()) ==
null ) {
+                            // create bind method
+                            createBind = true;
+                        }
+                        if ( unbindValue == null && ref.findMethod(ref.getUnbind())
== null ) {
+                            // create unbind method
+                            createUnbind = true;
+                        }
+                        if ( createBind || createUnbind ) {
+                            ((ModifiableJavaClassDescription)component.getJavaClassDescription()).addMethods(name,
type, createBind, createUnbind);
+                        }
                     }
                 }
             }

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Reference.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Reference.java?rev=572887&r1=572886&r2=572887&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Reference.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Reference.java Tue Sep
 4 23:42:20 2007
@@ -63,42 +63,55 @@
     public String getName() {
         return this.name;
     }
+
     public void setName(String name) {
         this.name = name;
     }
+
     public String getInterfacename() {
         return this.interfacename;
     }
+
     public void setInterfacename(String interfacename) {
         this.interfacename = interfacename;
     }
+
     public String getTarget() {
         return this.target;
     }
+
     public void setTarget(String target) {
         this.target = target;
     }
+
     public String getCardinality() {
         return this.cardinality;
     }
+
     public void setCardinality(String cardinality) {
         this.cardinality = cardinality;
     }
+
     public String getPolicy() {
         return this.policy;
     }
+
     public void setPolicy(String policy) {
         this.policy = policy;
     }
+
     public String getBind() {
         return this.bind;
     }
+
     public void setBind(String bind) {
         this.bind = bind;
     }
+
     public String getUnbind() {
         return this.unbind;
     }
+
     public void setUnbind(String unbind) {
         this.unbind = unbind;
     }



Mime
View raw message