You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by zo...@apache.org on 2011/02/27 18:47:18 UTC

svn commit: r1075094 [13/17] - in /aries/tags/blueprint-0.1-incubating: ./ blueprint-api/ blueprint-api/src/ blueprint-api/src/main/ blueprint-api/src/main/appended-resources/ blueprint-api/src/main/appended-resources/META-INF/ blueprint-api/src/main/j...

Added: aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/MetadataUtil.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/MetadataUtil.java?rev=1075094&view=auto
==============================================================================
--- aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/MetadataUtil.java (added)
+++ aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/MetadataUtil.java Sun Feb 27 17:47:08 2011
@@ -0,0 +1,210 @@
+/**
+ *  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.aries.blueprint.reflect;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.apache.aries.blueprint.PassThroughMetadata;
+import org.osgi.service.blueprint.reflect.BeanArgument;
+import org.osgi.service.blueprint.reflect.BeanMetadata;
+import org.osgi.service.blueprint.reflect.CollectionMetadata;
+import org.osgi.service.blueprint.reflect.ComponentMetadata;
+import org.osgi.service.blueprint.reflect.IdRefMetadata;
+import org.osgi.service.blueprint.reflect.MapMetadata;
+import org.osgi.service.blueprint.reflect.Metadata;
+import org.osgi.service.blueprint.reflect.NullMetadata;
+import org.osgi.service.blueprint.reflect.PropsMetadata;
+import org.osgi.service.blueprint.reflect.ReferenceListMetadata;
+import org.osgi.service.blueprint.reflect.RefMetadata;
+import org.osgi.service.blueprint.reflect.ReferenceMetadata;
+import org.osgi.service.blueprint.reflect.ServiceMetadata;
+import org.osgi.service.blueprint.reflect.Target;
+import org.osgi.service.blueprint.reflect.ValueMetadata;
+
+
+/**
+ * A utility class that handles cloning various polymorphic
+ * bits of metadata into concrete class implementations.
+ *
+ * @version $Rev: 822644 $, $Date: 2009-10-07 11:23:35 +0100 (Wed, 07 Oct 2009) $
+ */
+public class MetadataUtil {
+
+    public static final Comparator<BeanArgument> BEAN_COMPARATOR = new BeanArgumentComparator();
+    
+    static public Metadata cloneMetadata(Metadata source) {
+        if (source == null) {
+            return null;
+        } 
+        else if (source instanceof MapMetadata) {
+            return new MapMetadataImpl((MapMetadata)source);
+        }
+        else if (source instanceof NullMetadata) {
+            return NullMetadata.NULL;
+        }
+        else if (source instanceof PropsMetadata) {
+            return new PropsMetadataImpl((PropsMetadata)source);
+        }
+        else if (source instanceof RefMetadata) {
+            return new RefMetadataImpl((RefMetadata)source);
+        }
+        else if (source instanceof IdRefMetadata) {
+            return new IdRefMetadataImpl((IdRefMetadata)source);
+        }
+        else if (source instanceof ValueMetadata) {
+            return new ValueMetadataImpl((ValueMetadata)source);
+        }
+        else if (source instanceof BeanMetadata) {
+            return new BeanMetadataImpl((BeanMetadata)source);
+        }
+        else if (source instanceof ReferenceListMetadata) {
+            return new ReferenceListMetadataImpl((ReferenceListMetadata)source);
+        }
+        else if (source instanceof ServiceMetadata) {
+            return new ServiceMetadataImpl((ServiceMetadata)source);
+        }
+        else if (source instanceof ReferenceMetadata) {
+            return new ReferenceMetadataImpl((ReferenceMetadata)source);
+        }
+        else if (source instanceof CollectionMetadata) {
+            return new CollectionMetadataImpl((CollectionMetadata)source);
+        }
+        else if (source instanceof PassThroughMetadata) {
+            return new PassThroughMetadataImpl((PassThroughMetadata)source);
+        }
+
+        throw new RuntimeException("Unknown Metadata 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) {
+        return (ComponentMetadata) cloneMetadata(source);
+    }
+
+    /**
+     * Clone a target item, returning a mutable
+     * instance.
+     *
+     * @param source The source target item.
+     *
+     * @return A mutable instance of this target item.
+     */
+    static public Target cloneTarget(Target source) {
+        return (Target) cloneMetadata(source);
+    }
+
+    /**
+     * Create a new metadata instance of the given type
+     *
+     * @param type the class of the Metadata object to create
+     * @param <T>
+     * @return a new instance
+     */
+    public static <T extends Metadata> T createMetadata(Class<T> type) {
+        if (MapMetadata.class.isAssignableFrom(type)) {
+            return type.cast(new MapMetadataImpl());
+        } else if (NullMetadata.class.isAssignableFrom(type)) {
+            return type.cast(NullMetadata.NULL);
+        } else if (PropsMetadata.class.isAssignableFrom(type)) {
+            return type.cast(new PropsMetadataImpl());
+        } else if (RefMetadata.class.isAssignableFrom(type)) {
+            return type.cast(new RefMetadataImpl());
+        } else if (IdRefMetadata.class.isAssignableFrom(type)) {
+            return type.cast(new IdRefMetadataImpl());
+        } else if (ValueMetadata.class.isAssignableFrom(type)) {
+            return type.cast(new ValueMetadataImpl());
+        } else if (BeanMetadata.class.isAssignableFrom(type)) {
+            return type.cast(new BeanMetadataImpl());
+        } else if (ReferenceListMetadata.class.isAssignableFrom(type)) {
+            return type.cast(new ReferenceListMetadataImpl());
+        } else if (ServiceMetadata.class.isAssignableFrom(type)) {
+            return type.cast(new ServiceMetadataImpl());
+        } else if (ReferenceMetadata.class.isAssignableFrom(type)) {
+            return type.cast(new ReferenceMetadataImpl());
+        } else if (CollectionMetadata.class.isAssignableFrom(type)) {
+            return type.cast(new CollectionMetadataImpl());
+        } else if (PassThroughMetadata.class.isAssignableFrom(type)) {
+            return type.cast(new PassThroughMetadataImpl());
+        } else {
+            throw new IllegalArgumentException("Unsupport metadata type: " + (type != null ? type.getName() : null));
+        }
+    }
+    
+    public static List<BeanArgument> validateBeanArguments(List<BeanArgument> arguments) {
+        if (arguments == null || arguments.isEmpty()) {
+            return arguments;
+        }
+        // check if all or none arguments have index attribute
+        boolean hasIndexFirst = (arguments.get(0).getIndex() > -1);
+        for (int i = 1; i < arguments.size(); i++) {
+            boolean hasIndex = (arguments.get(i).getIndex() > -1);
+            if ( (hasIndexFirst && !hasIndex) ||
+                 (!hasIndexFirst && hasIndex) ) {
+                throw new IllegalArgumentException("Index attribute must be specified either on all or none constructor arguments");
+            }
+        }
+        if (hasIndexFirst) {
+            // sort the arguments
+            List<BeanArgument> argumentsCopy = new ArrayList<BeanArgument>(arguments);
+            Collections.sort(argumentsCopy, MetadataUtil.BEAN_COMPARATOR);
+            arguments = argumentsCopy;
+            
+            // check if the indexes are sequential
+            for (int i = 0; i < arguments.size(); i++) {
+                int index = arguments.get(i).getIndex();
+                if (index > i) {
+                    throw new IllegalArgumentException("Missing attribute index");                    
+                } else if (index < i) {
+                    throw new IllegalArgumentException("Duplicate attribute index");
+                } // must be the same
+            }            
+        }
+        
+        return arguments;
+    }
+    
+    public static boolean isPrototypeScope(BeanMetadata metadata) {
+        return (BeanMetadata.SCOPE_PROTOTYPE.equals(metadata.getScope()) || 
+                (metadata.getScope() == null && metadata.getId() == null));
+    }
+    
+    public static boolean isSingletonScope(BeanMetadata metadata) {
+        return (BeanMetadata.SCOPE_SINGLETON.equals(metadata.getScope())  ||
+                (metadata.getScope() == null && metadata.getId() != null));
+    }
+    
+    private static class BeanArgumentComparator implements Comparator<BeanArgument>, Serializable {
+        public int compare(BeanArgument object1, BeanArgument object2) {
+            return object1.getIndex() - object2.getIndex();
+        }        
+    }
+       
+}
+

Added: aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/PassThroughMetadataImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/PassThroughMetadataImpl.java?rev=1075094&view=auto
==============================================================================
--- aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/PassThroughMetadataImpl.java (added)
+++ aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/PassThroughMetadataImpl.java Sun Feb 27 17:47:08 2011
@@ -0,0 +1,53 @@
+/*
+ * 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.aries.blueprint.reflect;
+
+import org.apache.aries.blueprint.PassThroughMetadata;
+import org.apache.aries.blueprint.mutable.MutablePassThroughMetadata;
+
+/**
+ * A metadata for environment managers.
+ *
+ * @version $Rev: 896324 $, $Date: 2010-01-06 06:05:04 +0000 (Wed, 06 Jan 2010) $
+ */
+public class PassThroughMetadataImpl extends ComponentMetadataImpl implements MutablePassThroughMetadata {
+
+    private Object object;
+
+    public PassThroughMetadataImpl() {
+    }
+
+    public PassThroughMetadataImpl(PassThroughMetadata source) {
+        super(source);
+        this.object = source.getObject();
+    }
+
+    public PassThroughMetadataImpl(String id, Object object) {
+        this.id = id;
+        this.object = object;
+    }
+
+    public Object getObject() {
+        return object;
+    }
+
+    public void setObject(Object object) {
+        this.object = object;
+    }
+}

Added: aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/PropsMetadataImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/PropsMetadataImpl.java?rev=1075094&view=auto
==============================================================================
--- aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/PropsMetadataImpl.java (added)
+++ aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/PropsMetadataImpl.java Sun Feb 27 17:47:08 2011
@@ -0,0 +1,90 @@
+/*
+ * 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.aries.blueprint.reflect;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.aries.blueprint.mutable.MutablePropsMetadata;
+import org.osgi.service.blueprint.reflect.MapEntry;
+import org.osgi.service.blueprint.reflect.Metadata;
+import org.osgi.service.blueprint.reflect.NonNullMetadata;
+import org.osgi.service.blueprint.reflect.PropsMetadata;
+
+/**
+ * Implementation of PropsMetadata
+ *
+ * @version $Rev: 896324 $, $Date: 2010-01-06 06:05:04 +0000 (Wed, 06 Jan 2010) $
+ */
+public class PropsMetadataImpl implements MutablePropsMetadata {
+
+    private List<MapEntry> entries;
+
+    public PropsMetadataImpl() {
+    }
+
+    public PropsMetadataImpl(List<MapEntry> entries) {
+        this.entries = entries;
+    }
+
+    public PropsMetadataImpl(PropsMetadata source) {
+        for (MapEntry entry : source.getEntries()) {
+            addEntry(new MapEntryImpl(entry));
+        }
+    }
+
+    public List<MapEntry> getEntries() {
+        if (this.entries == null) {
+            return Collections.emptyList();
+        } else {
+            return Collections.unmodifiableList(this.entries);
+        }
+    }
+
+    public void setEntries(List<MapEntry> entries) {
+        this.entries = entries != null ? new ArrayList<MapEntry>(entries) : null;
+    }
+
+    public void addEntry(MapEntry entry) {
+        if (this.entries == null) {
+            this.entries = new ArrayList<MapEntry>();
+        }
+        this.entries.add(entry);
+    }
+
+    public MapEntry addEntry(NonNullMetadata key, Metadata value) {
+        MapEntry entry = new MapEntryImpl(key, value);
+        addEntry(entry);
+        return entry;
+    }
+
+    public void removeEntry(MapEntry entry) {
+        if (this.entries != null) {
+            this.entries.remove(entry);
+        }
+    }
+
+    @Override
+    public String toString() {
+        return "PropsMetadata[" +
+                "entries=" + entries +
+                ']';
+    }
+}

Added: aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/RefMetadataImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/RefMetadataImpl.java?rev=1075094&view=auto
==============================================================================
--- aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/RefMetadataImpl.java (added)
+++ aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/RefMetadataImpl.java Sun Feb 27 17:47:08 2011
@@ -0,0 +1,58 @@
+/*
+ * 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.aries.blueprint.reflect;
+
+import org.apache.aries.blueprint.mutable.MutableRefMetadata;
+import org.osgi.service.blueprint.reflect.RefMetadata;
+
+/**
+ * Implementation of RefMetadata
+ *
+ * @version $Rev: 896324 $, $Date: 2010-01-06 06:05:04 +0000 (Wed, 06 Jan 2010) $
+ */
+public class RefMetadataImpl implements MutableRefMetadata {
+
+    protected String componentId;
+
+    public RefMetadataImpl() {
+    }
+
+    public RefMetadataImpl(String componentId) {
+        this.componentId = componentId;
+    }
+
+    public RefMetadataImpl(RefMetadata source) {
+        componentId = source.getComponentId();
+    }
+
+    public String getComponentId() {
+        return componentId;
+    }
+
+    public void setComponentId(String componentId) {
+        this.componentId = componentId;
+    }
+
+    @Override
+    public String toString() {
+        return "RefMetadata[" +
+                "componentId='" + componentId + '\'' +
+                ']';
+    }
+}

Added: aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ReferenceListMetadataImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ReferenceListMetadataImpl.java?rev=1075094&view=auto
==============================================================================
--- aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ReferenceListMetadataImpl.java (added)
+++ aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ReferenceListMetadataImpl.java Sun Feb 27 17:47:08 2011
@@ -0,0 +1,63 @@
+/*
+ * 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.aries.blueprint.reflect;
+
+import org.apache.aries.blueprint.mutable.MutableReferenceListMetadata;
+import org.osgi.service.blueprint.reflect.ReferenceListMetadata;
+
+/**
+ * Implementation of RefCollectionMetadata 
+ *
+ * @version $Rev: 896324 $, $Date: 2010-01-06 06:05:04 +0000 (Wed, 06 Jan 2010) $
+ */
+public class ReferenceListMetadataImpl extends ServiceReferenceMetadataImpl implements MutableReferenceListMetadata {
+
+    private int memberType = USE_SERVICE_OBJECT;
+
+    public ReferenceListMetadataImpl() {
+    }
+    
+    public ReferenceListMetadataImpl(ReferenceListMetadata source) {
+        super(source);
+        memberType = source.getMemberType();
+    }
+
+    public int getMemberType() {
+        return memberType;
+    }
+
+    public void setMemberType(int memberType) {
+        this.memberType = memberType;
+    }
+
+    @Override
+    public String toString() {
+        return "RefCollectionMetadata[" +
+                "id='" + id + '\'' +
+                ", activation=" + activation +
+                ", dependsOn=" + dependsOn +
+                ", availability=" + availability +
+                ", interface='" + interfaceName + '\'' +
+                ", componentName='" + componentName + '\'' +
+                ", filter='" + filter + '\'' +
+                ", referenceListeners=" + referenceListeners +
+                ", memberType=" + memberType +
+                ']';
+    }
+}

Added: aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ReferenceListenerImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ReferenceListenerImpl.java?rev=1075094&view=auto
==============================================================================
--- aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ReferenceListenerImpl.java (added)
+++ aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ReferenceListenerImpl.java Sun Feb 27 17:47:08 2011
@@ -0,0 +1,83 @@
+/*
+ * 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.aries.blueprint.reflect;
+
+import org.apache.aries.blueprint.mutable.MutableReferenceListener;
+import org.osgi.service.blueprint.reflect.ReferenceListener;
+import org.osgi.service.blueprint.reflect.Target;
+
+/**
+ * Implementation of Listener
+ *
+ * @version $Rev: 896324 $, $Date: 2010-01-06 06:05:04 +0000 (Wed, 06 Jan 2010) $
+ */
+public class ReferenceListenerImpl implements MutableReferenceListener {
+
+    private Target listenerComponent;
+    private String bindMethod;
+    private String unbindMethod;
+
+    public ReferenceListenerImpl() {
+    }
+
+    public ReferenceListenerImpl(Target listenerComponent, String bindMethod, String unbindMethod) {
+        this.listenerComponent = listenerComponent;
+        this.bindMethod = bindMethod;
+        this.unbindMethod = unbindMethod;
+    }
+
+    public ReferenceListenerImpl(ReferenceListener source) {
+        this.listenerComponent = MetadataUtil.cloneTarget(source.getListenerComponent());
+        this.bindMethod = source.getBindMethod();
+        this.unbindMethod = source.getUnbindMethod();
+    }
+
+    public Target getListenerComponent() {
+        return this.listenerComponent;
+    }
+
+    public void setListenerComponent(Target listenerComponent) {
+        this.listenerComponent = listenerComponent;
+    }
+
+    public String getBindMethod() {
+        return this.bindMethod;
+    }
+
+    public void setBindMethod(String bindMethodName) {
+        this.bindMethod = bindMethodName;
+    }
+
+    public String getUnbindMethod() {
+        return this.unbindMethod;
+    }
+
+    public void setUnbindMethod(String unbindMethodName) {
+        this.unbindMethod = unbindMethodName;
+    }
+
+    @Override
+    public String toString() {
+        return "Listener[" +
+                "listenerComponent=" + listenerComponent +
+                ", bindMethodName='" + bindMethod + '\'' +
+                ", unbindMethodName='" + unbindMethod + '\'' +
+                ']';
+    }
+}

Added: aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ReferenceMetadataImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ReferenceMetadataImpl.java?rev=1075094&view=auto
==============================================================================
--- aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ReferenceMetadataImpl.java (added)
+++ aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ReferenceMetadataImpl.java Sun Feb 27 17:47:08 2011
@@ -0,0 +1,63 @@
+/*
+ * 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.aries.blueprint.reflect;
+
+import org.apache.aries.blueprint.mutable.MutableReferenceMetadata;
+import org.osgi.service.blueprint.reflect.ReferenceMetadata;
+
+/**
+ * Implementation of ReferenceMetadata
+ *
+ * @version $Rev: 896324 $, $Date: 2010-01-06 06:05:04 +0000 (Wed, 06 Jan 2010) $
+ */
+public class ReferenceMetadataImpl extends ServiceReferenceMetadataImpl implements MutableReferenceMetadata {
+
+    private long timeout;
+
+    public ReferenceMetadataImpl() {
+    }
+    
+    public ReferenceMetadataImpl(ReferenceMetadata source) {
+        super(source);
+        timeout = source.getTimeout();
+    }
+
+    public long getTimeout() {
+        return timeout;
+    }
+
+    public void setTimeout(long timeout) {
+        this.timeout = timeout;
+    }
+
+    @Override
+    public String toString() {
+        return "ReferenceMetadata[" +
+                "id='" + id + '\'' +
+                ", activation=" + activation +
+                ", dependsOn=" + dependsOn +
+                ", availability=" + availability +
+                ", interface='" + interfaceName + '\'' +
+                ", componentName='" + componentName + '\'' +
+                ", filter='" + filter + '\'' +
+                ", referenceListeners=" + referenceListeners +
+                ", timeout=" + timeout +
+                ']';
+    }
+}

Added: aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/RegistrationListenerImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/RegistrationListenerImpl.java?rev=1075094&view=auto
==============================================================================
--- aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/RegistrationListenerImpl.java (added)
+++ aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/RegistrationListenerImpl.java Sun Feb 27 17:47:08 2011
@@ -0,0 +1,83 @@
+/*
+ * 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.aries.blueprint.reflect;
+
+import org.apache.aries.blueprint.mutable.MutableRegistrationListener;
+import org.osgi.service.blueprint.reflect.RegistrationListener;
+import org.osgi.service.blueprint.reflect.Target;
+
+/**
+ * Implementation of RegistrationListener.
+ *
+ * @version $Rev: 896324 $, $Date: 2010-01-06 06:05:04 +0000 (Wed, 06 Jan 2010) $
+ */
+public class RegistrationListenerImpl implements MutableRegistrationListener {
+
+    private Target listenerComponent;
+    private String registrationMethod;
+    private String unregistrationMethod;
+
+    public RegistrationListenerImpl() {
+    }
+
+    public RegistrationListenerImpl(Target listenerComponent, String registrationMethod, String unregistrationMethod) {
+        this.listenerComponent = listenerComponent;
+        this.registrationMethod = registrationMethod;
+        this.unregistrationMethod = unregistrationMethod;
+    }
+
+    public RegistrationListenerImpl(RegistrationListener source) {
+        listenerComponent = MetadataUtil.cloneTarget(source.getListenerComponent());
+        registrationMethod = source.getRegistrationMethod();
+        unregistrationMethod = source.getUnregistrationMethod();
+    }
+
+    public Target getListenerComponent() {
+        return listenerComponent;
+    }
+
+    public void setListenerComponent(Target listenerComponent) {
+        this.listenerComponent = listenerComponent;
+    }
+
+    public String getRegistrationMethod() {
+        return registrationMethod;
+    }
+
+    public void setRegistrationMethod(String registrationMethod) {
+        this.registrationMethod = registrationMethod;
+    }
+
+    public String getUnregistrationMethod() {
+        return unregistrationMethod;
+    }
+
+    public void setUnregistrationMethod(String unregistrationMethod) {
+        this.unregistrationMethod = unregistrationMethod;
+    }
+
+    @Override
+    public String toString() {
+        return "RegistrationListener[" +
+                "listenerComponent=" + listenerComponent +
+                ", registrationMethodName='" + registrationMethod + '\'' +
+                ", unregistrationMethodName='" + unregistrationMethod + '\'' +
+                ']';
+    }
+}

Added: aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ServiceMetadataImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ServiceMetadataImpl.java?rev=1075094&view=auto
==============================================================================
--- aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ServiceMetadataImpl.java (added)
+++ aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ServiceMetadataImpl.java Sun Feb 27 17:47:08 2011
@@ -0,0 +1,190 @@
+/*
+ * 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.aries.blueprint.reflect;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.aries.blueprint.mutable.MutableServiceMetadata;
+import org.osgi.service.blueprint.reflect.MapEntry;
+import org.osgi.service.blueprint.reflect.Metadata;
+import org.osgi.service.blueprint.reflect.NonNullMetadata;
+import org.osgi.service.blueprint.reflect.RegistrationListener;
+import org.osgi.service.blueprint.reflect.ServiceMetadata;
+import org.osgi.service.blueprint.reflect.Target;
+
+/**
+ * Implementation of ServiceMetadata
+ *
+ * @version $Rev: 896324 $, $Date: 2010-01-06 06:05:04 +0000 (Wed, 06 Jan 2010) $
+ */
+public class ServiceMetadataImpl extends ComponentMetadataImpl implements MutableServiceMetadata {
+
+    private Target serviceComponent;
+    private List<String> interfaceNames;
+    private int autoExport;
+    private List<MapEntry> serviceProperties;
+    private int ranking;
+    private Collection<RegistrationListener> registrationListeners;
+
+    public ServiceMetadataImpl() {
+    }
+    
+    public ServiceMetadataImpl(ServiceMetadata source) {
+        super(source);
+        this.serviceComponent = MetadataUtil.cloneTarget(source.getServiceComponent());
+        this.interfaceNames = new ArrayList<String>(source.getInterfaces());
+        this.autoExport = source.getAutoExport();
+        for (MapEntry serviceProperty : source.getServiceProperties()) {
+            addServiceProperty(new MapEntryImpl(serviceProperty));
+        }
+        this.ranking = source.getRanking();
+        for (RegistrationListener listener : source.getRegistrationListeners()) {
+            addRegistrationListener(new RegistrationListenerImpl(listener));
+        }
+    }
+
+    public Target getServiceComponent() {
+        return serviceComponent;
+    }
+
+    public void setServiceComponent(Target exportedComponent) {
+        this.serviceComponent = exportedComponent;
+    }
+
+    public List<String> getInterfaces() {
+        if (this.interfaceNames == null) {
+            return Collections.emptyList();
+        } else {
+            return Collections.unmodifiableList(this.interfaceNames);
+        }
+    }
+
+    public void setInterfaceNames(List<String> interfaceNames) {
+        this.interfaceNames = interfaceNames != null ? new ArrayList<String>(interfaceNames) : null;
+    }
+
+    public void addInterface(String interfaceName) {
+        if (this.interfaceNames == null) {
+            this.interfaceNames = new ArrayList<String>();
+        }
+        this.interfaceNames.add(interfaceName);
+    }
+
+    public void removeInterface(String interfaceName) {
+        if (this.interfaceNames != null) {
+            this.interfaceNames.remove(interfaceName);
+        }
+    }
+
+    public int getAutoExport() {
+        return this.autoExport;
+    }
+
+    public void setAutoExport(int autoExport) {
+        this.autoExport = autoExport;
+    }
+
+    public List<MapEntry> getServiceProperties() {
+        if (this.serviceProperties == null) {
+            return Collections.emptyList();
+        } else {
+            return Collections.unmodifiableList(this.serviceProperties);
+        }
+    }
+
+    public void setServiceProperties(List<MapEntry> serviceProperties) {
+        this.serviceProperties = serviceProperties != null ? new ArrayList<MapEntry>(serviceProperties) : null;
+    }
+
+    public void addServiceProperty(MapEntry serviceProperty) {
+        if (this.serviceProperties == null) {
+            this.serviceProperties = new ArrayList<MapEntry>();
+        }
+        this.serviceProperties.add(serviceProperty);
+    }
+
+    public MapEntry addServiceProperty(NonNullMetadata key, Metadata value) {
+        MapEntry serviceProperty = new MapEntryImpl(key, value);
+        addServiceProperty(serviceProperty);
+        return serviceProperty;
+    }
+
+    public void removeServiceProperty(MapEntry serviceProperty) {
+        if (this.serviceProperties != null) {
+            this.serviceProperties.remove(serviceProperty);
+        }
+    }
+
+    public int getRanking() {
+        return ranking;
+    }
+
+    public void setRanking(int ranking) {
+        this.ranking = ranking;
+    }
+
+    public Collection<RegistrationListener> getRegistrationListeners() {
+        if (this.registrationListeners == null) {
+            return Collections.emptySet();
+        } else {
+            return Collections.unmodifiableCollection(this.registrationListeners);
+        }
+    }
+
+    public void setRegistrationListeners(Collection<RegistrationListener> registrationListeners) {
+        this.registrationListeners = registrationListeners;
+    }
+
+    public void addRegistrationListener(RegistrationListener registrationListenerMetadata) {
+        if (this.registrationListeners == null) {
+            this.registrationListeners = new ArrayList<RegistrationListener>();
+        }
+        this.registrationListeners.add(registrationListenerMetadata);
+    }
+
+    public RegistrationListener addRegistrationListener(Target listenerComponent, String registrationMethodName, String unregistrationMethodName) {
+        RegistrationListener listener = new RegistrationListenerImpl(listenerComponent, registrationMethodName,  unregistrationMethodName);
+        addRegistrationListener(listener);
+        return listener;
+    }
+
+    public void removeRegistrationListener(RegistrationListener listener) {
+        if (this.registrationListeners != null) {
+            this.registrationListeners.remove(listener);
+        }
+    }
+
+    @Override
+    public String toString() {
+        return "ServiceMetadata[" +
+                "id='" + id + '\'' +
+                ", activation=" + activation +
+                ", dependsOn=" + dependsOn +
+                ", exportedComponent=" + serviceComponent +
+                ", interfaces=" + interfaceNames +
+                ", autoExportMode=" + autoExport +
+                ", serviceProperties=" + serviceProperties +
+                ", ranking=" + ranking +
+                ", registrationListeners=" + registrationListeners +
+                ']';
+    }
+}

Added: aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ServiceReferenceMetadataImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ServiceReferenceMetadataImpl.java?rev=1075094&view=auto
==============================================================================
--- aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ServiceReferenceMetadataImpl.java (added)
+++ aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ServiceReferenceMetadataImpl.java Sun Feb 27 17:47:08 2011
@@ -0,0 +1,129 @@
+/*
+ * 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.aries.blueprint.reflect;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+import org.apache.aries.blueprint.mutable.MutableServiceReferenceMetadata;
+import org.osgi.service.blueprint.reflect.ReferenceListener;
+import org.osgi.service.blueprint.reflect.ServiceReferenceMetadata;
+import org.osgi.service.blueprint.reflect.Target;
+
+/**
+ * Implementation of ServiceReferenceMetadata 
+ *
+ * @version $Rev: 896324 $, $Date: 2010-01-06 06:05:04 +0000 (Wed, 06 Jan 2010) $
+ */
+public abstract class ServiceReferenceMetadataImpl extends ComponentMetadataImpl implements MutableServiceReferenceMetadata {
+
+    protected int availability;
+    protected String interfaceName;
+    protected String componentName;
+    protected String filter;
+    protected Collection<ReferenceListener> referenceListeners;
+    protected int proxyMethod;
+
+    public ServiceReferenceMetadataImpl() {
+    }
+
+    public ServiceReferenceMetadataImpl(ServiceReferenceMetadata source) {
+        super(source);
+        this.availability = source.getAvailability();
+        this.interfaceName = source.getInterface();
+        this.componentName = source.getComponentName();
+        this.filter = source.getFilter();
+        for (ReferenceListener listener : source.getReferenceListeners()) {
+            addServiceListener(new ReferenceListenerImpl(listener));
+        }
+    }
+
+    public int getAvailability() {
+        return availability;
+    }
+
+    public void setAvailability(int availability) {
+        this.availability = availability;
+    }
+
+    public String getInterface() {
+        return interfaceName;
+    }
+
+    public void setInterface(String interfaceName) {
+        this.interfaceName = interfaceName;
+    }
+
+    public String getComponentName() {
+        return componentName;
+    }
+
+    public void setComponentName(String componentName) {
+        this.componentName = componentName;
+    }
+
+    public String getFilter() {
+        return filter;
+    }
+
+    public void setFilter(String filter) {
+        this.filter = filter;
+    }
+
+    public Collection<ReferenceListener> getReferenceListeners() {
+        if (this.referenceListeners == null) {
+            return Collections.emptyList();
+        } else {
+            return Collections.unmodifiableCollection(this.referenceListeners);
+        }
+    }
+
+    public void setReferenceListeners(Collection<ReferenceListener> listeners) {
+        this.referenceListeners = listeners != null ? new ArrayList<ReferenceListener>(listeners) : null;
+    }
+
+    public void addServiceListener(ReferenceListener bindingListenerMetadata) {
+        if (this.referenceListeners == null) {
+            this.referenceListeners = new ArrayList<ReferenceListener>();
+        }
+        this.referenceListeners.add(bindingListenerMetadata);
+    }
+
+    public ReferenceListener addServiceListener(Target listenerComponent, String bindMethodName, String unbindMethodName) {
+        ReferenceListener listener = new ReferenceListenerImpl(listenerComponent, bindMethodName, unbindMethodName);
+        addServiceListener(listener);
+        return listener;
+    }
+
+    public void removeReferenceListener(ReferenceListener listener) {
+        if (this.referenceListeners != null) {
+            this.referenceListeners.remove(listener);
+        }
+    }
+
+    public int getProxyMethod() {
+        return proxyMethod;
+    }
+
+    public void setProxyMethod(int proxyMethod) {
+        this.proxyMethod = proxyMethod;
+    }
+
+}

Added: aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ValueMetadataImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ValueMetadataImpl.java?rev=1075094&view=auto
==============================================================================
--- aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ValueMetadataImpl.java (added)
+++ aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ValueMetadataImpl.java Sun Feb 27 17:47:08 2011
@@ -0,0 +1,74 @@
+/*
+ * 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.aries.blueprint.reflect;
+
+import org.apache.aries.blueprint.mutable.MutableValueMetadata;
+import org.osgi.service.blueprint.reflect.ValueMetadata;
+
+/**
+ * Implementation of ValueMetadata 
+ *
+ * @version $Rev: 896324 $, $Date: 2010-01-06 06:05:04 +0000 (Wed, 06 Jan 2010) $
+ */
+public class ValueMetadataImpl implements MutableValueMetadata {
+
+    private String stringValue;
+    private String type;
+
+    public ValueMetadataImpl() {
+    }
+
+    public ValueMetadataImpl(String stringValue) {
+        this.stringValue = stringValue;
+    }
+
+    public ValueMetadataImpl(String stringValue, String type) {
+        this.stringValue = stringValue;
+        this.type = type;
+    }
+
+    public ValueMetadataImpl(ValueMetadata source) {
+        this.stringValue = source.getStringValue();
+        this.type = source.getType();
+    }
+
+    public String getStringValue() {
+        return stringValue;
+    }
+
+    public void setStringValue(String stringValue) {
+        this.stringValue = stringValue;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String typeName) {
+        this.type = typeName;
+    }
+
+    @Override
+    public String toString() {
+        return "ValueMetadata[" +
+                "stringValue='" + stringValue + '\'' +
+                ", type='" + type + '\'' +
+                ']';
+    }
+}

Added: aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/BundleDelegatingClassLoader.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/BundleDelegatingClassLoader.java?rev=1075094&view=auto
==============================================================================
--- aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/BundleDelegatingClassLoader.java (added)
+++ aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/BundleDelegatingClassLoader.java Sun Feb 27 17:47:08 2011
@@ -0,0 +1,87 @@
+/*
+ * 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.aries.blueprint.utils;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Enumeration;
+
+import org.osgi.framework.Bundle;
+
+/**
+ * A ClassLoader delegating to a given OSGi bundle.
+ *
+ * @version $Rev: 896324 $, $Date: 2010-01-06 06:05:04 +0000 (Wed, 06 Jan 2010) $
+ */
+public class BundleDelegatingClassLoader extends ClassLoader {
+
+    private final Bundle bundle;
+    private final ClassLoader classLoader;
+
+    public BundleDelegatingClassLoader(Bundle bundle) {
+        this(bundle, null);
+    }
+
+    public BundleDelegatingClassLoader(Bundle bundle, ClassLoader classLoader) {
+        this.bundle = bundle;
+        this.classLoader = classLoader;
+    }
+
+    protected Class findClass(String name) throws ClassNotFoundException {
+        return bundle.loadClass(name);
+    }
+
+    protected URL findResource(String name) {
+        URL resource = bundle.getResource(name);
+        if (classLoader != null && resource == null) {
+            resource = classLoader.getResource(name);
+        }
+        return resource;
+    }
+
+    protected Enumeration findResources(String name) throws IOException {
+        return bundle.getResources(name);
+    }
+
+    protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException {
+        Class clazz;
+        try {
+            clazz = findClass(name);
+        }
+        catch (ClassNotFoundException cnfe) {
+            if (classLoader != null) {
+                try {
+                    clazz = classLoader.loadClass(name);
+                } catch (ClassNotFoundException e) {
+                    throw new ClassNotFoundException(name + " from bundle " + bundle.getBundleId() + " (" + bundle.getSymbolicName() + ")", cnfe);
+                }
+            } else {
+                throw new ClassNotFoundException(name + " from bundle " + bundle.getBundleId() + " (" + bundle.getSymbolicName() + ")", cnfe);
+            }
+        }
+        if (resolve) {
+            resolveClass(clazz);
+        }
+        return clazz;
+    }
+
+    public Bundle getBundle() {
+        return bundle;
+    }
+}

Added: aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/DynamicCollection.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/DynamicCollection.java?rev=1075094&view=auto
==============================================================================
--- aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/DynamicCollection.java (added)
+++ aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/DynamicCollection.java Sun Feb 27 17:47:08 2011
@@ -0,0 +1,314 @@
+/*
+ * 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.aries.blueprint.utils;
+
+import java.lang.ref.WeakReference;
+import java.util.AbstractCollection;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.NoSuchElementException;
+
+/**
+ * Collection that allows iterators to see addition or removals of elements while iterating.
+ * This collection and its iterators are thread safe but all operations happen under a
+ * synchronization lock, so the performance in heavy concurrency load is far from optimal.
+ * If such a use is needed, a CopyOnWriteArrayList may be more suited.
+ *
+ * @version $Rev: 896324 $, $Date: 2010-01-06 06:05:04 +0000 (Wed, 06 Jan 2010) $
+ */
+public class DynamicCollection<E> extends AbstractCollection<E> {
+
+    protected final Object lock = new Object();
+    protected final List<E> storage;
+    protected final List<WeakReference<DynamicIterator>> iterators;
+
+    public DynamicCollection() {
+        this.storage = new ArrayList<E>();
+        this.iterators = new ArrayList<WeakReference<DynamicIterator>>();
+    }
+
+    public DynamicIterator iterator() {
+        return iterator(0);
+    }
+
+    public DynamicIterator iterator(int index) {
+        DynamicIterator iterator = createIterator(index);
+        synchronized (lock) {
+            for (Iterator<WeakReference<DynamicIterator>> it = iterators.iterator(); it.hasNext();) {
+                if (it.next().get() == null) {
+                    it.remove();
+                }
+            }
+            iterators.add(new WeakReference<DynamicIterator>(iterator));
+        }
+        return iterator;
+    }
+
+    protected DynamicIterator createIterator(int index) {
+        return new DynamicIterator(index);
+    }
+
+    public int size() {
+        synchronized (lock) {
+            return storage.size();
+        }
+    }
+
+    public boolean isEmpty() {
+        return size() == 0;
+    }
+
+    public boolean contains(Object o) {
+        if (o == null) {
+            throw new NullPointerException();
+        }
+        synchronized (lock) {
+            return storage.contains(o);
+        }
+    }
+
+    public Object[] toArray() {
+        synchronized (lock) {
+            return storage.toArray();
+        }
+    }
+
+    public <T> T[] toArray(T[] a) {
+        synchronized (lock) {
+            return storage.toArray(a);
+        }
+    }
+
+    public boolean containsAll(Collection<?> c) {
+        synchronized (lock) {
+            return storage.containsAll(c);
+        }
+    }
+
+    public boolean add(E o) {
+        if (o == null) {
+            throw new NullPointerException();
+        }
+        synchronized (lock) {
+            internalAdd(storage.size(), o);
+            return true;
+        }
+    }
+
+    public boolean remove(Object o) {
+        if (o == null) {
+            throw new NullPointerException();
+        }
+        synchronized (lock) {
+            int index = storage.indexOf(o);
+            return remove(index) != null;
+        }
+    }
+
+    public E get(int index) {
+        synchronized (lock) {
+            return storage.get(index);
+        }
+    }
+
+    private void internalAdd(int index, E o) {
+        if (o == null) {
+            throw new NullPointerException();
+        }
+        synchronized (lock) {
+            storage.add(index, o);
+            for (Iterator<WeakReference<DynamicIterator>> it = iterators.iterator(); it.hasNext();) {
+                DynamicIterator i = it.next().get();
+                if (i == null) {
+                    it.remove();
+                } else {
+                    i.addedIndex(index);
+                }
+            }
+        }
+    }
+
+    @Override
+    public void clear() {
+        synchronized (lock) {
+            storage.clear();
+        }
+    }
+
+    public E remove(int index) {
+        synchronized (lock) {
+            E o = storage.remove(index);
+            for (Iterator<WeakReference<DynamicIterator>> it = iterators.iterator(); it.hasNext();) {
+                WeakReference<DynamicIterator> r = it.next();
+                DynamicIterator i = r.get();
+                if (i == null) {
+                    it.remove();
+                } else {
+                    i.removedIndex(index);
+                }
+            }
+            return o;
+        }
+    }
+
+    public E first() {
+        synchronized (lock) {
+            if (storage.isEmpty()) {
+                throw new NoSuchElementException();
+            } else {
+                return storage.get(0);
+            }
+        }
+    }
+
+    public E last() {
+        synchronized (lock) {
+            if (storage.isEmpty()) {
+                throw new NoSuchElementException();
+            } else {
+                return storage.get(storage.size() - 1);
+            }
+        }
+    }
+
+    public class DynamicIterator implements ListIterator<E> {
+
+        protected int index;
+        protected boolean hasNextCalled;
+        protected E next;
+        protected boolean hasPreviousCalled;
+        protected E previous;
+        protected E last;
+
+        public DynamicIterator() {
+            this(0);
+        }
+
+        public DynamicIterator(int index) {
+            this.index = index;
+        }
+
+        protected void removedIndex(int index) {
+            synchronized (lock) {
+                if (index < this.index || (index == this.index && (hasNextCalled || hasPreviousCalled))) {
+                    this.index--;
+                }
+            }
+        }
+
+        protected void addedIndex(int index) {
+            synchronized (lock) {
+                if (index < this.index || (index == this.index && (next != null || previous != null))) {
+                    this.index++;
+                }
+            }
+        }
+
+        public boolean hasNext() {
+            synchronized (lock) {
+                hasPreviousCalled = false;
+                hasNextCalled = true;
+                next = index < storage.size() ? storage.get(index) : null;
+                return next != null;
+            }
+        }
+
+        public boolean hasPrevious() {
+            synchronized (lock) {
+                hasPreviousCalled = true;
+                hasNextCalled = false;
+                previous = index > 0 ? storage.get(index - 1) : null;
+                return previous != null;
+            }
+        }
+
+        public E next() {
+            synchronized (lock) {
+                try {
+                    if (!hasNextCalled) {
+                        hasNext();
+                    }
+                    last = next;
+                    if (next != null) {
+                        ++index;
+                        return next;
+                    } else {
+                        throw new NoSuchElementException();
+                    }
+                } finally {
+                    hasPreviousCalled = false;
+                    hasNextCalled = false;
+                    next = null;
+                    previous = null;
+                }
+            }
+        }
+
+        public E previous() {
+            synchronized (lock) {
+                try {
+                    if (!hasPreviousCalled) {
+                        hasPrevious();
+                    }
+                    last = previous;
+                    if (previous != null) {
+                        --index;
+                        return previous;
+                    } else {
+                        throw new NoSuchElementException();
+                    }
+                } finally {
+                    hasPreviousCalled = false;
+                    hasNextCalled = false;
+                    next = null;
+                    previous = null;
+                }
+            }
+        }
+
+        public int nextIndex() {
+            synchronized (lock) {
+                return index;
+            }
+        }
+
+        public int previousIndex() {
+            synchronized (lock) {
+                return index - 1;
+            }
+        }
+
+        public void set(E o) {
+            throw new UnsupportedOperationException();
+        }
+
+        public void add(E o) {
+            throw new UnsupportedOperationException();
+        }
+
+        public void remove() {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+}

Added: aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/HeaderParser.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/HeaderParser.java?rev=1075094&view=auto
==============================================================================
--- aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/HeaderParser.java (added)
+++ aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/HeaderParser.java Sun Feb 27 17:47:08 2011
@@ -0,0 +1,114 @@
+/**
+ * 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.aries.blueprint.utils;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Utility class to parse a standard OSGi header with paths.
+ *
+ * @version $Rev: 820286 $, $Date: 2009-09-30 15:45:55 +0100 (Wed, 30 Sep 2009) $
+ */
+public class HeaderParser  {
+
+    /**
+     * Parse a given OSGi header into a list of paths
+     *
+     * @param header the OSGi header to parse
+     * @return the list of paths extracted from this header
+     */
+    public static List<PathElement> parseHeader(String header) {
+        List<PathElement> elements = new ArrayList<PathElement>();
+        if (header == null || header.trim().length() == 0) {
+            return elements;
+        }
+        String[] clauses = header.split(",");
+        for (String clause : clauses) {
+            String[] tokens = clause.split(";");
+            if (tokens.length < 1) {
+                throw new IllegalArgumentException("Invalid header clause: " + clause);
+            }
+            PathElement elem = new PathElement(tokens[0].trim());
+            elements.add(elem);
+            for (int i = 1; i < tokens.length; i++) {
+                int pos = tokens[i].indexOf('=');
+                if (pos != -1) {
+                    if (pos > 0 && tokens[i].charAt(pos - 1) == ':') {
+                        String name = tokens[i].substring(0, pos - 1).trim();
+                        String value = tokens[i].substring(pos + 1).trim();
+                        elem.addDirective(name, value);
+                    } else {
+                        String name = tokens[i].substring(0, pos).trim();
+                        String value = tokens[i].substring(pos + 1).trim();
+                        elem.addAttribute(name, value);
+                    }
+                } else {
+                    elem = new PathElement(tokens[i].trim());
+                    elements.add(elem);
+                }
+            }
+        }
+        return elements;
+    }
+
+    public static class PathElement {
+        
+        private String path;
+        private Map<String, String> attributes;
+        private Map<String, String> directives;
+        
+        public PathElement(String path) {
+            this.path = path;
+            this.attributes = new HashMap<String, String>();
+            this.directives = new HashMap<String, String>();
+        }
+        
+        public String getName() {
+            return this.path;
+        }
+        
+        public Map<String, String> getAttributes() {
+            return attributes;
+        }
+        
+        public String getAttribute(String name) {
+            return attributes.get(name);
+        }
+        
+        public void addAttribute(String name, String value) {
+            attributes.put(name, value);
+        }
+        
+        public Map<String, String> getDirectives() {
+            return directives;
+        }
+        
+        public String getDirective(String name) {
+            return directives.get(name);
+        }
+        
+        public void addDirective(String name, String value) {
+            directives.put(name, value);
+        }        
+        
+    }
+}

Added: aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/JavaUtils.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/JavaUtils.java?rev=1075094&view=auto
==============================================================================
--- aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/JavaUtils.java (added)
+++ aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/JavaUtils.java Sun Feb 27 17:47:08 2011
@@ -0,0 +1,59 @@
+/**
+ * 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.aries.blueprint.utils;
+
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
+
+/**
+ * @version $Rev: 820636 $ $Date: 2009-10-01 13:55:42 +0100 (Thu, 01 Oct 2009) $
+ */
+public final class JavaUtils {
+
+    private JavaUtils() {
+    }
+
+    public static void copy(Dictionary destination, Dictionary source) {
+        Enumeration e = source.keys();
+        while (e.hasMoreElements()) {
+            Object key = e.nextElement();
+            Object value = source.get(key);
+            destination.put(key, value);
+        }
+    }
+
+    public static Hashtable getProperties(ServiceReference ref) {
+        Hashtable props = new Hashtable();
+        for (String key : ref.getPropertyKeys()) {
+            props.put(key, ref.getProperty(key));
+        }
+        return props;
+    }
+
+    public static Version getBundleVersion(Bundle bundle) {
+        Dictionary headers = bundle.getHeaders();
+        String version = (String)headers.get(Constants.BUNDLE_VERSION);
+        return (version != null) ? Version.parseVersion(version) : Version.emptyVersion;
+    }
+
+}

Added: aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/ReflectionUtils.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/ReflectionUtils.java?rev=1075094&view=auto
==============================================================================
--- aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/ReflectionUtils.java (added)
+++ aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/ReflectionUtils.java Sun Feb 27 17:47:08 2011
@@ -0,0 +1,392 @@
+/**
+ * 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.aries.blueprint.utils;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Type;
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.WeakHashMap;
+
+/**
+ * TODO: javadoc
+ *
+ * @version $Rev: 910448 $, $Date: 2010-02-16 09:50:18 +0000 (Tue, 16 Feb 2010) $
+ */
+public class ReflectionUtils {
+
+    // TODO: MLK: PropertyDescriptor holds a reference to Method which holds a reference to the Class itself
+    private static Map<Class<?>, PropertyDescriptor[][]> beanInfos = Collections.synchronizedMap(new WeakHashMap<Class<?>, PropertyDescriptor[][]>());
+
+    public static boolean hasDefaultConstructor(Class type) {
+        if (!Modifier.isPublic(type.getModifiers())) {
+            return false;
+        }
+        if (Modifier.isAbstract(type.getModifiers())) {
+            return false;
+        }
+        Constructor[] constructors = type.getConstructors();
+        for (Constructor constructor : constructors) {
+            if (Modifier.isPublic(constructor.getModifiers()) &&
+                    constructor.getParameterTypes().length == 0) {
+                return true;
+            }
+        }
+        return false;
+    }
+    
+    public static Set<String> getImplementedInterfaces(Set<String> classes, Class clazz) {
+        if (clazz != null && clazz != Object.class) {
+            for (Class itf : clazz.getInterfaces()) {
+                if (Modifier.isPublic(itf.getModifiers())) {
+                    classes.add(itf.getName());
+                }
+                getImplementedInterfaces(classes, itf);
+            }
+            getImplementedInterfaces(classes, clazz.getSuperclass());
+        }
+        return classes;
+    }
+
+    public static Set<String> getSuperClasses(Set<String> classes, Class clazz) {
+        if (clazz != null && clazz != Object.class) {
+            if (Modifier.isPublic(clazz.getModifiers())) {
+                classes.add(clazz.getName());
+            }
+            getSuperClasses(classes, clazz.getSuperclass());
+        }
+        return classes;
+    }
+
+    public static Method getLifecycleMethod(Class clazz, String name) {
+        if (name != null) {
+            try {
+                Method method = clazz.getMethod(name);
+                if (Void.TYPE.equals(method.getReturnType())) {
+                    return method;
+                }
+            } catch (NoSuchMethodException e) {
+                // fall thru
+            }
+        }
+        return null;
+    }
+    
+    public static List<Method> findCompatibleMethods(Class clazz, String name, Class[] paramTypes) {
+        List<Method> methods = new ArrayList<Method>();
+        for (Method method : clazz.getMethods()) {
+            Class[] methodParams = method.getParameterTypes();
+            if (name.equals(method.getName()) && Void.TYPE.equals(method.getReturnType()) && methodParams.length == paramTypes.length && !method.isBridge()) {
+                boolean assignable = true;
+                for (int i = 0; i < paramTypes.length && assignable; i++) {
+                    assignable &= paramTypes[i] == null || methodParams[i].isAssignableFrom(paramTypes[i]);
+                }
+                if (assignable) {
+                    methods.add(method);
+                }
+            }
+        }
+        return methods;
+    }
+
+    public static PropertyDescriptor[] getPropertyDescriptors(Class clazz, boolean allowFieldInjection) {
+        PropertyDescriptor[][] properties = beanInfos.get(clazz);
+        int index = allowFieldInjection ? 0 : 1;
+        
+        if (properties == null) {
+            properties = new PropertyDescriptor[2][];
+            beanInfos.put(clazz, properties);
+        }
+        
+        if (properties[index] == null) {
+            Map<String,PropertyDescriptor> props = new HashMap<String, PropertyDescriptor>();
+            for (Method method : clazz.getMethods()) {
+                if (Modifier.isStatic(method.getModifiers()) || method.isBridge()) {
+                    continue;
+                }
+                String name = method.getName();
+                Class<?> argTypes[] = method.getParameterTypes();
+                Class<?> resultType = method.getReturnType();
+                
+                Class<?> argType = resultType;
+                Method getter = null;
+                Method setter = null;
+                
+                if (name.length() > 3 && name.startsWith("set") && resultType == Void.TYPE && argTypes.length == 1) {
+                    name = decapitalize(name.substring(3));
+                    setter = method;
+                    argType = argTypes[0];
+                } else if (name.length() > 3 && name.startsWith("get") && argTypes.length == 0) {
+                    name = decapitalize(name.substring(3));
+                    getter = method;
+                } else if (name.length() > 2 && name.startsWith("is") && argTypes.length == 0 && resultType == boolean.class) {
+                    name = decapitalize(name.substring(2));
+                    getter = method;
+                } else {
+                    continue;
+                }
+                
+                if (props.containsKey(name)) {
+                    PropertyDescriptor pd = props.get(name);
+                    if (pd != INVALID_PROPERTY) {
+                        if (!argType.equals(pd.type)) {
+                            props.put(name, INVALID_PROPERTY);
+                        } else if (getter != null) {
+                            if (pd.getter == null || pd.getter.equals(getter))
+                                pd.getter = getter;
+                            else
+                                props.put(name, INVALID_PROPERTY);
+                        } else if (setter != null) {
+                            if (pd.setter == null || pd.setter.equals(setter)) 
+                                pd.setter = setter;
+                            else
+                                props.put(name, INVALID_PROPERTY);
+                        }
+                    }
+                } else {
+                    props.put(name, new PropertyDescriptor(name, argType, getter, setter));
+                }
+            }
+            
+            if (allowFieldInjection) {
+                for (Field field : clazz.getDeclaredFields()) {
+                    if (Modifier.isStatic(field.getModifiers())) {
+                        continue;
+                    }
+                    
+                    String name = decapitalize(field.getName());
+                    if (!props.containsKey(name)) {
+                        props.put(name, new PropertyDescriptor(name, field.getType(), field));
+                    } else {
+                        PropertyDescriptor pd = props.get(name);
+                        if (pd != INVALID_PROPERTY) {
+                            if (pd.type.equals(field.getType())) {
+                                pd.field = field;
+                            } 
+                            // no else, we don't require field implementations to have the same
+                            // type as the getter and setter
+                        }
+                    }
+                }
+            }
+            
+            Iterator<PropertyDescriptor> it = props.values().iterator();
+            while (it.hasNext()) {
+                if (it.next() == INVALID_PROPERTY)
+                    it.remove();
+            }
+            
+            Collection<PropertyDescriptor> tmp = props.values();
+            properties[index] = tmp.toArray(new PropertyDescriptor[tmp.size()]); 
+        }
+        return properties[index];
+    }
+
+    private static String decapitalize(String name) {
+        if (name == null || name.length() == 0) {
+            return name;
+        }
+        if (name.length() > 1 && Character.isUpperCase(name.charAt(1)) &&
+                Character.isUpperCase(name.charAt(0))) {
+            return name;
+        }
+        char chars[] = name.toCharArray();
+        chars[0] = Character.toLowerCase(chars[0]);
+        return new String(chars);
+    }
+
+    public static Object invoke(AccessControlContext acc, final Method method, final Object instance, final Object... args) throws Exception {
+        if (acc == null) {
+            return method.invoke(instance, args);
+        } else {
+            try {
+                return AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
+                    public Object run() throws Exception {
+                        return method.invoke(instance, args);
+                    }            
+                }, acc);
+            } catch (PrivilegedActionException e) {
+                throw e.getException();
+            }
+        }
+    }
+    
+    public static Object newInstance(AccessControlContext acc, final Class clazz) throws Exception {
+        if (acc == null) {
+            return clazz.newInstance();
+        } else {
+            try {
+                return AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
+                    public Object run() throws Exception {
+                        return clazz.newInstance();
+                    }            
+                }, acc);
+            } catch (PrivilegedActionException e) {
+                throw e.getException();
+            }
+        }
+    }
+    
+    public static Object newInstance(AccessControlContext acc, final Constructor constructor, final Object... args) throws Exception {
+        if (acc == null) {
+            return constructor.newInstance(args);
+        } else {
+            try {
+                return AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
+                    public Object run() throws Exception {
+                        return constructor.newInstance(args);
+                    }            
+                }, acc);
+            } catch (PrivilegedActionException e) {
+                throw e.getException();
+            }
+        }
+    }
+    
+    private static final PropertyDescriptor INVALID_PROPERTY = new PropertyDescriptor(null, null, null, null);
+
+    public static class PropertyDescriptor {
+        private String name;
+        private Class<?> type;
+        private Method getter;
+        private Method setter;
+        private Field field;
+
+        public PropertyDescriptor(String name, Class<?> type, Method getter, Method setter) {
+            this.name = name;
+            this.type = type;
+            this.getter = getter;
+            this.setter = setter;
+        }
+        
+        public PropertyDescriptor(String name, Class<?> type, Field field) {
+            this.name = name;
+            this.type = type;
+            this.field = field;
+            this.getter = null;
+            this.setter = null;
+        }
+
+        public String getName() {
+            return name;
+        }
+        
+        public boolean allowsGet() {
+            return getter != null || field != null;
+        }
+        
+        public boolean allowsSet() {
+            return setter != null || field != null;
+        }
+        
+        public Object get(final Object instance, AccessControlContext acc) throws Exception {            
+            if (acc == null) {
+                return internalGet(instance);
+            } else {
+                try {
+                    return AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
+                        public Object run() throws Exception {
+                            return internalGet(instance);
+                        }            
+                    }, acc);
+                } catch (PrivilegedActionException e) {
+                    throw e.getException();
+                }
+            }
+        }
+            
+        private Object internalGet(Object instance) 
+                throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
+            if (getter != null) {
+                return getter.invoke(instance);
+            } else if (field != null) {
+                field.setAccessible(true);
+                return field.get(instance);
+            } else {
+                throw new UnsupportedOperationException();
+            }
+        }
+
+        public void set(final Object instance, final Object value, AccessControlContext acc) throws Exception {
+            if (acc == null) {
+                internalSet(instance, value);
+            } else {
+                try {
+                    AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
+                        public Object run() throws Exception {
+                            internalSet(instance, value);
+                            return null;
+                        }            
+                    }, acc);
+                } catch (PrivilegedActionException e) {
+                    throw e.getException();
+                }
+            }            
+        }
+        
+        private void internalSet(Object instance, Object value) 
+                throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
+            if (setter != null) {
+                setter.invoke(instance, value);
+            } else if (field != null) {
+                field.setAccessible(true);
+                field.set(instance, value);
+            } else {
+                throw new UnsupportedOperationException();
+            }
+        }
+        
+        public Type getGenericType() {
+            if (setter != null)
+                return setter.getGenericParameterTypes()[0];
+            else if (getter != null)
+                return getter.getGenericReturnType();
+            else 
+                return field.getGenericType();
+                
+        }
+        
+        public String toString() {
+            return "PropertyDescriptor <name: "+name+", getter: "+getter+", setter: "+setter+
+                ", field: "+field+">";
+        }
+    }
+
+    public static Throwable getRealCause(Throwable t) {
+        if (t instanceof InvocationTargetException && t.getCause() != null) {
+            return t.getCause();
+        }
+        return t;
+    }
+
+}

