geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r765267 - in /geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint: context/ reflect/
Date Wed, 15 Apr 2009 16:45:06 GMT
Author: gawor
Date: Wed Apr 15 16:45:06 2009
New Revision: 765267

URL: http://svn.apache.org/viewvc?rev=765267&view=rev
Log:
added Rick's copy constructors

Added:
    geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/MetadataUtil.java
  (with props)
Modified:
    geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/context/Parser.java
    geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ArrayValueImpl.java
    geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/BindingListenerMetadataImpl.java
    geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/CollectionBasedServiceReferenceComponentMetadataImpl.java
    geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ComponentMetadataImpl.java
    geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ComponentValueImpl.java
    geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ConstructorInjectionMetadataImpl.java
    geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ListValueImpl.java
    geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/LocalComponentMetadataImpl.java
    geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/MapValueImpl.java
    geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/MethodInjectionMetadataImpl.java
    geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ParameterSpecificationImpl.java
    geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/PropertiesValueImpl.java
    geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/PropertyInjectionMetadataImpl.java
    geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ReferenceNameValueImpl.java
    geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ReferenceValueImpl.java
    geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/RegistrationListenerMetadataImpl.java
    geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ServiceExportComponentMetadataImpl.java
    geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ServiceReferenceComponentMetadataImpl.java
    geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/SetValueImpl.java
    geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/TypedStringValueImpl.java
    geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/UnaryServiceReferenceComponentMetadataImpl.java

Modified: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/context/Parser.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/context/Parser.java?rev=765267&r1=765266&r2=765267&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/context/Parser.java
(original)
+++ geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/context/Parser.java
Wed Apr 15 16:45:06 2009
@@ -566,7 +566,7 @@
         String keyType = element.hasAttribute(KEY_TYPE_ATTRIBUTE) ? element.getAttribute(KEY_TYPE_ATTRIBUTE)
: null;
         String valueType = element.hasAttribute(VALUE_TYPE_ATTRIBUTE) ? element.getAttribute(VALUE_TYPE_ATTRIBUTE)
: null;
         // Parse elements
-        Map<Object, Object> map = new HashMap<Object, Object>();
+        Map<Value, Value> map = new HashMap<Value, Value>();
         NodeList nl = element.getChildNodes();
         for (int i = 0; i < nl.getLength(); i++) {
             Node node = nl.item(i);
@@ -580,7 +580,7 @@
         return new MapValueImpl(keyType, valueType, map);
     }
 
-    private void parseMapEntry(Map<Object, Object> map, Element element, ComponentMetadata
enclosingComponent) {
+    private void parseMapEntry(Map<Value, Value> map, Element element, ComponentMetadata
enclosingComponent) {
         // Parse attributes
         String key = element.hasAttribute(KEY_ATTRIBUTE) ? element.getAttribute(KEY_ATTRIBUTE)
: null;
         String keyRef = element.hasAttribute(KEY_REF_ATTRIBUTE) ? element.getAttribute(KEY_REF_ATTRIBUTE)
: null;

Modified: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ArrayValueImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ArrayValueImpl.java?rev=765267&r1=765266&r2=765267&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ArrayValueImpl.java
(original)
+++ geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ArrayValueImpl.java
Wed Apr 15 16:45:06 2009
@@ -40,6 +40,17 @@
         this.valueType = valueType;
     }
 
+    public ArrayValueImpl(ArrayValue source) {
+        Value[] valueArray = source.getArray();
+
+        array = new Value[valueArray.length];
+        for (int i = 0; i < valueArray.length; i++) {
+            array[i] = MetadataUtil.cloneValue(valueArray[i]);
+        }
+
+        valueType = source.getValueType();
+    }
+    
     public Value[] getArray() {
         return array;
     }

Modified: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/BindingListenerMetadataImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/BindingListenerMetadataImpl.java?rev=765267&r1=765266&r2=765267&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/BindingListenerMetadataImpl.java
(original)
+++ geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/BindingListenerMetadataImpl.java
Wed Apr 15 16:45:06 2009
@@ -42,6 +42,12 @@
         this.unbindMethodName = unbindMethodName;
     }
 
