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 22:21:22 UTC
svn commit: r1075149 [17/23] - in /aries/tags/blueprint-0.3.1: ./
blueprint-annotation-api/ blueprint-annotation-api/src/
blueprint-annotation-api/src/main/ blueprint-annotation-api/src/main/java/
blueprint-annotation-api/src/main/java/org/ blueprint-a...
Added: aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/IdRefMetadataImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/IdRefMetadataImpl.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/IdRefMetadataImpl.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/IdRefMetadataImpl.java Sun Feb 27 21:21:05 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.MutableIdRefMetadata;
+import org.osgi.service.blueprint.reflect.IdRefMetadata;
+
+/**
+ * Implementation of IdRefMetadata
+ *
+ * @version $Rev: 896324 $, $Date: 2010-01-06 06:05:04 +0000 (Wed, 06 Jan 2010) $
+ */
+public class IdRefMetadataImpl implements MutableIdRefMetadata {
+
+ protected String componentId;
+
+ public IdRefMetadataImpl() {
+ }
+
+ public IdRefMetadataImpl(String componentId) {
+ this.componentId = componentId;
+ }
+
+ public IdRefMetadataImpl(IdRefMetadata source) {
+ componentId = source.getComponentId();
+ }
+
+ public String getComponentId() {
+ return componentId;
+ }
+
+ public void setComponentId(String componentId) {
+ this.componentId = componentId;
+ }
+
+ @Override
+ public String toString() {
+ return "IdRefMetadata[" +
+ "componentId='" + componentId + '\'' +
+ ']';
+ }
+}
Added: aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/MapEntryImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/MapEntryImpl.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/MapEntryImpl.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/MapEntryImpl.java Sun Feb 27 21:21:05 2011
@@ -0,0 +1,72 @@
+/*
+ * 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.MutableMapEntry;
+import org.osgi.service.blueprint.reflect.MapEntry;
+import org.osgi.service.blueprint.reflect.Metadata;
+import org.osgi.service.blueprint.reflect.NonNullMetadata;
+
+/**
+ * Implementation of MapEntry
+ *
+ * @version $Rev: 896324 $, $Date: 2010-01-06 06:05:04 +0000 (Wed, 06 Jan 2010) $
+ */
+public class MapEntryImpl implements MutableMapEntry {
+
+ private NonNullMetadata key;
+ private Metadata value;
+
+ public MapEntryImpl() {
+ }
+
+ public MapEntryImpl(NonNullMetadata key, Metadata value) {
+ this.key = key;
+ this.value = value;
+ }
+
+ public MapEntryImpl(MapEntry entry) {
+ this.key = (NonNullMetadata) MetadataUtil.cloneMetadata(entry.getKey());
+ this.value = MetadataUtil.cloneMetadata(entry.getValue());
+ }
+
+ public NonNullMetadata getKey() {
+ return key;
+ }
+
+ public void setKey(NonNullMetadata key) {
+ this.key = key;
+ }
+
+ public Metadata getValue() {
+ return value;
+ }
+
+ public void setValue(Metadata value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return "MapEntry[" +
+ "key=" + key +
+ ", value=" + value +
+ ']';
+ }
+}
Added: aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/MapMetadataImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/MapMetadataImpl.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/MapMetadataImpl.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/MapMetadataImpl.java Sun Feb 27 21:21:05 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.reflect;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.aries.blueprint.mutable.MutableMapMetadata;
+import org.osgi.service.blueprint.reflect.MapEntry;
+import org.osgi.service.blueprint.reflect.MapMetadata;
+import org.osgi.service.blueprint.reflect.Metadata;
+import org.osgi.service.blueprint.reflect.NonNullMetadata;
+
+/**
+ * Implementation of MapMetadata
+ *
+ * @version $Rev: 896324 $, $Date: 2010-01-06 06:05:04 +0000 (Wed, 06 Jan 2010) $
+ */
+public class MapMetadataImpl implements MutableMapMetadata {
+
+ private String keyType;
+ private String valueType;
+ private List<MapEntry> entries;
+
+ public MapMetadataImpl() {
+ }
+
+ public MapMetadataImpl(String keyType, String valueType, List<MapEntry> entries) {
+ this.keyType = keyType;
+ this.valueType = valueType;
+ this.entries = entries;
+ }
+
+ public MapMetadataImpl(MapMetadata source) {
+ this.valueType = source.getValueType();
+ this.keyType = source.getKeyType();
+ for (MapEntry entry : source.getEntries()) {
+ addEntry(new MapEntryImpl(entry));
+ }
+ }
+
+ public String getKeyType() {
+ return this.keyType;
+ }
+
+ public void setKeyType(String keyTypeName) {
+ this.keyType = keyTypeName;
+ }
+
+ public String getValueType() {
+ return this.valueType;
+ }
+
+ public void setValueType(String valueTypeName) {
+ this.valueType = valueTypeName;
+ }
+
+ 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 "MapMetadata[" +
+ "keyType='" + keyType + '\'' +
+ ", valueType='" + valueType + '\'' +
+ ", entries=" + entries +
+ ']';
+ }
+}
Added: aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/MetadataUtil.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/MetadataUtil.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/MetadataUtil.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/MetadataUtil.java Sun Feb 27 21:21:05 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.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/PassThroughMetadataImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/PassThroughMetadataImpl.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/PassThroughMetadataImpl.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/PassThroughMetadataImpl.java Sun Feb 27 21:21:05 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.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/PropsMetadataImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/PropsMetadataImpl.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/PropsMetadataImpl.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/PropsMetadataImpl.java Sun Feb 27 21:21:05 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.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/RefMetadataImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/RefMetadataImpl.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/RefMetadataImpl.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/RefMetadataImpl.java Sun Feb 27 21:21:05 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.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ReferenceListMetadataImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ReferenceListMetadataImpl.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ReferenceListMetadataImpl.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ReferenceListMetadataImpl.java Sun Feb 27 21:21:05 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.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ReferenceListenerImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ReferenceListenerImpl.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ReferenceListenerImpl.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ReferenceListenerImpl.java Sun Feb 27 21:21:05 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.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ReferenceMetadataImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ReferenceMetadataImpl.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ReferenceMetadataImpl.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ReferenceMetadataImpl.java Sun Feb 27 21:21:05 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.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/RegistrationListenerImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/RegistrationListenerImpl.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/RegistrationListenerImpl.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/RegistrationListenerImpl.java Sun Feb 27 21:21:05 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.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ServiceMetadataImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ServiceMetadataImpl.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ServiceMetadataImpl.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ServiceMetadataImpl.java Sun Feb 27 21:21:05 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.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ServiceReferenceMetadataImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ServiceReferenceMetadataImpl.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ServiceReferenceMetadataImpl.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ServiceReferenceMetadataImpl.java Sun Feb 27 21:21:05 2011
@@ -0,0 +1,137 @@
+/*
+ * 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: 950985 $, $Date: 2010-06-03 14:19:22 +0100 (Thu, 03 Jun 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;
+ protected Class runtimeInterface;
+
+ 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;
+ }
+
+ public Class getRuntimeInterface() {
+ return runtimeInterface;
+ }
+
+ public void setRuntimeInterface(Class runtimeInterface) {
+ this.runtimeInterface = runtimeInterface;
+ }
+}
Added: aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ValueMetadataImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ValueMetadataImpl.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ValueMetadataImpl.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/reflect/ValueMetadataImpl.java Sun Feb 27 21:21:05 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.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/BundleDelegatingClassLoader.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/BundleDelegatingClassLoader.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/BundleDelegatingClassLoader.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/BundleDelegatingClassLoader.java Sun Feb 27 21:21:05 2011
@@ -0,0 +1,132 @@
+/*
+ * 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.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+
+import org.osgi.framework.Bundle;
+
+/**
+ * A ClassLoader delegating to a given OSGi bundle.
+ *
+ * @version $Rev: 954428 $, $Date: 2010-06-14 13:32:07 +0100 (Mon, 14 Jun 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(final String name) throws ClassNotFoundException {
+ try {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
+ public Class<?> run() throws ClassNotFoundException
+ {
+ return bundle.loadClass(name);
+ }
+
+ });
+ } catch (PrivilegedActionException e) {
+ Exception cause = e.getException();
+
+ if (cause instanceof ClassNotFoundException) throw (ClassNotFoundException)cause;
+ else throw (RuntimeException)cause;
+ }
+ }
+
+ protected URL findResource(final String name) {
+ URL resource = AccessController.doPrivileged(new PrivilegedAction<URL>() {
+ public URL run()
+ {
+ return bundle.getResource(name);
+ }
+ });
+ if (classLoader != null && resource == null) {
+ resource = classLoader.getResource(name);
+ }
+ return resource;
+ }
+
+ protected Enumeration findResources(final String name) throws IOException {
+ Enumeration<URL> urls;
+ try {
+ urls = AccessController.doPrivileged(new PrivilegedExceptionAction<Enumeration<URL>>() {
+ @SuppressWarnings("unchecked")
+ public Enumeration<URL> run() throws IOException
+ {
+ return (Enumeration<URL>)bundle.getResources(name);
+ }
+
+ });
+ } catch (PrivilegedActionException e) {
+ Exception cause = e.getException();
+
+ if (cause instanceof IOException) throw (IOException)cause;
+ else throw (RuntimeException)cause;
+ }
+
+ if (urls == null) {
+ urls = Collections.enumeration(new ArrayList<URL>());
+ }
+
+ return urls;
+ }
+
+ 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.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/DynamicCollection.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/DynamicCollection.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/DynamicCollection.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/DynamicCollection.java Sun Feb 27 21:21:05 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.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/HeaderParser.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/HeaderParser.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/HeaderParser.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/HeaderParser.java Sun Feb 27 21:21:05 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.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/JavaUtils.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/JavaUtils.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/JavaUtils.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/JavaUtils.java Sun Feb 27 21:21:05 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;
+ }
+
+}