Added: aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/resources/OSGI-INF/blueprint/blueprint-ext.xml
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/resources/OSGI-INF/blueprint/blueprint-ext.xml?rev=1075094&view=auto
==============================================================================
--- aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/resources/OSGI-INF/blueprint/blueprint-ext.xml (added)
+++ aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/resources/OSGI-INF/blueprint/blueprint-ext.xml Sun Feb 27 17:47:08 2011
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+
+    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.
+
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+    <service interface="org.apache.aries.blueprint.NamespaceHandler">
+        <service-properties>
+            <entry key="osgi.service.blueprint.namespace" value="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"/>
+        </service-properties>
+        <bean class="org.apache.aries.blueprint.ext.ExtNamespaceHandler"/>
+    </service>
+
+</blueprint>

Added: aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/resources/OSGI-INF/permissions.perm
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/resources/OSGI-INF/permissions.perm?rev=1075094&view=auto
==============================================================================
--- aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/resources/OSGI-INF/permissions.perm (added)
+++ aries/tags/blueprint-0.1-incubating/blueprint-core/src/main/resources/OSGI-INF/permissions.perm Sun Feb 27 17:47:08 2011
@@ -0,0 +1,26 @@
+################################################################################
+#
+#    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.
+#
+################################################################################
+# Lines beginning with '#' or '//' are comments
+#
+# This file contains the permissions to be granted.
+# The permissions are listed one per
+# line in PermissionInfo encoded format.
+# See org.osgi.service.permissionadmin.PermissionInfo
+
+(java.security.AllPermission "" "")