+    public BindingListenerMetadataImpl(BindingListenerMetadata source) {
+        listenerComponent = MetadataUtil.cloneValue(source.getListenerComponent());
+        bindMethodName = source.getBindMethodName();
+        unbindMethodName = source.getUnbindMethodName();
+    }
+    
     public Value getListenerComponent() {
         return listenerComponent;
     }

Modified: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/CollectionBasedServiceReferenceComponentMetadataImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/CollectionBasedServiceReferenceComponentMetadataImpl.java?rev=765267&r1=765266&r2=765267&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/CollectionBasedServiceReferenceComponentMetadataImpl.java
(original)
+++ geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/CollectionBasedServiceReferenceComponentMetadataImpl.java
Wed Apr 15 16:45:06 2009
@@ -34,6 +34,17 @@
     private int orderingComparisonBasis;
     private int memberType;
 
+    public CollectionBasedServiceReferenceComponentMetadataImpl() {        
+    }
+    
+    public CollectionBasedServiceReferenceComponentMetadataImpl(CollectionBasedServiceReferenceComponentMetadata
source) {
+        super(source);
+        comparator = MetadataUtil.cloneValue(source.getComparator());
+        collectionType = source.getCollectionType();
+        orderingComparisonBasis = source.getOrderingComparisonBasis();
+        memberType = source.getMemberType();
+    }
+    
     public Class getCollectionType() {
         return collectionType;
     }

Modified: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ComponentMetadataImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ComponentMetadataImpl.java?rev=765267&r1=765266&r2=765267&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ComponentMetadataImpl.java
(original)
+++ geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ComponentMetadataImpl.java
Wed Apr 15 16:45:06 2009
@@ -40,7 +40,9 @@
     
     protected ComponentMetadataImpl(ComponentMetadata source) {
         name = source.getName();
-        explicitDependencies = new HashSet<String>(source.getExplicitDependencies());
+        if (source.getExplicitDependencies() != null) {
+            explicitDependencies = new HashSet<String>(source.getExplicitDependencies());
+        }
     }
     
     public String getName() {

Modified: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ComponentValueImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ComponentValueImpl.java?rev=765267&r1=765266&r2=765267&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ComponentValueImpl.java
(original)
+++ geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ComponentValueImpl.java
Wed Apr 15 16:45:06 2009
@@ -18,9 +18,8 @@
  */
 package org.apache.felix.blueprint.reflect;
 
-import org.osgi.service.blueprint.reflect.ComponentValue;
-import org.osgi.service.blueprint.reflect.LocalComponentMetadata;
 import org.osgi.service.blueprint.reflect.ComponentMetadata;
+import org.osgi.service.blueprint.reflect.ComponentValue;
 
 /**
  * TODO: javadoc
@@ -39,6 +38,10 @@
         this.metadata = metadata;
     }
 
+    public ComponentValueImpl(ComponentValue source) {
+        metadata = MetadataUtil.cloneComponentMetadata(source.getComponentMetadata());
+    }
+
     public ComponentMetadata getComponentMetadata() {
         return metadata;
     }

Modified: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ConstructorInjectionMetadataImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ConstructorInjectionMetadataImpl.java?rev=765267&r1=765266&r2=765267&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ConstructorInjectionMetadataImpl.java
(original)
+++ geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ConstructorInjectionMetadataImpl.java
Wed Apr 15 16:45:06 2009
@@ -19,6 +19,7 @@
 package org.apache.felix.blueprint.reflect;
 
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
 import java.util.ArrayList;
 
@@ -43,6 +44,16 @@
         this.parameterSpecifications = parameterSpecifications;
     }
 
+    public ConstructorInjectionMetadataImpl(ConstructorInjectionMetadata source) {
+        if (source.getParameterSpecifications() != null) {
+            parameterSpecifications = new ArrayList<ParameterSpecification>();
+            Iterator i = source.getParameterSpecifications().iterator();
+            while (i.hasNext()) {
+                parameterSpecifications.add(new ParameterSpecificationImpl((ParameterSpecification)i.next()));
+            }
+        }
+    }
+    
     public List<ParameterSpecification> getParameterSpecifications() {
         return Collections.unmodifiableList(parameterSpecifications);
     }

Modified: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ListValueImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ListValueImpl.java?rev=765267&r1=765266&r2=765267&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ListValueImpl.java
(original)
+++ geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ListValueImpl.java
Wed Apr 15 16:45:06 2009
@@ -18,6 +18,8 @@
  */
 package org.apache.felix.blueprint.reflect;
 
+import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 
 import org.osgi.service.blueprint.reflect.ListValue;
@@ -41,7 +43,18 @@
         this.valueType = valueType;
         this.list = list;
     }
