felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r918683 - in /felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency: Consumer.java ServiceConsumer.java ServiceInterface.java ServiceProvider.java
Date Wed, 03 Mar 2010 21:00:13 GMT
Author: pderop
Date: Wed Mar  3 21:00:13 2010
New Revision: 918683

URL: http://svn.apache.org/viewvc?rev=918683&view=rev
Log:
added integration test for new BundleAdapterService annotation

Added:
    felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/ServiceConsumer.java
    felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/ServiceInterface.java
    felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/ServiceProvider.java
Modified:
    felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/Consumer.java

Modified: felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/Consumer.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/Consumer.java?rev=918683&r1=918682&r2=918683&view=diff
==============================================================================
--- felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/Consumer.java
(original)
+++ felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/Consumer.java
Wed Mar  3 21:00:13 2010
@@ -26,13 +26,16 @@
 import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
 import org.osgi.framework.Bundle;
 
+/**
+ * Simple Consumer which has a BundleDependency dependency.
+ */
 @Service
 public class Consumer
 {
     protected volatile boolean m_added;
     protected volatile boolean m_removed;
 
-    @ServiceDependency
+    @ServiceDependency(filter="(test=consumer)")
     private volatile Sequencer m_sequencer;
 
     @BundleDependency(required = false, removed = "removed", filter = "(Bundle-SymbolicName=org.apache.felix.dependencymanager)")

Added: felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/ServiceConsumer.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/ServiceConsumer.java?rev=918683&view=auto
==============================================================================
--- felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/ServiceConsumer.java
(added)
+++ felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/ServiceConsumer.java
Wed Mar  3 21:00:13 2010
@@ -0,0 +1,43 @@
+/*
+* 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.test.bundle.annotation.bundledependency;
+
+import org.apache.felix.dm.annotation.api.Service;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.annotation.api.Start;
+import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
+
+/**
+ * ServiceInterface Consumer.
+ */
+@Service
+public class ServiceConsumer
+{
+    @ServiceDependency(filter="(test=adapter)")
+    Sequencer m_sequencer;
+
+    @ServiceDependency
+    ServiceInterface m_service;
+
+    @Start
+    void start() {
+        m_sequencer.step(2);
+        m_service.run();
+    }
+}

Added: felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/ServiceInterface.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/ServiceInterface.java?rev=918683&view=auto
==============================================================================
--- felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/ServiceInterface.java
(added)
+++ felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/ServiceInterface.java
Wed Mar  3 21:00:13 2010
@@ -0,0 +1,23 @@
+/*
+* 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.test.bundle.annotation.bundledependency;
+
+public interface ServiceInterface extends Runnable
+{
+}

Added: felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/ServiceProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/ServiceProvider.java?rev=918683&view=auto
==============================================================================
--- felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/ServiceProvider.java
(added)
+++ felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/ServiceProvider.java
Wed Mar  3 21:00:13 2010
@@ -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.test.bundle.annotation.bundledependency;
+
+import org.apache.felix.dm.annotation.api.BundleAdapterService;
+import org.apache.felix.dm.annotation.api.Param;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.annotation.api.Start;
+import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
+import org.osgi.framework.Bundle;
+
+/**
+ * A BundleAdapter test, which adapts the dependency manager bundle to the ServiceInterface
service.
+ */
+@BundleAdapterService(
+    filter = "(Bundle-SymbolicName=org.apache.felix.dependencymanager)",
+    stateMask = Bundle.INSTALLED | Bundle.RESOLVED | Bundle.ACTIVE,
+    propagate = true,
+    properties = { @Param(name = "foo", value = "bar") })
+public class ServiceProvider implements ServiceInterface
+{
+    // Adapted bundle (injected by reflection).
+    protected Bundle m_bundle;
+
+    // Our Sequencer required dependency
+    @ServiceDependency(filter = "(test=adapter)")
+    Sequencer m_sequencer;
+
+    @Start
+    void start()
+    {
+        m_sequencer.step(1);
+    }
+
+    public void run()
+    {
+        if (m_bundle == null
+            || !m_bundle.getSymbolicName().equals("org.apache.felix.dependencymanager"))
+        {
+            throw new IllegalStateException("ServiceProvider did not get proper bundle: "
+                + m_bundle);
+        }
+        m_sequencer.step(3);
+    }
+}



Mime
View raw message