You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by pd...@apache.org on 2018/09/26 16:45:39 UTC
svn commit: r1842034 [4/11] - in /felix/trunk/dependencymanager: ./
.gradle-wrapper/ cnf/ cnf/buildrepo/ cnf/ext/ cnf/localrepo/
cnf/localrepo/org.apache.felix.gogo.command/
cnf/localrepo/org.apache.felix.gogo.jline/
cnf/localrepo/org.apache.felix.gogo...
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceCallbacksBuilder.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceCallbacksBuilder.java?rev=1842034&r1=1842033&r2=1842034&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceCallbacksBuilder.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceCallbacksBuilder.java Wed Sep 26 16:45:35 2018
@@ -29,6 +29,8 @@ import org.apache.felix.dm.lambda.callba
import org.apache.felix.dm.lambda.callbacks.CbServiceComponentRef;
import org.apache.felix.dm.lambda.callbacks.CbServiceDict;
import org.apache.felix.dm.lambda.callbacks.CbServiceMap;
+import org.apache.felix.dm.lambda.callbacks.CbServiceObjects;
+import org.apache.felix.dm.lambda.callbacks.CbServiceObjectsServiceObjects;
import org.apache.felix.dm.lambda.callbacks.CbServiceRef;
import org.apache.felix.dm.lambda.callbacks.CbServiceService;
import org.apache.felix.dm.lambda.callbacks.CbServiceServiceComponent;
@@ -43,6 +45,8 @@ import org.apache.felix.dm.lambda.callba
import org.apache.felix.dm.lambda.callbacks.InstanceCbServiceComponentRef;
import org.apache.felix.dm.lambda.callbacks.InstanceCbServiceDict;
import org.apache.felix.dm.lambda.callbacks.InstanceCbServiceMap;
+import org.apache.felix.dm.lambda.callbacks.InstanceCbServiceObjects;
+import org.apache.felix.dm.lambda.callbacks.InstanceCbServiceObjectsServiceObjects;
import org.apache.felix.dm.lambda.callbacks.InstanceCbServiceRef;
import org.apache.felix.dm.lambda.callbacks.InstanceCbServiceService;
import org.apache.felix.dm.lambda.callbacks.InstanceCbServiceServiceComponent;
@@ -62,13 +66,17 @@ import org.osgi.annotation.versioning.Pr
* method(S service, Dictionary<String, Object> serviceProperties)
* method(ServiceReference<S> serviceRef, S service),
* method(ServiceReference<S> serviceRef)
+ * method(ServiceObjects<S> serviceObjects)
* method(Component serviceComponent)
* method(Component serviceComponent, ServiceReference<S> serviceRef)
* method(Component serviceComponent, S service)
* method(Component serviceComponent, ServiceReference<S> serviceRef, S service)
* swapMethod(S oldService, S newService)
* swapMethod(ServiceReference<S> oldRef, S old, ServiceReference<S> newRef, S newService)
+ * swapMethod(ServiceReference<S> oldRef, ServiceReference<S> newRef)
+ * swapMethod(ServiceObjects<S> oldServiceObjects, ServiceObjects<S> newServiceObjects)
* swapMethod(Component component, S oldService, S newService)
+ * swapMethod(Component component, ServiceReference<S> oldService, ServiceReference<S> newService)
* swapMethod(Component component, ServiceReference<S> oldRef, S old, ServiceReference<S> newRef, S newService)
* }</pre>
*
@@ -82,6 +90,7 @@ import org.osgi.annotation.versioning.Pr
* method(S service, Component serviceComponent)
* method(S service, Component serviceComponent, ServiceReference<S> serviceRef)
* method(ServiceReference<S> service)
+ * method(ServiceObjects<S> service)
* method(ServiceReference<S> service, Component serviceComponent)
* swapMethod(S oldService, S newService)
* swapMethod(ServiceReference<> oldRef, ServiceReference<S> newRef)
@@ -435,6 +444,36 @@ public interface ServiceCallbacksBuilder
<T> B remove(CbRef<T, S> remove);
/**
+ * Sets a <code>component callback(ServiceObjects ref)</code> method reference. The callback is invoked when a service is added.
+ * The method reference must point to a Component implementation class method.
+ *
+ * @param <T> the type of the component implementation class on which the callback is invoked.
+ * @param add the method reference invoked when a service is added.
+ * @return this builder
+ */
+ <T> B add(CbServiceObjects<T, S> add);
+
+ /**
+ * Sets a <code>component callback(ServiceObjects)</code> method reference. The callback is invoked when a service is changed.
+ * The method reference must point to a Component implementation class method.
+ *
+ * @param <T> the type of the component implementation class on which the callback is invoked.
+ * @param change the method reference invoked when a service is changed.
+ * @return this builder
+ */
+ <T> B change(CbServiceObjects<T, S> change);
+
+ /**
+ * Sets a <code>component callback(ServiceObjects)</code> method reference. The callback is invoked when a service is removed.
+ * The method reference must point to a Component implementation class method.
+ *
+ * @param <T> the type of the component implementation class on which the callback is invoked.
+ * @param remove the method reference invoked when a service is removed.
+ * @return this builder
+ */
+ <T> B remove(CbServiceObjects<T, S> remove);
+
+ /**
* Sets a <code>component callback(ServiceReference ref, Component comp)</code> method reference. The callback is invoked when a service is added.
* The method reference must point to a Component implementation class method.
*
@@ -600,6 +639,33 @@ public interface ServiceCallbacksBuilder
B remove(InstanceCbRef<S> remove);
/**
+ * Sets an <code>Object instance callback(ServiceObjects)</code> method reference. The callback is invoked when a service is added.
+ * The method reference must point to a method from an Object instance.
+ *
+ * @param add the method reference invoked when a service is added.
+ * @return this builder
+ */
+ B add(InstanceCbServiceObjects<S> add);
+
+ /**
+ * Sets an <code>Object instance callback(ServiceObjects)</code> method reference. The callback is invoked when a service is changed.
+ * The method reference must point to method from an Object instance.
+ *
+ * @param change the method reference invoked when a service is changed.
+ * @return this builder
+ */
+ B change(InstanceCbServiceObjects<S> change);
+
+ /**
+ * Sets an <code>Object instance callback(ServiceObjects)</code> method reference. The callback is invoked when a service is removed.
+ * The method reference must point to method from an Object instance.
+ *
+ * @param remove the method reference invoked when a service is removed.
+ * @return this builder
+ */
+ B remove(InstanceCbServiceObjects<S> remove);
+
+ /**
* Sets an <code>Object instance callback(Service, Component)</code> method reference. The callback is when a service is added.
* The method reference must point to a method from an Object instance.
*
@@ -701,6 +767,16 @@ public interface ServiceCallbacksBuilder
<T> B swap(CbRefRef<T, S> swap);
/**
+ * Sets a swap <code>component callback(ServiceObjects, ServiceObjects)</code> method reference. The callback is invoked when a service is swapped.
+ * The method reference must point to a Component implementation class method.
+ *
+ * @param <T> the type of the component implementation class on which the callback is invoked.
+ * @param swap the method reference invoked when the service is swapped.
+ * @return this builder
+ */
+ <T> B swap(CbServiceObjectsServiceObjects<T, S> swap);
+
+ /**
* Sets a swap <code>component callback(Service, Service, Component)</code> method reference. The callback is invoked when a service is swapped.
* The method reference must point to a Component implementation class method.
*
@@ -761,6 +837,15 @@ public interface ServiceCallbacksBuilder
B swap(InstanceCbRefRef<S> swap);
/**
+ * Sets a swap <code>instance callback(ServiceObjects, ServiceObjects)</code> method reference. The callback is invoked when a service is swapped.
+ * The method reference must point to a method from an Object instance.
+ *
+ * @param swap the method reference invoked when the service is swapped.
+ * @return this builder
+ */
+ B swap(InstanceCbServiceObjectsServiceObjects<S> swap);
+
+ /**
* Sets a swap <code>instance callback(ServiceReference, ServiceReference, Component)</code> method reference. The callback is invoked when a service is swapped.
* The method reference must point to a method from an Object instance.
*
Added: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbServiceObjects.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbServiceObjects.java?rev=1842034&view=auto
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbServiceObjects.java (added)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbServiceObjects.java Wed Sep 26 16:45:35 2018
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.dm.lambda.callbacks;
+
+import java.util.Objects;
+
+import org.osgi.framework.ServiceObjects;
+
+/**
+ * Represents a callback(ServiceObjects) that is invoked on a Component implementation class.
+ * The type of the class on which the callback is invoked on is represented by the T generic parameter.
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+@FunctionalInterface
+public interface CbServiceObjects<T, S> extends SerializableLambda {
+ /**
+ * Handles the given arguments.
+ * @param instance the Component implementation instance on which the callback is invoked on.
+ * @param ref a Service Reference
+ */
+ void accept(T instance, ServiceObjects<S> ref);
+
+ default CbServiceObjects<T, S> andThen(CbServiceObjects<? super T, S> after) {
+ Objects.requireNonNull(after);
+ return (T instance, ServiceObjects<S> ref) -> {
+ accept(instance, ref);
+ after.accept(instance, ref);
+ };
+ }
+}
Added: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbServiceObjectsServiceObjects.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbServiceObjectsServiceObjects.java?rev=1842034&view=auto
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbServiceObjectsServiceObjects.java (added)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbServiceObjectsServiceObjects.java Wed Sep 26 16:45:35 2018
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.dm.lambda.callbacks;
+
+import java.util.Objects;
+
+import org.osgi.framework.ServiceObjects;
+
+/**
+ * Represents a callback(ServiceObjects, ServiceObjects) that is invoked on a Component implementation class.
+ * The type of the class on which the callback is invoked on is represented by the T generic parameter.
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+@FunctionalInterface
+public interface CbServiceObjectsServiceObjects<T, S> extends SerializableLambda {
+ /**
+ * Handles the given arguments.
+ * @param instance the Component implementation instance on which the callback is invoked on.
+ * @param ref1 first callback arg
+ * @param ref2 second callback arg
+ */
+ void accept(T instance, ServiceObjects<S> ref1, ServiceObjects<S> ref2);
+
+ default CbServiceObjectsServiceObjects<T, S> andThen(CbServiceObjectsServiceObjects<? super T, S> after) {
+ Objects.requireNonNull(after);
+ return (T instance, ServiceObjects<S> ref1, ServiceObjects<S> ref2) -> {
+ accept(instance, ref1, ref2);
+ after.accept(instance, ref1, ref2);
+ };
+ }
+}
Added: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/InstanceCbServiceObjects.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/InstanceCbServiceObjects.java?rev=1842034&view=auto
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/InstanceCbServiceObjects.java (added)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/InstanceCbServiceObjects.java Wed Sep 26 16:45:35 2018
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.dm.lambda.callbacks;
+
+import java.util.Objects;
+
+import org.osgi.framework.ServiceObjects;
+
+/**
+ * Represents a callback(ServiceObjects) on an Object instance.
+ *
+ * <p> The type of the service passed in argument to the callback is defined by the "S" generic parameter.
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+@FunctionalInterface
+public interface InstanceCbServiceObjects<S> {
+ /**
+ * Handles the given arguments.
+ * @param ref a Service Reference
+ * @param service a Service
+ */
+ void accept(ServiceObjects<S> ref);
+
+ default InstanceCbServiceObjects<S> andThen(InstanceCbServiceObjects<S> after) {
+ Objects.requireNonNull(after);
+ return (ServiceObjects<S> ref) -> {
+ accept(ref);
+ after.accept(ref);
+ };
+ }
+}
Added: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/InstanceCbServiceObjectsServiceObjects.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/InstanceCbServiceObjectsServiceObjects.java?rev=1842034&view=auto
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/InstanceCbServiceObjectsServiceObjects.java (added)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/InstanceCbServiceObjectsServiceObjects.java Wed Sep 26 16:45:35 2018
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.dm.lambda.callbacks;
+
+import java.util.Objects;
+
+import org.osgi.framework.ServiceObjects;
+
+/**
+ * Represents a swap callback(ServoceObjects, ServoceObjects) on an Object instance.
+ *
+ * <p> The type of the service passed in argument to the callback is defined by the "S" generic parameter.
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+@FunctionalInterface
+public interface InstanceCbServiceObjectsServiceObjects<S> extends SerializableLambda {
+ /**
+ * Handles the given argument
+ * @param ref1 a Service Reference
+ * @param ref2 a Service Reference
+ */
+ void accept(ServiceObjects<S> ref1, ServiceObjects<S> ref2);
+
+ default InstanceCbServiceObjectsServiceObjects<S> andThen(InstanceCbServiceObjectsServiceObjects<S> after) {
+ Objects.requireNonNull(after);
+ return (ServiceObjects<S> ref1, ServiceObjects<S> ref2) -> {
+ accept(ref1, ref2);
+ after.accept(ref1, ref2);
+ };
+ }
+}
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/packageinfo
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/packageinfo?rev=1842034&r1=1842033&r2=1842034&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/packageinfo (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/packageinfo Wed Sep 26 16:45:35 2018
@@ -1 +1 @@
-version 1.1.0
+version 1.2.0
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/AdapterBase.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/AdapterBase.java?rev=1842034&r1=1842033&r2=1842034&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/AdapterBase.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/AdapterBase.java Wed Sep 26 16:45:35 2018
@@ -24,6 +24,7 @@ import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
+import org.apache.felix.dm.Component.ServiceScope;
import org.apache.felix.dm.ComponentStateListener;
import org.apache.felix.dm.Dependency;
import org.apache.felix.dm.lambda.BundleDependencyBuilder;
@@ -45,6 +46,11 @@ public interface AdapterBase<B extends C
void andThenBuild(Consumer<ComponentBuilder<?>> builder);
+ default B scope(ServiceScope scope) {
+ andThenBuild(compBuilder -> compBuilder.scope(scope));
+ return (B) this;
+ }
+
default B impl(Object impl) {
andThenBuild(compBuilder -> compBuilder.impl(impl));
return (B) this;
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ComponentBuilderImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ComponentBuilderImpl.java?rev=1842034&r1=1842033&r2=1842034&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ComponentBuilderImpl.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ComponentBuilderImpl.java Wed Sep 26 16:45:35 2018
@@ -38,6 +38,7 @@ import java.util.function.Supplier;
import java.util.stream.Stream;
import org.apache.felix.dm.Component;
+import org.apache.felix.dm.Component.ServiceScope;
import org.apache.felix.dm.ComponentStateListener;
import org.apache.felix.dm.Dependency;
import org.apache.felix.dm.DependencyManager;
@@ -95,6 +96,12 @@ public class ComponentBuilderImpl implem
m_component = component;
m_componentUpdated = update;
}
+
+ @Override
+ public ComponentBuilderImpl scope(ServiceScope scope) {
+ m_component.setScope(scope);
+ return this;
+ }
@Override
public ComponentBuilderImpl autoConfig(Class<?> clazz, boolean autoConfig) {
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ConfigurationDependencyBuilderImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ConfigurationDependencyBuilderImpl.java?rev=1842034&r1=1842033&r2=1842034&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ConfigurationDependencyBuilderImpl.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ConfigurationDependencyBuilderImpl.java Wed Sep 26 16:45:35 2018
@@ -139,7 +139,7 @@ public class ConfigurationDependencyBuil
Class<T> componentType = Helpers.getLambdaArgType(callback, 0);
m_pid = m_pid == null ? configClass.getName() : m_pid;
return setComponentCallbackRef(componentType, (instance, component, props) -> {
- U configProxy = ((ComponentContext) m_component).createConfigurationType(configClass, props);
+ U configProxy = ((ComponentContext<?>) m_component).createConfigurationType(configClass, props);
callback.accept((T) instance, configProxy);
});
}
@@ -149,7 +149,7 @@ public class ConfigurationDependencyBuil
Class<T> componentType = Helpers.getLambdaArgType(callback, 0);
m_pid = m_pid == null ? configClass.getName() : m_pid;
return setComponentCallbackRef(componentType, (instance, component, props) -> {
- U configProxy = ((ComponentContext) m_component).createConfigurationType(configClass, props);
+ U configProxy = ((ComponentContext<?>) m_component).createConfigurationType(configClass, props);
callback.accept((T) instance, configProxy, component);
});
}
@@ -171,7 +171,7 @@ public class ConfigurationDependencyBuil
public <T> ConfigurationDependencyBuilder update(Class<T> configClass, InstanceCbConfiguration<T> updated) {
m_pid = m_pid == null ? configClass.getName() : m_pid;
return setInstanceCallbackRef((instance, component, props) -> {
- T configProxy = ((ComponentContext) m_component).createConfigurationType(configClass, props);
+ T configProxy = ((ComponentContext<?>) m_component).createConfigurationType(configClass, props);
updated.accept(configProxy);
});
}
@@ -179,7 +179,7 @@ public class ConfigurationDependencyBuil
public <T> ConfigurationDependencyBuilder update(Class<T> configClass, InstanceCbConfigurationComponent<T> updated) {
m_pid = m_pid == null ? configClass.getName() : m_pid;
return setInstanceCallbackRef((instance, component, props) -> {
- T configProxy = ((ComponentContext) m_component).createConfigurationType(configClass, props);
+ T configProxy = ((ComponentContext<?>) m_component).createConfigurationType(configClass, props);
updated.accept(configProxy, component);
});
}
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/FactoryPidAdapterBuilderImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/FactoryPidAdapterBuilderImpl.java?rev=1842034&r1=1842033&r2=1842034&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/FactoryPidAdapterBuilderImpl.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/FactoryPidAdapterBuilderImpl.java Wed Sep 26 16:45:35 2018
@@ -133,7 +133,7 @@ public class FactoryPidAdapterBuilderImp
Class<T> type = Helpers.getLambdaArgType(callback, 0);
m_factoryPid = m_factoryPid == null ? configType.getName() : m_factoryPid;
return setComponentCallbackRef(type, (instance, component, props) -> {
- U configProxy = ((ComponentContext) component).createConfigurationType(configType, props);
+ U configProxy = ((ComponentContext<?>) component).createConfigurationType(configType, props);
callback.accept((T) instance, configProxy);
});
}
@@ -149,7 +149,7 @@ public class FactoryPidAdapterBuilderImp
Class<T> type = Helpers.getLambdaArgType(callback, 0);
m_factoryPid = m_factoryPid == null ? configType.getName() : m_factoryPid;
return setComponentCallbackRef(type, (instance, component, props) -> {
- U configProxy = ((ComponentContext) component).createConfigurationType(configType, props);
+ U configProxy = ((ComponentContext<?>) component).createConfigurationType(configType, props);
callback.accept((T) instance, configProxy, component);
});
}
@@ -162,7 +162,7 @@ public class FactoryPidAdapterBuilderImp
@Override
public <T> FactoryPidAdapterBuilder update(Class<T> configType, InstanceCbConfiguration<T> callback) {
return setInstanceCallbackRef((instance, component, props) -> {
- T configProxy = ((ComponentContext) component).createConfigurationType(configType, props);
+ T configProxy = ((ComponentContext<?>) component).createConfigurationType(configType, props);
callback.accept(configProxy);
});
}
@@ -175,7 +175,7 @@ public class FactoryPidAdapterBuilderImp
@Override
public <T> FactoryPidAdapterBuilder update(Class<T> configType, InstanceCbConfigurationComponent<T> callback) {
return setInstanceCallbackRef((instance, component, props) -> {
- T configProxy = ((ComponentContext) component).createConfigurationType(configType, props);
+ T configProxy = ((ComponentContext<?>) component).createConfigurationType(configType, props);
callback.accept(configProxy, component);
});
}
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceCallbacksBuilderImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceCallbacksBuilderImpl.java?rev=1842034&r1=1842033&r2=1842034&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceCallbacksBuilderImpl.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceCallbacksBuilderImpl.java Wed Sep 26 16:45:35 2018
@@ -37,6 +37,8 @@ import org.apache.felix.dm.lambda.callba
import org.apache.felix.dm.lambda.callbacks.CbServiceComponentRef;
import org.apache.felix.dm.lambda.callbacks.CbServiceDict;
import org.apache.felix.dm.lambda.callbacks.CbServiceMap;
+import org.apache.felix.dm.lambda.callbacks.CbServiceObjects;
+import org.apache.felix.dm.lambda.callbacks.CbServiceObjectsServiceObjects;
import org.apache.felix.dm.lambda.callbacks.CbServiceRef;
import org.apache.felix.dm.lambda.callbacks.CbServiceService;
import org.apache.felix.dm.lambda.callbacks.CbServiceServiceComponent;
@@ -51,6 +53,8 @@ import org.apache.felix.dm.lambda.callba
import org.apache.felix.dm.lambda.callbacks.InstanceCbServiceComponentRef;
import org.apache.felix.dm.lambda.callbacks.InstanceCbServiceDict;
import org.apache.felix.dm.lambda.callbacks.InstanceCbServiceMap;
+import org.apache.felix.dm.lambda.callbacks.InstanceCbServiceObjects;
+import org.apache.felix.dm.lambda.callbacks.InstanceCbServiceObjectsServiceObjects;
import org.apache.felix.dm.lambda.callbacks.InstanceCbServiceRef;
import org.apache.felix.dm.lambda.callbacks.InstanceCbServiceService;
import org.apache.felix.dm.lambda.callbacks.InstanceCbServiceServiceComponent;
@@ -378,6 +382,29 @@ public class ServiceCallbacksBuilderImpl
return (B) this;
}
+ public B add(InstanceCbServiceObjects<S> add) {
+ return callbacks(add, null, null);
+ }
+
+ public B change(InstanceCbServiceObjects<S> change) {
+ return callbacks(null, change, null);
+ }
+
+ public B remove(InstanceCbServiceObjects<S> remove) {
+ return callbacks(null, null, remove);
+ }
+
+ public B callbacks(InstanceCbServiceObjects<S> add, InstanceCbServiceObjects<S> change, InstanceCbServiceObjects<S> remove) {
+ if (add != null)
+ setInstanceCallbackRef(Cb.ADD, (inst, comp, ref, srv) -> add.accept(ref.getBundle().getBundleContext().getServiceObjects(ref)));
+ if (change != null)
+ setInstanceCallbackRef(Cb.CHG, (inst, comp, ref, srv) -> change.accept(ref.getBundle().getBundleContext().getServiceObjects(ref)));
+ if (remove != null)
+ setInstanceCallbackRef(Cb.REM, (inst, comp, ref, srv) -> remove.accept(ref.getBundle().getBundleContext().getServiceObjects(ref)));
+ m_dereferenceServiceInternally = false;
+ return (B) this;
+ }
+
public <T> B add(CbServiceComponent<T, S> add) {
return callbacks(add, null, null);
}
@@ -467,6 +494,32 @@ public class ServiceCallbacksBuilderImpl
return (B) this;
}
+ public <T> B add(CbServiceObjects<T, S> add) {
+ return callbacks(add, null, null);
+ }
+
+ public <T> B change(CbServiceObjects<T, S> change) {
+ return callbacks(null, change, null);
+ }
+
+ public <T> B remove(CbServiceObjects<T, S> remove) {
+ return callbacks(null, null, remove);
+ }
+
+ private <T> B callbacks(CbServiceObjects<T, S> add, CbServiceObjects<T, S> change, CbServiceObjects<T, S> remove) {
+ if (add != null)
+ setComponentCallbackRef(Cb.ADD, Helpers.getLambdaArgType(add, 0), (inst, comp, ref, srv) -> add.accept((T) inst,
+ ref.getBundle().getBundleContext().getServiceObjects(ref)));
+ if (change != null)
+ setComponentCallbackRef(Cb.CHG, Helpers.getLambdaArgType(change, 0), (inst, comp, ref, srv) -> change.accept((T) inst,
+ ref.getBundle().getBundleContext().getServiceObjects(ref)));
+ if (remove != null)
+ setComponentCallbackRef(Cb.REM, Helpers.getLambdaArgType(remove, 0), (inst, comp, ref, srv) -> remove.accept((T) inst,
+ ref.getBundle().getBundleContext().getServiceObjects(ref)));
+ m_dereferenceServiceInternally = false;
+ return (B) this;
+ }
+
public <T> B add(CbRefComponent<T, S> add) {
return callbacks(add, null, null);
}
@@ -547,6 +600,15 @@ public class ServiceCallbacksBuilderImpl
swap.accept((T) inst, oref, nref));
}
+ public <T> B swap(CbServiceObjectsServiceObjects<T, S> swap) {
+ Class<T> type = Helpers.getLambdaArgType(swap, 0);
+ m_dereferenceServiceInternally = false;
+ return setComponentSwapCallbackRef(type, (inst, component, oref, oserv, nref, nserv) ->
+ swap.accept((T) inst,
+ oref.getBundle().getBundleContext().getServiceObjects(oref),
+ nref.getBundle().getBundleContext().getServiceObjects(nref)));
+ }
+
@Override
public <T> B swap(CbServiceServiceComponent<T, S> swap) {
Class<T> type = Helpers.getLambdaArgType(swap, 0);
@@ -583,6 +645,13 @@ public class ServiceCallbacksBuilderImpl
return setInstanceSwapCallbackRef((inst, component, oref, oserv, nref, nserv) -> swap.accept(oref, nref));
}
+ public B swap(InstanceCbServiceObjectsServiceObjects<S> swap) {
+ m_dereferenceServiceInternally = false;
+ return setInstanceSwapCallbackRef((inst, component, oref, oserv, nref, nserv) ->
+ swap.accept(oref.getBundle().getBundleContext().getServiceObjects(oref),
+ nref.getBundle().getBundleContext().getServiceObjects(nref)));
+ }
+
public B swap(InstanceCbServiceServiceComponent<S> swap) {
return setInstanceSwapCallbackRef((inst, component, oref, oserv, nref, nserv) -> swap.accept(oserv, nserv, component));
}
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/packageinfo
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/packageinfo?rev=1842034&r1=1842033&r2=1842034&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/packageinfo (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/packageinfo Wed Sep 26 16:45:35 2018
@@ -1 +1 @@
-version 1.1.0
\ No newline at end of file
+version 1.2.0
\ No newline at end of file
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/bnd.bnd
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/bnd.bnd?rev=1842034&r1=1842033&r2=1842034&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/bnd.bnd (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/bnd.bnd Wed Sep 26 16:45:35 2018
@@ -22,17 +22,20 @@
org.apache.felix.dependencymanager.itest.api;version=latest,\
osgi.core;version=6.0,\
osgi.cmpn;version=6.0
--runbundles: \
+-runbundles: \
+ org.apache.servicemix.bundles.junit;version=4.12,\
+ org.mockito.mockito-core;version='[1.10.19,1.10.20)',\
+ org.objenesis;version='[2.2.0,2.2.1)',\
+ org.apache.felix.metatype;version=1.1.2,\
+ org.apache.servicemix.bundles.junit;version=4.12,\
org.apache.felix.configadmin;version=1.8.8,\
- org.apache.felix.metatype;version=1.0.4,\
org.apache.felix.gogo.runtime;version=1.0.6,\
org.apache.felix.log;version=1.0.1,\
org.apache.felix.dependencymanager;version=latest,\
org.apache.felix.dependencymanager.runtime;version=latest,\
- org.apache.felix.dependencymanager.shell;version=latest,\
- biz.aQute.junit;version=3.0.0
+ org.apache.felix.dependencymanager.shell;version=latest
-runee: JavaSE-1.7
--runfw: org.apache.felix.framework;version='[5.2.0,5.2.0]'
+-runfw: org.apache.felix.framework;version='[5.6.10,5.6.10]'
-runsystempackages: \
sun.reflect
-runvm:-ea
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/AdapterAnnotation.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/AdapterAnnotation.java?rev=1842034&r1=1842033&r2=1842034&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/AdapterAnnotation.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/AdapterAnnotation.java Wed Sep 26 16:45:35 2018
@@ -69,7 +69,8 @@ public class AdapterAnnotation {
}
}
- @AdapterService(adapteeService = S1.class, properties = { @Property(name = "adapter", value = "true") })
+ @Property(name = "adapter", value = "true")
+ @AdapterService(adapteeService = S1.class)
public static class S1ToS3AdapterAutoConfig implements S3 {
public static final String ENSURE = "AdapterAnnotation.autoConfig";
@@ -128,7 +129,8 @@ public class AdapterAnnotation {
}
}
- @AdapterService(adapteeService = S1.class, properties = { @Property(name = "adapter", value = "true") }, field = "m_s1")
+ @AdapterService(adapteeService = S1.class, field = "m_s1")
+ @Property(name = "adapter", value = "true")
public static class S1ToS3AdapterAutoConfigField implements S3 {
public final static String ENSURE = "AdapterAnnotation.autoConfig.field";
// This is the adapted service
@@ -143,7 +145,8 @@ public class AdapterAnnotation {
}
}
- @AdapterService(adapteeService = S1.class, properties = { @Property(name = "adapter", value = "true") }, added = "bind", removed = "removed")
+ @AdapterService(adapteeService = S1.class, added = "bind", removed = "removed")
+ @Property(name = "adapter", value = "true")
public static class S1ToS3AdapterCallback implements S3 {
public final static String ENSURE = "AdapterAnnotation.callback";
// This is the adapted service
@@ -170,7 +173,8 @@ public class AdapterAnnotation {
}
}
- @Component(properties = { @Property(name = "param1", value = "value1") })
+ @Component
+ @Property(name = "param1", value = "value1")
public static class S1Impl implements S1 {
public final static String ENSURE = "AdapterAnnotation.S1Impl";
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/AdapterServiceTestWithPublisher.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/AdapterServiceTestWithPublisher.java?rev=1842034&r1=1842033&r2=1842034&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/AdapterServiceTestWithPublisher.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/AdapterServiceTestWithPublisher.java Wed Sep 26 16:45:35 2018
@@ -77,7 +77,8 @@ public class AdapterServiceTestWithPubli
}
}
- @Component(properties = {@Property(name = "foo", value = "bar")})
+ @Component
+ @Property(name = "foo", value = "bar")
public static class ProviderImpl implements Provider {
@Start
Map start() {
@@ -91,7 +92,8 @@ public class AdapterServiceTestWithPubli
}
}
- @AdapterService(properties = {@Property(name = "foo3", value = "bar3")}, adapteeService = Provider.class)
+ @AdapterService(adapteeService = Provider.class)
+ @Property(name = "foo3", value = "bar3")
public static class Provider2Impl implements Provider2 {
@LifecycleController
volatile Runnable m_publisher; // injected and used to register our service
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/BundleAdapterServiceTestWithPublisher.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/BundleAdapterServiceTestWithPublisher.java?rev=1842034&r1=1842033&r2=1842034&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/BundleAdapterServiceTestWithPublisher.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/BundleAdapterServiceTestWithPublisher.java Wed Sep 26 16:45:35 2018
@@ -72,8 +72,8 @@ public class BundleAdapterServiceTestWit
}
}
- @BundleAdapterService(properties = {@Property(name = "foo", value = "bar")}, filter = "(Bundle-SymbolicName=" + Utils.DM_BSN + ")", stateMask = Bundle.INSTALLED
- | Bundle.RESOLVED | Bundle.ACTIVE, propagate = true)
+ @BundleAdapterService(filter = "(Bundle-SymbolicName=" + Utils.DM_BSN + ")", stateMask = Bundle.INSTALLED | Bundle.RESOLVED | Bundle.ACTIVE, propagate = true)
+ @Property(name = "foo", value = "bar")
public static class ProviderImpl implements Provider {
@LifecycleController
volatile Runnable m_publisher; // injected and used to register our service
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/BundleDependencyAnnotation.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/BundleDependencyAnnotation.java?rev=1842034&r1=1842033&r2=1842034&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/BundleDependencyAnnotation.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/BundleDependencyAnnotation.java Wed Sep 26 16:45:35 2018
@@ -95,8 +95,8 @@ public class BundleDependencyAnnotation
/**
* A BundleAdapter test, which adapts the dependency manager bundle to the ServiceInterface service.
*/
- @BundleAdapterService(filter = "(Bundle-SymbolicName=" + METATYPE_BSN + ")", stateMask = Bundle.INSTALLED
- | Bundle.RESOLVED | Bundle.ACTIVE, propagate = true, properties = {@Property(name = "foo", value = "bar")})
+ @BundleAdapterService(filter = "(Bundle-SymbolicName=" + METATYPE_BSN + ")", stateMask = Bundle.INSTALLED | Bundle.RESOLVED | Bundle.ACTIVE, propagate = true)
+ @Property(name = "foo", value = "bar")
public static class ServiceProvider implements ServiceInterface {
// Adapted bundle (injected by reflection).
protected volatile Bundle m_bundle;
Added: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/CollectionFieldDependencyAnnotation.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/CollectionFieldDependencyAnnotation.java?rev=1842034&view=auto
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/CollectionFieldDependencyAnnotation.java (added)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/CollectionFieldDependencyAnnotation.java Wed Sep 26 16:45:35 2018
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.dm.runtime.itest.components;
+
+import java.util.Collection;
+import java.util.Dictionary;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.felix.dm.annotation.api.Component;
+import org.apache.felix.dm.annotation.api.Property;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.annotation.api.Start;
+import org.apache.felix.dm.itest.util.Ensure;
+import org.junit.Assert;
+
+/**
+ * Tests if a consumer can be injected with some services using a field collection.
+ */
+public class CollectionFieldDependencyAnnotation {
+
+ interface Provider {
+ }
+
+ @Component
+ @Property(name="p", value="v1")
+ public static class ProviderImpl1 implements Provider {
+ public final static String ENSURE = "CollectionFieldDependencyAnnotation.ProviderImpl1";
+
+ @ServiceDependency(filter="(name=" + ENSURE + ")")
+ Ensure m_ensure;
+
+ @Start
+ void start() {
+ m_ensure.step();
+ }
+ }
+
+ @Component
+ @Property(name="p", value="v2")
+ public static class ProviderImpl2 implements Provider {
+ public final static String ENSURE = "CollectionFieldDependencyAnnotation.ProviderImpl2";
+
+ @ServiceDependency(filter="(name=" + ENSURE + ")")
+ Ensure m_ensure;
+
+ @Start
+ void start() {
+ m_ensure.step();
+ }
+ }
+
+ @Component
+ public static class Consumer {
+ public final static String ENSURE = "CollectionFieldDependencyAnnotation.Consumer";
+
+ @ServiceDependency(filter="(name=" + ENSURE + ")")
+ Ensure m_ensure;
+
+ @ServiceDependency
+ volatile Iterable<Provider> m_list1;
+
+ @ServiceDependency
+ volatile Collection<Provider> m_list2;
+
+ @ServiceDependency
+ volatile Map<Provider, Dictionary<String, Object>> m_list3 = new ConcurrentHashMap<>();
+
+ @ServiceDependency(filter="(p=v1)")
+ volatile Provider m_p1;
+
+ @ServiceDependency(filter="(p=v2)")
+ volatile Provider m_p2;
+
+ @Start
+ void start() {
+ m_ensure.step(3);
+
+ Assert.assertNotNull(m_p1);
+ Assert.assertNotNull(m_p2);
+ Assert.assertNotNull(m_list1);
+ int size = 0;
+ for (Provider p : m_list1) size ++;
+ Assert.assertEquals(2, size);
+ Assert.assertEquals(2, m_list2.size());
+ Iterator<Provider> it = m_list1.iterator();
+ Provider p1 = it.next();
+ Provider p2 = it.next();
+ if (p1 == m_p1 && p2 == m_p2) {
+ m_ensure.step(4);
+ } else if (p1 == m_p2 && p2 == m_p1) {
+ m_ensure.step(4);
+ }
+
+ Assert.assertEquals(2, m_list3.size());
+ Dictionary<String, Object> p1Props = m_list3.get(m_p1);
+ Assert.assertNotNull(p1Props);
+ Assert.assertEquals("v1", p1Props.get("p"));
+ m_ensure.step();
+
+ Dictionary<String, Object> p2Props = m_list3.get(m_p2);
+ Assert.assertNotNull(p2Props);
+ Assert.assertEquals("v2", p2Props.get("p"));
+ m_ensure.step();
+ }
+ }
+
+}
Added: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/ComponentDMPropertyTypeAnnotation.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/ComponentDMPropertyTypeAnnotation.java?rev=1842034&view=auto
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/ComponentDMPropertyTypeAnnotation.java (added)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/ComponentDMPropertyTypeAnnotation.java Wed Sep 26 16:45:35 2018
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.dm.runtime.itest.components;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.util.Map;
+
+import org.apache.felix.dm.annotation.api.Component;
+import org.apache.felix.dm.annotation.api.PropertyType;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.itest.util.Ensure;
+
+/**
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class ComponentDMPropertyTypeAnnotation {
+ public final static String ENSURE = "ComponentDMPropertyTypeAnnotation";
+
+ @PropertyType
+ @Retention(RetentionPolicy.CLASS)
+ @interface MyProperties {
+ double double_value() default 123;
+ String string_value() default "defstring";
+ }
+
+ @Component(provides=MyComponent.class)
+ @MyProperties(double_value=456)
+ public static class MyComponent {
+ }
+
+ @Component
+ public static class MyConsumer {
+ @ServiceDependency(filter = "(name=" + ENSURE + ")")
+ volatile Ensure m_ensure;
+
+ @ServiceDependency
+ void bind(MyComponent comp, Map<String, Object> props) {
+ m_ensure.step(1);
+ if ("defstring".equals(props.get("string.value"))) {
+ m_ensure.step(2);
+ }
+ if (new Double(456).equals(props.get("double.value"))) {
+ m_ensure.step(3);
+ }
+ }
+ }
+
+}
Added: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/ComponentDMPropertyTypeArrayAnnotation.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/ComponentDMPropertyTypeArrayAnnotation.java?rev=1842034&view=auto
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/ComponentDMPropertyTypeArrayAnnotation.java (added)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/ComponentDMPropertyTypeArrayAnnotation.java Wed Sep 26 16:45:35 2018
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.dm.runtime.itest.components;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.util.Map;
+
+import org.apache.felix.dm.annotation.api.Component;
+import org.apache.felix.dm.annotation.api.PropertyType;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.itest.util.Ensure;
+
+/**
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class ComponentDMPropertyTypeArrayAnnotation {
+ public final static String ENSURE = "ComponentDMPropertyTypeArrayAnnotation";
+
+ @PropertyType
+ @Retention(RetentionPolicy.CLASS)
+ @interface MyProperties {
+ String[] pattern();
+ String[] pattern2();
+ String prefix();
+ }
+
+ @Component(provides=MyComponent.class)
+ @MyProperties(pattern="/web", pattern2 = { "/web1", "/web2" }, prefix="/*")
+ public static class MyComponent {
+ }
+
+ @Component
+ public static class MyConsumer {
+ @ServiceDependency(filter = "(name=" + ENSURE + ")")
+ volatile Ensure m_ensure;
+
+ @ServiceDependency
+ void bind(MyComponent comp, Map<String, Object> props) {
+ m_ensure.step(1);
+ Object pattern = props.get("pattern");
+ if (pattern instanceof String) {
+ if ("/web".equals(pattern.toString()))
+ m_ensure.step(2);
+ }
+
+ Object pattern2 = props.get("pattern2");
+ if (pattern2 != null) {
+ if (pattern2 instanceof String[]) {
+ String[] array = (String[]) pattern2;
+ if (array.length == 2 && array[0].equals("/web1") && array[1].equals("/web2")) {
+ m_ensure.step(3);
+ }
+ }
+ }
+
+ if ("/*".equals(props.get("prefix"))) {
+ m_ensure.step(4);
+ }
+ }
+ }
+
+}
Added: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/ComponentDMSingleValuedPropertyTypeAnnotation.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/ComponentDMSingleValuedPropertyTypeAnnotation.java?rev=1842034&view=auto
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/ComponentDMSingleValuedPropertyTypeAnnotation.java (added)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/ComponentDMSingleValuedPropertyTypeAnnotation.java Wed Sep 26 16:45:35 2018
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.dm.runtime.itest.components;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.util.Map;
+
+import org.apache.felix.dm.annotation.api.Component;
+import org.apache.felix.dm.annotation.api.PropertyType;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.itest.util.Ensure;
+
+/**
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class ComponentDMSingleValuedPropertyTypeAnnotation {
+ public final static String ENSURE = "ComponentDMSingleValuedPropertyTypeAnnotation";
+
+ @PropertyType
+ @Retention(RetentionPolicy.CLASS)
+ @interface MyProperty1 {
+ String PREFIX_ = "prefix1.";
+ String value() default "defval1"; // derived property name is prefix1.my.property1;
+ }
+
+ @PropertyType
+ @Retention(RetentionPolicy.CLASS)
+ @interface MyProperty2 {
+ String PREFIX_ = "prefix2.";
+ String value() default "defval2"; // derived property name is prefix2.my.propert2;
+ }
+
+ @Component(provides=MyComponent.class)
+ @MyProperty1("val1")
+ @MyProperty2
+ public static class MyComponent {
+ }
+
+ @Component
+ public static class MyConsumer {
+ @ServiceDependency(filter = "(name=" + ENSURE + ")")
+ volatile Ensure m_ensure;
+
+ @ServiceDependency
+ void bind(MyComponent comp, Map<String, Object> props) {
+ m_ensure.step(1);
+ if ("val1".equals(props.get("prefix1.my.property1"))) {
+ m_ensure.step(2);
+ }
+ if ("defval2".equals(props.get("prefix2.my.property2"))) {
+ m_ensure.step(3);
+ }
+ }
+ }
+
+}
Added: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/ComponentJaxrsResourceAnnotation.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/ComponentJaxrsResourceAnnotation.java?rev=1842034&view=auto
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/ComponentJaxrsResourceAnnotation.java (added)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/ComponentJaxrsResourceAnnotation.java Wed Sep 26 16:45:35 2018
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.dm.runtime.itest.components;
+
+import java.util.Map;
+
+import org.apache.felix.dm.annotation.api.Component;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.itest.util.Ensure;
+import org.osgi.service.jaxrs.whiteboard.JaxRSWhiteboardConstants;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsResource;
+
+/**
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class ComponentJaxrsResourceAnnotation {
+ public final static String ENSURE = "ComponentJaxrsResourceAnnotation";
+
+ @Component(provides=MyComponent.class)
+ @JaxrsResource
+ public static class MyComponent {
+ }
+
+ @Component
+ public static class MyConsumer {
+ @ServiceDependency(filter = "(name=" + ENSURE + ")")
+ volatile Ensure m_ensure;
+
+ @ServiceDependency
+ void bind(MyComponent comp, Map<String, Object> props) {
+ m_ensure.step(1);
+ Object value = props.get(JaxRSWhiteboardConstants.JAX_RS_RESOURCE);
+ if (Boolean.TRUE.equals(value)) {
+ m_ensure.step(2);
+ }
+ }
+ }
+
+}
Added: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/ComponentPropertyTypeWithDictionaryPassedInUpdateCallback.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/ComponentPropertyTypeWithDictionaryPassedInUpdateCallback.java?rev=1842034&view=auto
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/ComponentPropertyTypeWithDictionaryPassedInUpdateCallback.java (added)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/ComponentPropertyTypeWithDictionaryPassedInUpdateCallback.java Wed Sep 26 16:45:35 2018
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.dm.runtime.itest.components;
+
+import java.io.IOException;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.apache.felix.dm.annotation.api.Component;
+import org.apache.felix.dm.annotation.api.ConfigurationDependency;
+import org.apache.felix.dm.annotation.api.PropertyType;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.annotation.api.Start;
+import org.apache.felix.dm.itest.util.Ensure;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+/**
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class ComponentPropertyTypeWithDictionaryPassedInUpdateCallback {
+ public final static String ENSURE = "ComponentPropertyWithDictionaryPassedInUpdateCallback";
+
+ @PropertyType
+ @Retention(RetentionPolicy.CLASS)
+ @interface MyProperty {
+ String string_value();
+ }
+
+ @Component(provides=MyComponent.class)
+ @MyProperty(string_value="defstring")
+ public static class MyComponent {
+ @ServiceDependency(filter = "(name=" + ENSURE + ")")
+ volatile Ensure m_ensure;
+
+ private Dictionary<String, String> m_cnf;
+ private MyProperty m_prop;
+
+ @ConfigurationDependency(propagate=true)
+ void updated(Dictionary<String, String> cnf, MyProperty prop) {
+ m_cnf = cnf;
+ m_prop = prop;
+ }
+
+ @Start
+ void start() {
+ System.out.println("MyComponent.start: cnf=" + m_cnf + ", string_value=" + m_prop.string_value());
+ if ("configured".equals(m_cnf.get("string.value")) && "configured".equals(m_prop.string_value())) {
+ m_ensure.step(1);
+ }
+ }
+ }
+
+ @Component
+ public static class MyConsumer {
+ @ServiceDependency(filter = "(name=" + ENSURE + ")")
+ volatile Ensure m_ensure;
+ Configuration m_conf;
+
+ @ServiceDependency
+ void bind(ConfigurationAdmin cm) {
+ try {
+ m_conf = cm.getConfiguration(MyProperty.class.getName());
+ Hashtable<String, Object> newprops = new Hashtable<>();
+ newprops.put("string.value", "configured");
+ m_conf.update(newprops);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ @ServiceDependency(removed="remove", required=false)
+ void bind(MyComponent comp, Map<String, Object> props) {
+ try {
+ // first, we expect to be injected with MyComponent with the following properties:
+ // string.value=another_string and double_value=123
+ if ("configured".equals(props.get("string.value"))) {
+ m_ensure.step(2);
+ m_conf.delete();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ void remove(MyComponent comp) {
+ m_ensure.step(3);
+ }
+ }
+
+}
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/CompositeAnnotations.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/CompositeAnnotations.java?rev=1842034&r1=1842033&r2=1842034&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/CompositeAnnotations.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/CompositeAnnotations.java Wed Sep 26 16:45:35 2018
@@ -159,7 +159,8 @@ public class CompositeAnnotations {
}
}
- @Component(properties = @Property(name = "foo", value = "bar1"))
+ @Component
+ @Property(name = "foo", value = "bar1")
public static class Dependency1 implements Dependency {
public final static String ENSURE = "CompositeAnnotations.Dependency1";
@@ -176,7 +177,8 @@ public class CompositeAnnotations {
}
}
- @Component(properties = @Property(name = "foo", value = "bar2"))
+ @Component
+ @Property(name = "foo", value = "bar2")
public static class Dependency2 implements Dependency {
public final static String ENSURE = "CompositeAnnotations.Dependency2";
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/ExtraAdapterServiceProperties.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/ExtraAdapterServiceProperties.java?rev=1842034&r1=1842033&r2=1842034&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/ExtraAdapterServiceProperties.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/ExtraAdapterServiceProperties.java Wed Sep 26 16:45:35 2018
@@ -44,11 +44,13 @@ public class ExtraAdapterServiceProperti
public interface Provider2 {
}
- @Component(properties = {@Property(name = "foo", value = "bar")})
+ @Component
+ @Property(name = "foo", value = "bar")
public static class ProviderImpl implements Provider {
}
- @AdapterService(provides = Provider2.class, properties = {@Property(name = "foo2", value = "bar2")}, adapteeService = Provider.class)
+ @AdapterService(provides = Provider2.class, adapteeService = Provider.class)
+ @Property(name = "foo2", value = "bar2")
public static class Provider2Impl implements Provider2 {
protected Provider m_adaptee;
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/ExtraServiceProperties.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/ExtraServiceProperties.java?rev=1842034&r1=1842033&r2=1842034&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/ExtraServiceProperties.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/ExtraServiceProperties.java Wed Sep 26 16:45:35 2018
@@ -40,7 +40,8 @@ public class ExtraServiceProperties {
public interface Provider {
}
- @Component(properties = {@Property(name = "foo", value = "bar")})
+ @Component
+ @Property(name = "foo", value = "bar")
public static class ProviderImpl implements Provider {
@Start
Map<String, String> start() {
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/FELIX5337.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/FELIX5337.java?rev=1842034&r1=1842033&r2=1842034&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/FELIX5337.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/FELIX5337.java Wed Sep 26 16:45:35 2018
@@ -22,9 +22,9 @@ import org.apache.felix.dm.DependencyMan
import org.apache.felix.dm.annotation.api.Component;
import org.apache.felix.dm.annotation.api.Inject;
import org.apache.felix.dm.annotation.api.ServiceDependency;
-import org.apache.felix.dm.annotation.api.ServiceDependency.Any;
import org.apache.felix.dm.annotation.api.Start;
import org.apache.felix.dm.annotation.api.Stop;
+import org.apache.felix.dm.annotation.api.ServiceDependency.Any;
import org.apache.felix.dm.itest.util.Ensure;
import org.junit.Assert;
import org.osgi.framework.Bundle;
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/FELIX5337_MatchAllServicesWithFilter.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/FELIX5337_MatchAllServicesWithFilter.java?rev=1842034&r1=1842033&r2=1842034&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/FELIX5337_MatchAllServicesWithFilter.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/FELIX5337_MatchAllServicesWithFilter.java Wed Sep 26 16:45:35 2018
@@ -25,8 +25,8 @@ import java.util.concurrent.atomic.Atomi
import org.apache.felix.dm.annotation.api.Component;
import org.apache.felix.dm.annotation.api.Property;
import org.apache.felix.dm.annotation.api.ServiceDependency;
-import org.apache.felix.dm.annotation.api.ServiceDependency.Any;
import org.apache.felix.dm.annotation.api.Start;
+import org.apache.felix.dm.annotation.api.ServiceDependency.Any;
import org.apache.felix.dm.itest.util.Ensure;
import org.junit.Assert;
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/FactoryConfigurationAdapterAnnotation.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/FactoryConfigurationAdapterAnnotation.java?rev=1842034&r1=1842033&r2=1842034&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/FactoryConfigurationAdapterAnnotation.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/FactoryConfigurationAdapterAnnotation.java Wed Sep 26 16:45:35 2018
@@ -23,7 +23,6 @@ import java.util.Map;
import org.apache.felix.dm.DependencyManager;
import org.apache.felix.dm.annotation.api.Component;
-import org.apache.felix.dm.annotation.api.FactoryConfigurationAdapterService;
import org.apache.felix.dm.annotation.api.Inject;
import org.apache.felix.dm.annotation.api.Property;
import org.apache.felix.dm.annotation.api.ServiceDependency;
@@ -78,7 +77,8 @@ public class FactoryConfigurationAdapter
/**
* This service is instantiated when a factory configuration is created from ConfigAdmin
*/
- @FactoryConfigurationAdapterService(factoryPid = "FactoryPidTest", properties = {@Property(name = "foo", value = "bar")}, propagate = true)
+ @Component(factoryPid = "FactoryPidTest", propagate = true)
+ @Property(name = "foo", value = "bar")
public static class ServiceProvider implements ServiceInterface {
public final static String ENSURE = "FactoryConfigurationAdapterAnnotation.ServiceProvider";
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/FactoryConfigurationAdapterServiceTestWithPublisher.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/FactoryConfigurationAdapterServiceTestWithPublisher.java?rev=1842034&r1=1842033&r2=1842034&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/FactoryConfigurationAdapterServiceTestWithPublisher.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/FactoryConfigurationAdapterServiceTestWithPublisher.java Wed Sep 26 16:45:35 2018
@@ -25,7 +25,6 @@ import java.util.Hashtable;
import java.util.Map;
import org.apache.felix.dm.annotation.api.Component;
-import org.apache.felix.dm.annotation.api.FactoryConfigurationAdapterService;
import org.apache.felix.dm.annotation.api.Init;
import org.apache.felix.dm.annotation.api.LifecycleController;
import org.apache.felix.dm.annotation.api.Property;
@@ -102,7 +101,8 @@ public class FactoryConfigurationAdapter
}
}
- @FactoryConfigurationAdapterService(propagate = true, properties = {@Property(name = "foo", value = "bar")}, factoryPid = PID, updated = "updated")
+ @Component(propagate = true, factoryPid = PID, updated = "updated")
+ @Property(name = "foo", value = "bar")
public static class ProviderImpl implements Provider {
@LifecycleController
volatile Runnable m_publisher; // injected and used to register our service
Added: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/FactoryPidWithPropertyTypeAnnotation.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/FactoryPidWithPropertyTypeAnnotation.java?rev=1842034&view=auto
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/FactoryPidWithPropertyTypeAnnotation.java (added)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/FactoryPidWithPropertyTypeAnnotation.java Wed Sep 26 16:45:35 2018
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.dm.runtime.itest.components;
+
+import java.io.IOException;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.apache.felix.dm.annotation.api.Component;
+import org.apache.felix.dm.annotation.api.PropertyType;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.itest.util.Ensure;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+/**
+ * A Factory Pid component which provides its service properties using property type annotations.
+ * The service properties can also be overriden from factory configuration.
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class FactoryPidWithPropertyTypeAnnotation {
+ public final static String ENSURE = "FactoryPidWithPropertyTypeAnnotation";
+
+ @PropertyType
+ @Retention(RetentionPolicy.CLASS)
+ @interface MyProperties {
+ String string_value() default "defstring";
+ double double_value() default 123;
+ }
+
+ @PropertyType
+ @Retention(RetentionPolicy.CLASS)
+ @interface MyProperties2 {
+ String string_value2() default "defstring2";
+ double double_value2() default 456;
+ }
+
+ /**
+ * Service properties are defined using the two annotations above,
+ * and we override some service properties using the factory configuration
+ */
+ @Component(provides=MyComponent.class, propagate=true, factoryPid="org.apache.felix.dm.runtime.itest.components.FactoryPidWithPropertyTypeAnnotation$MyProperties")
+ @MyProperties(string_value="string")
+ @MyProperties2(string_value2="string2")
+ public static class MyComponent {
+ void updated(MyProperties props, MyProperties2 props2) {
+ if (props != null) {
+ System.out.println("MyComponent.updated: string_value=" + props.string_value() + ", double_value=" + props.double_value() +
+ "string_value2=" + props2.string_value2() + ", double_value2=" + props2.double_value2());
+ }
+ }
+ }
+
+ @Component
+ public static class MyConsumer {
+ @ServiceDependency(filter = "(name=" + ENSURE + ")")
+ Ensure m_ensure;
+
+ Configuration m_conf;
+
+ @ServiceDependency
+ void bind(ConfigurationAdmin cm) {
+ try {
+ m_conf = cm.createFactoryConfiguration(MyProperties.class.getName());
+ Hashtable<String, Object> newprops = new Hashtable<>();
+ newprops.put("string.value", "CM");
+ m_conf.update(newprops);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @ServiceDependency(required=false, changed="change", removed="remove")
+ void add(MyComponent comp, Map<String, Object> props) {
+ try {
+ // first, we expect to be injected with MyComponent with the following properties:
+ // string.value=CM and double_value=123
+ if ("CM".equals(props.get("string.value")) && new Double(123).equals(props.get("double.value")) &&
+ "string2".equals(props.get("string.value2")) && new Double(456).equals(props.get("double.value2"))) {
+ m_ensure.step(1);
+
+ // at this point, let's reconfigure the factory component
+ Hashtable<String, Object> newprops = new Hashtable<>();
+ newprops.put("string.value", "CM modified");
+ m_conf.update(newprops);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ void change(MyComponent comp, Map<String, Object> props) {
+ try {
+ System.out.println("MyConsumer.change: " + props);
+ if ("CM modified".equals(props.get("string.value")) && new Double(123).equals(props.get("double.value")) &&
+ "string2".equals(props.get("string.value2")) && new Double(456).equals(props.get("double.value2"))) {
+ m_ensure.step(2);
+ m_conf.delete();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ void remove(MyComponent comp, Map<String, Object> props) {
+ m_ensure.step(3);
+ }
+ }
+
+}
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/Felix4050.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/Felix4050.java?rev=1842034&r1=1842033&r2=1842034&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/Felix4050.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/Felix4050.java Wed Sep 26 16:45:35 2018
@@ -49,7 +49,8 @@ public class Felix4050 {
void run();
}
- @Component(properties = {@Property(name = "type", value = "b1")})
+ @Component
+ @Property(name = "type", value = "b1")
public static class B1 implements B {
public void run() {
}
Added: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/JaxrsComponentPropertyTypeAnnotation.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/JaxrsComponentPropertyTypeAnnotation.java?rev=1842034&view=auto
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/JaxrsComponentPropertyTypeAnnotation.java (added)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/JaxrsComponentPropertyTypeAnnotation.java Wed Sep 26 16:45:35 2018
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.dm.runtime.itest.components;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.apache.felix.dm.annotation.api.Component;
+import org.apache.felix.dm.annotation.api.ConfigurationDependency;
+import org.apache.felix.dm.annotation.api.PropertyType;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.itest.util.Ensure;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsName;
+
+/**
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class JaxrsComponentPropertyTypeAnnotation {
+
+ @Component(provides=JaxRsComponent.class)
+ @JaxrsName("foo")
+ public static class JaxRsComponent {
+ }
+
+ @Component
+ public static class JaxRsConsumer {
+ public final static String ENSURE = "ComponentPropertyTypeAnnotations.JaxRsConsumer";
+
+ @ServiceDependency(filter = "(name=" + ENSURE + ")")
+ volatile Ensure m_ensure;
+
+ @ServiceDependency
+ void bind(JaxRsComponent jaxrs, Map<String, Object> props) {
+ m_ensure.step(1);
+ if ("foo".equals(props.get("osgi.jaxrs.name"))) {
+ m_ensure.step(2);
+ }
+ }
+ }
+
+}