-
+    
+    public ListValueImpl(ListValue source) {
+        if (source.getList() != null) {
+            list = new ArrayList<Value>();
+            Iterator i = source.getList().iterator();
+            while (i.hasNext()) {
+                list.add(MetadataUtil.cloneValue((Value)i.next()));
+            }
+        }
+        valueType = source.getValueType();
+    }
+    
     public String getValueType() {
         return valueType;
     }

Modified: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/LocalComponentMetadataImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/LocalComponentMetadataImpl.java?rev=765267&r1=765266&r2=765267&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/LocalComponentMetadataImpl.java
(original)
+++ geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/LocalComponentMetadataImpl.java
Wed Apr 15 16:45:06 2009
@@ -21,6 +21,7 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Iterator;
 
 import org.osgi.service.blueprint.reflect.ConstructorInjectionMetadata;
 import org.osgi.service.blueprint.reflect.LocalComponentMetadata;
@@ -44,7 +45,6 @@
     private String destroyMethodName;
     private ConstructorInjectionMetadataImpl constructorInjectionMetadata;
     private Collection<PropertyInjectionMetadata> propertyInjectionMetadata;
-    private Collection<MethodInjectionMetadata> methodInjectionMetadata;
     private MethodInjectionMetadata factoryMethodMetadata;
     private Value factoryComponent;
 
@@ -60,6 +60,20 @@
         className = source.getClassName();
         scope = source.getScope();
         isLazy = source.isLazy();
+        if (source.getConstructorInjectionMetadata() != null) {
+            constructorInjectionMetadata = new ConstructorInjectionMetadataImpl(source.getConstructorInjectionMetadata());
+        }
+        if (source.getFactoryMethodMetadata() != null) {
+            factoryMethodMetadata = new MethodInjectionMetadataImpl(source.getFactoryMethodMetadata());
+        }
+        factoryComponent = MetadataUtil.cloneValue(source.getFactoryComponent());    
+        if (source.getPropertyInjectionMetadata() != null) {
+            propertyInjectionMetadata = new ArrayList<PropertyInjectionMetadata>();
       
+            Iterator propertySource = source.getPropertyInjectionMetadata().iterator();
+            while (propertySource.hasNext()) {
+                propertyInjectionMetadata.add(new PropertyInjectionMetadataImpl((PropertyInjectionMetadata)propertySource.next()));
+            }
+        }
     }
     
     public String getClassName() {
@@ -94,14 +108,6 @@
         return Collections.unmodifiableCollection(propertyInjectionMetadata);
     }
 
-    public Collection<MethodInjectionMetadata> getMethodInjectionMetadata() {
-        return Collections.unmodifiableCollection(methodInjectionMetadata);
-    }
-
-    public void setMethodInjectionMetadata(Collection<MethodInjectionMetadata> methodInjectionMetadata)
{
-        this.methodInjectionMetadata = methodInjectionMetadata;
-    }
-
     public boolean isLazy() {
         return isLazy;
     }

Modified: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/MapValueImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/MapValueImpl.java?rev=765267&r1=765266&r2=765267&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/MapValueImpl.java
(original)
+++ geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/MapValueImpl.java
Wed Apr 15 16:45:06 2009
@@ -18,9 +18,13 @@
  */
 package org.apache.felix.blueprint.reflect;
 
+import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import org.osgi.service.blueprint.reflect.MapValue;
+import org.osgi.service.blueprint.reflect.Value;
 
 /**
  * TODO: javadoc
@@ -32,17 +36,31 @@
 
     private String keyType;
     private String valueType;
-    private Map<Object, Object> map;
+    private Map<Value, Value> map;
 
     public MapValueImpl() {
     }
 
-    public MapValueImpl(String keyType, String valueType, Map<Object, Object> map)
{
+    public MapValueImpl(String keyType, String valueType, Map<Value, Value> map) {
         this.keyType = keyType;
         this.valueType = valueType;
         this.map = map;
     }
 
+    public MapValueImpl(MapValue source) {
+        if (source.getMap() != null) {
+            map = new HashMap<Value, Value>();
+            // both the values and the keys are Value types, so we need to deep copy them
+            Iterator i = source.getMap().entrySet().iterator();
+            while (i.hasNext()) {
+                Entry entry = (Entry)i.next();
+                map.put(MetadataUtil.cloneValue((Value)entry.getKey()), MetadataUtil.cloneValue((Value)entry.getValue()));
+            }
+        }
+        valueType = source.getValueType();
+        keyType = source.getKeyType();
+    }
+    
     public String getKeyType() {
         return keyType;
     }
@@ -59,11 +77,11 @@
         this.valueType = valueType;
     }
 
-    public Map<Object, Object> getMap() {
+    public Map<Value, Value> getMap() {
         return map;
     }
 
-    public void setMap(Map<Object, Object> map) {
+    public void setMap(Map<Value, Value> map) {
         this.map = map;
     }
 }

Added: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/MetadataUtil.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/MetadataUtil.java?rev=765267&view=auto
==============================================================================
--- geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/MetadataUtil.java
(added)
+++ geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/MetadataUtil.java
Wed Apr 15 16:45:06 2009
@@ -0,0 +1,120 @@
+/**
+ *  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.blueprint.reflect;
+
+import org.osgi.service.blueprint.reflect.ArrayValue;
+import org.osgi.service.blueprint.reflect.CollectionBasedServiceReferenceComponentMetadata;
+import org.osgi.service.blueprint.reflect.ComponentMetadata;
+import org.osgi.service.blueprint.reflect.ComponentValue;
+import org.osgi.service.blueprint.reflect.ListValue;
+import org.osgi.service.blueprint.reflect.LocalComponentMetadata;
+import org.osgi.service.blueprint.reflect.MapValue;
+import org.osgi.service.blueprint.reflect.NullValue;
+import org.osgi.service.blueprint.reflect.PropertiesValue;
+import org.osgi.service.blueprint.reflect.ReferenceNameValue;
+import org.osgi.service.blueprint.reflect.ReferenceValue;
+import org.osgi.service.blueprint.reflect.ServiceExportComponentMetadata;
+import org.osgi.service.blueprint.reflect.SetValue;
+import org.osgi.service.blueprint.reflect.TypedStringValue;
+import org.osgi.service.blueprint.reflect.UnaryServiceReferenceComponentMetadata;
+import org.osgi.service.blueprint.reflect.Value;
+
+
+/**
+ * A utility class that handles cloning various polymorphic
+ * bits of metadata into concrete class implementations.
+ */
+public class MetadataUtil {
+    
+    static public Value cloneValue(Value source) {
+        if (source == null) {
+            return null;
+        } 
+        else if (source instanceof ArrayValue) {
+            return new ArrayValueImpl((ArrayValue)source);
+        }
+        else if (source instanceof ComponentValue) {
+            return new ComponentValueImpl((ComponentValue)source);
+        }
+        else if (source instanceof ListValue) {
+            return new ListValueImpl((ListValue)source);
+        }
+        else if (source instanceof SetValue) {
+            return new SetValueImpl((SetValue)source);
+        }
+        else if (source instanceof MapValue) {
+            return new MapValueImpl((MapValue)source);
+        }
+        else if (source instanceof NullValue) {
+            return NullValue.NULL;
+        }
+        else if (source instanceof PropertiesValue) {
+            return new PropertiesValueImpl((PropertiesValue)source);
+        }
+        else if (source instanceof PropertiesValue) {
+            return new PropertiesValueImpl((PropertiesValue)source);
+        }
+        else if (source instanceof ReferenceNameValue) {
+            return new ReferenceNameValueImpl((ReferenceNameValue)source);
+        }
+        else if (source instanceof ReferenceValue) {
+            return new ReferenceValueImpl((ReferenceValue)source);
+        }
+        else if (source instanceof TypedStringValue) {
+            return new TypedStringValueImpl((TypedStringValue)source);
+        }
+
+        throw new RuntimeException("Unknown Value type received: " + source.getClass().getName());
+    }
+
+
+    /**
+     * Clone a component metadata item, returning a mutable
+     * instance.
+     *
+     * @param source The source metadata item.
+     *
+     * @return A mutable instance of this metadata item.
+     */
+    static public ComponentMetadata cloneComponentMetadata(ComponentMetadata source) {
+        if (source == null) {
+            return null;
+        } else if (source instanceof LocalComponentMetadata) {
+            return new LocalComponentMetadataImpl((LocalComponentMetadata)source);
+        }
+        else if (source instanceof CollectionBasedServiceReferenceComponentMetadata) {
+            return new CollectionBasedServiceReferenceComponentMetadataImpl((CollectionBasedServiceReferenceComponentMetadata)source);
+        }
+        else if (source instanceof CollectionBasedServiceReferenceComponentMetadata) {
+            return new CollectionBasedServiceReferenceComponentMetadataImpl((CollectionBasedServiceReferenceComponentMetadata)source);
+        }
+        else if (source instanceof ServiceExportComponentMetadata) {
+            return new ServiceExportComponentMetadataImpl((ServiceExportComponentMetadata)source);
+        }
+        else if (source instanceof ServiceExportComponentMetadata) {
+            return new ServiceExportComponentMetadataImpl((ServiceExportComponentMetadata)source);
+        }
+        else if (source instanceof UnaryServiceReferenceComponentMetadata) {
+            return new UnaryServiceReferenceComponentMetadataImpl((UnaryServiceReferenceComponentMetadata)source);
+        }
+
+        throw new RuntimeException("Unknown ComponentMetadata type received: " + source.getClass().getName());
+    }
+
+}
+

Propchange: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/MetadataUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/MetadataUtil.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/MetadataUtil.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/MethodInjectionMetadataImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/MethodInjectionMetadataImpl.java?rev=765267&r1=765266&r2=765267&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/MethodInjectionMetadataImpl.java
(original)
+++ geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/MethodInjectionMetadataImpl.java
Wed Apr 15 16:45:06 2009
@@ -18,7 +18,9 @@
  */
 package org.apache.felix.blueprint.reflect;
 
+import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
 
 import org.osgi.service.blueprint.reflect.MethodInjectionMetadata;
@@ -43,6 +45,17 @@
         this.parameterSpecifications = parameterSpecifications;
     }
 
+    public MethodInjectionMetadataImpl(MethodInjectionMetadata source) {
+        name = source.getName();
+        if (source.getParameterSpecifications() != null) {
+            parameterSpecifications = new ArrayList<ParameterSpecification>();
+            Iterator i = source.getParameterSpecifications().iterator();
+            while (i.hasNext()) {
+                parameterSpecifications.add(new ParameterSpecificationImpl((ParameterSpecification)i.next()));
+            }
+        }
+    }
+
     public String getName() {
         return name;
     }

Modified: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ParameterSpecificationImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ParameterSpecificationImpl.java?rev=765267&r1=765266&r2=765267&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ParameterSpecificationImpl.java
(original)
+++ geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ParameterSpecificationImpl.java
Wed Apr 15 16:45:06 2009
@@ -42,6 +42,12 @@
         this.index = index;
     }
 
+    public ParameterSpecificationImpl(ParameterSpecification source) {
+        value = MetadataUtil.cloneValue(source.getValue());
+        typeName = source.getTypeName();
+        index = source.getIndex();
+    }
+    
     public Value getValue() {
         return value;
     }

Modified: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/PropertiesValueImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/PropertiesValueImpl.java?rev=765267&r1=765266&r2=765267&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/PropertiesValueImpl.java
(original)
+++ geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/PropertiesValueImpl.java
Wed Apr 15 16:45:06 2009
@@ -39,6 +39,12 @@
         this.propertiesValue = propertiesValue;
     }
 
+    public PropertiesValueImpl(PropertiesValue source) {
+        if (source.getPropertiesValue() != null) {
+            propertiesValue = new Properties(source.getPropertiesValue());
+        }
+    }
+    
     public Properties getPropertiesValue() {
         return propertiesValue;
     }

Modified: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/PropertyInjectionMetadataImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/PropertyInjectionMetadataImpl.java?rev=765267&r1=765266&r2=765267&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/PropertyInjectionMetadataImpl.java
(original)
+++ geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/PropertyInjectionMetadataImpl.java
Wed Apr 15 16:45:06 2009
@@ -40,6 +40,11 @@
         this.value = value;
     }
 
+    public PropertyInjectionMetadataImpl(PropertyInjectionMetadata source) {
+        name = source.getName();
+        value = MetadataUtil.cloneValue(source.getValue());
+    }
+    
     public String getName() {
         return name;
     }

Modified: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ReferenceNameValueImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ReferenceNameValueImpl.java?rev=765267&r1=765266&r2=765267&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ReferenceNameValueImpl.java
(original)
+++ geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ReferenceNameValueImpl.java
Wed Apr 15 16:45:06 2009
@@ -37,6 +37,10 @@
         this.referenceName = referenceName;
     }
 
+    public ReferenceNameValueImpl(ReferenceNameValue source) {
+        referenceName = source.getReferenceName();
+    }
+    
     public String getReferenceName() {
         return referenceName;
     }

Modified: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ReferenceValueImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ReferenceValueImpl.java?rev=765267&r1=765266&r2=765267&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ReferenceValueImpl.java
(original)
+++ geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ReferenceValueImpl.java
Wed Apr 15 16:45:06 2009
@@ -37,6 +37,10 @@
         this.componentName = componentName;
     }
 
+    public ReferenceValueImpl(ReferenceValue source) {
+        componentName = source.getComponentName();
+    }
+    
     public String getComponentName() {
         return componentName;
     }

Modified: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/RegistrationListenerMetadataImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/RegistrationListenerMetadataImpl.java?rev=765267&r1=765266&r2=765267&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/RegistrationListenerMetadataImpl.java
(original)
+++ geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/RegistrationListenerMetadataImpl.java
Wed Apr 15 16:45:06 2009
@@ -42,6 +42,12 @@
         this.unregistrationMethodName = unregistrationMethodName;
     }
 
+    public RegistrationListenerMetadataImpl(RegistrationListenerMetadata source) {
+        listenerComponent = MetadataUtil.cloneValue(source.getListenerComponent());
+        registrationMethodName = source.getRegistrationMethodName();
+        unregistrationMethodName = source.getUnregistrationMethodName();
+    }
+    
     public Value getListenerComponent() {
         return listenerComponent;
     }

Modified: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ServiceExportComponentMetadataImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ServiceExportComponentMetadataImpl.java?rev=765267&r1=765266&r2=765267&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ServiceExportComponentMetadataImpl.java
(original)
+++ geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ServiceExportComponentMetadataImpl.java
Wed Apr 15 16:45:06 2009
@@ -20,6 +20,9 @@
 
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 import java.util.ArrayList;
@@ -40,11 +43,34 @@
     private Value exportedComponent;
     private Set<String> interfaceNames;
     private int autoExportMode;
-    private Map serviceProperties;
+    private Map serviceProperties;    
     private MapValue servicePropertiesValue;
     private int ranking;
     private Collection<RegistrationListenerMetadata> registrationListeners;
 
+    public ServiceExportComponentMetadataImpl() {        
+    }
+    
+    public ServiceExportComponentMetadataImpl(ServiceExportComponentMetadata source) {
+        super(source);
+        if (source.getServiceProperties() != null) {
+            serviceProperties = new HashMap(source.getServiceProperties());
+        }
+        exportedComponent = MetadataUtil.cloneValue(source.getExportedComponent());
+        ranking = source.getRanking();
+        if (source.getInterfaceNames() != null) {
+            interfaceNames = new HashSet<String>(source.getInterfaceNames());
+        }
+        if (source.getRegistrationListeners() != null) {
+            Iterator i = source.getRegistrationListeners().iterator();
+            registrationListeners = new ArrayList<RegistrationListenerMetadata>();
+            while (i.hasNext()) {
+                registrationListeners.add(new RegistrationListenerMetadataImpl((RegistrationListenerMetadata)i.next()));
+            }
+        }
+        autoExportMode = source.getAutoExportMode();
+    }
+    
     public Value getExportedComponent() {
         return exportedComponent;
     }
@@ -76,11 +102,11 @@
     public void setServiceProperties(Map serviceProperties) {
         this.serviceProperties = serviceProperties;
     }
-
+    
     public MapValue getServicePropertiesValue() {
         return servicePropertiesValue;
     }
-
+    
     public void setServicePropertiesValue(MapValue servicePropertiesValue) {
         this.servicePropertiesValue = servicePropertiesValue;
     }

Modified: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ServiceReferenceComponentMetadataImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ServiceReferenceComponentMetadataImpl.java?rev=765267&r1=765266&r2=765267&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ServiceReferenceComponentMetadataImpl.java
(original)
+++ geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/ServiceReferenceComponentMetadataImpl.java
Wed Apr 15 16:45:06 2009
@@ -20,6 +20,8 @@
 
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
 import java.util.Set;
 import java.util.ArrayList;
 
@@ -44,6 +46,23 @@
         bindingListeners = new ArrayList<BindingListenerMetadata>();
     }
 
+    public ServiceReferenceComponentMetadataImpl(ServiceReferenceComponentMetadata source)
{
+        super(source);
+        if (source.getBindingListeners() != null) {
+            bindingListeners = new ArrayList<BindingListenerMetadata>();
+            Iterator i = source.getBindingListeners().iterator();
+            while (i.hasNext()) {
+                bindingListeners.add(new BindingListenerMetadataImpl((BindingListenerMetadata)i.next()));
+            }
+        }
+        if (source.getInterfaceNames() != null) {
+            interfaceNames = new HashSet<String>(source.getInterfaceNames());
+        }
+        serviceAvailabilitySpecification = source.getServiceAvailabilitySpecification();
+        filter = source.getFilter();
+        componentName = source.getComponentName();
+    }
+    
     public int getServiceAvailabilitySpecification() {
         return serviceAvailabilitySpecification;
     }

Modified: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/SetValueImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/SetValueImpl.java?rev=765267&r1=765266&r2=765267&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/SetValueImpl.java
(original)
+++ geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/SetValueImpl.java
Wed Apr 15 16:45:06 2009
@@ -18,6 +18,8 @@
  */
 package org.apache.felix.blueprint.reflect;
 
+import java.util.HashSet;
+import java.util.Iterator;
 import java.util.Set;
 
 import org.osgi.service.blueprint.reflect.SetValue;
@@ -42,6 +44,17 @@
         this.set = set;
     }
 
+    public SetValueImpl(SetValue source) {
+        if (source.getSet() != null) {
+            set = new HashSet<Value>();
+            Iterator i = source.getSet().iterator();
+            while (i.hasNext()) {
+                set.add(MetadataUtil.cloneValue((Value)i.next()));
+            }
+        }
+        valueType = source.getValueType();
+    }
+    
     public String getValueType() {
         return valueType;
     }

Modified: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/TypedStringValueImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/TypedStringValueImpl.java?rev=765267&r1=765266&r2=765267&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/TypedStringValueImpl.java
(original)
+++ geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/TypedStringValueImpl.java
Wed Apr 15 16:45:06 2009
@@ -43,6 +43,11 @@
         this.typeName = typeName;
     }
 
+    public TypedStringValueImpl(TypedStringValue source) {
+        this.stringValue = source.getStringValue();
+        this.typeName = source.getTypeName();
+    }
+
     public String getStringValue() {
         return stringValue;
     }

Modified: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/UnaryServiceReferenceComponentMetadataImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/UnaryServiceReferenceComponentMetadataImpl.java?rev=765267&r1=765266&r2=765267&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/UnaryServiceReferenceComponentMetadataImpl.java
(original)
+++ geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/reflect/UnaryServiceReferenceComponentMetadataImpl.java
Wed Apr 15 16:45:06 2009
@@ -30,6 +30,14 @@
 
     private long timeout;
 
+    public UnaryServiceReferenceComponentMetadataImpl() {        
+    }
+    
+    public UnaryServiceReferenceComponentMetadataImpl(UnaryServiceReferenceComponentMetadata
source) {
+        super(source);
+        timeout = source.getTimeout();
+    }
+    
     public long getTimeout() {
         return timeout;
     }



Mime
View raw message