You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by fm...@apache.org on 2012/05/30 13:07:50 UTC

svn commit: r1344193 - in /felix/trunk/configadmin: ./ src/main/appended-resources/META-INF/ src/main/java/org/apache/felix/cm/ src/main/java/org/apache/felix/cm/file/ src/main/java/org/osgi/framework/ src/main/java/org/osgi/service/ src/test/java/org/...

Author: fmeschbe
Date: Wed May 30 11:07:49 2012
New Revision: 1344193

URL: http://svn.apache.org/viewvc?rev=1344193&view=rev
Log:
FELIX-3177 Replace temp. inclusion of OSGi source by offical class inclusion
  - Compile with source/target 1.5
  - Check for Java 5 API signature
  - Use BND annotations for exports
  - Include modified Core 4.1 ServiceReference (generified with service class)
    in source but not in final bundle. This helps compiling against Compendium 4.3
    library while allowing to still use Core 4.1 dependency. Thus ensuring
    minimal framework requirement (Core 4.1)
  - update OSGi Alliance copyright year

Added:
    felix/trunk/configadmin/src/main/java/org/apache/felix/cm/file/package-info.java
    felix/trunk/configadmin/src/main/java/org/apache/felix/cm/package-info.java
    felix/trunk/configadmin/src/main/java/org/osgi/framework/
    felix/trunk/configadmin/src/main/java/org/osgi/framework/ServiceReference.java
Removed:
    felix/trunk/configadmin/src/main/java/org/osgi/service/
Modified:
    felix/trunk/configadmin/pom.xml
    felix/trunk/configadmin/src/main/appended-resources/META-INF/DEPENDENCIES
    felix/trunk/configadmin/src/main/appended-resources/META-INF/NOTICE
    felix/trunk/configadmin/src/test/java/org/apache/felix/cm/MockBundle.java
    felix/trunk/configadmin/src/test/java/org/apache/felix/cm/impl/RankingComparatorTest.java
    felix/trunk/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationAdminUpdateStressTest.java
    felix/trunk/configadmin/src/test/java/org/apache/felix/cm/integration/FELIX2813_ConfigurationAdminStartupTest.java

Modified: felix/trunk/configadmin/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/pom.xml?rev=1344193&r1=1344192&r2=1344193&view=diff
==============================================================================
--- felix/trunk/configadmin/pom.xml (original)
+++ felix/trunk/configadmin/pom.xml Wed May 30 11:07:49 2012
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.apache.felix</groupId>
         <artifactId>felix-parent</artifactId>
-        <version>2</version>
+        <version>2.1</version>
         <relativePath>../pom/pom.xml</relativePath>
     </parent>
 
@@ -74,8 +74,6 @@
         <bundle.file.name>
             ${bundle.build.name}/${project.build.finalName}.jar
         </bundle.file.name>
-
-		<api-package-version>1.0</api-package-version>
     </properties>
 
 
@@ -83,16 +81,24 @@
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.core</artifactId>
-            <version>4.0.0</version>
+            <version>4.1.0</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.compendium</artifactId>
-            <version>4.2.0</version>
+            <version>4.3.0</version>
             <scope>provided</scope>
         </dependency>
-        
+
+        <!-- BND export annotations -->        
+        <dependency>
+            <groupId>biz.aQute</groupId>
+            <artifactId>bndlib</artifactId>
+            <version>1.50.0</version>
+            <scope>provided</scope>
+        </dependency>
+
         <!-- Integration Testing with Pax Exam -->
         <dependency>
             <groupId>junit</groupId>
@@ -147,19 +153,17 @@
                             org.apache.felix.cm.impl.ConfigurationManager
                         </Bundle-Activator>
                         <Export-Package>
+                            <!-- just list, version from package-info classes -->
                             org.apache.felix.cm;
-                            org.apache.felix.cm.file;version=${api-package-version};provide:=true,
-                            org.osgi.service.cm;version=1.4;-split-package:=merge-first;provide:=true
+                            org.apache.felix.cm.file,
+                            org.osgi.service.cm;provide:=true
                         </Export-Package>
                         <Private-Package>
                             org.apache.felix.cm.impl,
                             org.osgi.util.tracker
                         </Private-Package>
-                        <Import-Package>
-                            org.osgi.service.cm;version="[1.4,1.5)",
-                            *
-                        </Import-Package>
                         <DynamicImport-Package>
+                            <!-- overwrite version from compendium bundle -->
                             org.osgi.service.log;version="1.3"
                         </DynamicImport-Package>
 						<Export-Service>
@@ -178,7 +182,6 @@
                     </instructions>
                 </configuration>
             </plugin>
-            <!-- Make sure to not use non Java 1.3 API -->
             <plugin>
                 <groupId>org.codehaus.mojo</groupId>
                 <artifactId>animal-sniffer-maven-plugin</artifactId>
@@ -186,7 +189,7 @@
                 <configuration>
                     <signature>
                         <groupId>org.codehaus.mojo.signature</groupId>
-                        <artifactId>java13-sun</artifactId>
+                        <artifactId>java15</artifactId>
                         <version>1.0</version>
                     </signature>
                 </configuration>
@@ -199,40 +202,13 @@
                     </execution>
                 </executions>
             </plugin>
-            <!--
-                configure default compilation for Java 1.3 and integration
-                test compilation for Java 5 (since integration tests use
-                Java Annotations for Pax Exam)
-            -->
             <plugin>
                 <artifactId>maven-compiler-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>test-compile-java5</id>
-                        <goals>
-                            <goal>testCompile</goal>
-                        </goals>
-                        <configuration>
-                            <source>1.5</source>
-                            <target>1.5</target>
-                            <testExcludes>
-                                <testExclude>**/cm/*</testExclude>
-                                <testExclude>**/cm/file/*</testExclude>
-                                <testExclude>**/cm/impl/**</testExclude>
-                            </testExcludes>
-                            <testIncludes>
-                                <testInclude>**/integration/**</testInclude>
-                            </testIncludes>
-                        </configuration>
-                    </execution>
-                </executions>
                 <configuration>
-                    <testExcludes>
-                        <testExclude>**/integration/**</testExclude>
-                    </testExcludes>
+                    <source>1.5</source>
+                    <target>1.5</target>
                 </configuration>
             </plugin>
-
             <!--
                 Exclude Integration tests in (default) unit tests and
                 conversely enable integration tests for integration testing

Modified: felix/trunk/configadmin/src/main/appended-resources/META-INF/DEPENDENCIES
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/appended-resources/META-INF/DEPENDENCIES?rev=1344193&r1=1344192&r2=1344193&view=diff
==============================================================================
--- felix/trunk/configadmin/src/main/appended-resources/META-INF/DEPENDENCIES (original)
+++ felix/trunk/configadmin/src/main/appended-resources/META-INF/DEPENDENCIES Wed May 30 11:07:49 2012
@@ -2,14 +2,14 @@ I. Included Third-Party Software
 
 This product includes software developed at
 The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2009).
+Copyright (c) OSGi Alliance (2000, 2012).
 Licensed under the Apache License 2.0. 
 
 II. Used Third-Party Software
 
 This product uses software developed at
 The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2009).
+Copyright (c) OSGi Alliance (2000, 2012).
 Licensed under the Apache License 2.0. 
 
 This product uses software developed at

Modified: felix/trunk/configadmin/src/main/appended-resources/META-INF/NOTICE
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/appended-resources/META-INF/NOTICE?rev=1344193&r1=1344192&r2=1344193&view=diff
==============================================================================
--- felix/trunk/configadmin/src/main/appended-resources/META-INF/NOTICE (original)
+++ felix/trunk/configadmin/src/main/appended-resources/META-INF/NOTICE Wed May 30 11:07:49 2012
@@ -1,4 +1,4 @@
 This product includes software developed at
 The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2009).
+Copyright (c) OSGi Alliance (2000, 2012).
 Licensed under the Apache License 2.0.
\ No newline at end of file

Added: felix/trunk/configadmin/src/main/java/org/apache/felix/cm/file/package-info.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/apache/felix/cm/file/package-info.java?rev=1344193&view=auto
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/apache/felix/cm/file/package-info.java (added)
+++ felix/trunk/configadmin/src/main/java/org/apache/felix/cm/file/package-info.java Wed May 30 11:07:49 2012
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+@Version("1.0")
+@Export(optional = "provide:=true")
+package org.apache.felix.cm.file;
+
+
+import aQute.bnd.annotation.Export;
+import aQute.bnd.annotation.Version;
+
+

Added: felix/trunk/configadmin/src/main/java/org/apache/felix/cm/package-info.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/apache/felix/cm/package-info.java?rev=1344193&view=auto
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/apache/felix/cm/package-info.java (added)
+++ felix/trunk/configadmin/src/main/java/org/apache/felix/cm/package-info.java Wed May 30 11:07:49 2012
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+@Version("1.0")
+@Export(optional = "provide:=true")
+package org.apache.felix.cm;
+
+
+import aQute.bnd.annotation.Export;
+import aQute.bnd.annotation.Version;
+
+

Added: felix/trunk/configadmin/src/main/java/org/osgi/framework/ServiceReference.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/osgi/framework/ServiceReference.java?rev=1344193&view=auto
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/osgi/framework/ServiceReference.java (added)
+++ felix/trunk/configadmin/src/main/java/org/osgi/framework/ServiceReference.java Wed May 30 11:07:49 2012
@@ -0,0 +1,180 @@
+/*
+ * $Header: /cvshome/build/org.osgi.framework/src/org/osgi/framework/ServiceReference.java,v 1.20 2007/02/21 16:49:05 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2000, 2007). All Rights Reserved.
+ *
+ * Licensed 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.osgi.framework;
+
+/**
+ * A reference to a service.
+ *
+ * <p>
+ * The Framework returns <code>ServiceReference</code> objects from the
+ * <code>BundleContext.getServiceReference</code> and
+ * <code>BundleContext.getServiceReferences</code> methods.
+ * <p>
+ * A <code>ServiceReference</code> object may be shared between bundles and
+ * can be used to examine the properties of the service and to get the service
+ * object.
+ * <p>
+ * Every service registered in the Framework has a unique
+ * <code>ServiceRegistration</code> object and may have multiple, distinct
+ * <code>ServiceReference</code> objects referring to it.
+ * <code>ServiceReference</code> objects associated with a
+ * <code>ServiceRegistration</code> object have the same <code>hashCode</code>
+ * and are considered equal (more specifically, their <code>equals()</code>
+ * method will return <code>true</code> when compared).
+ * <p>
+ * If the same service object is registered multiple times,
+ * <code>ServiceReference</code> objects associated with different
+ * <code>ServiceRegistration</code> objects are not equal.
+ *
+ * @see BundleContext#getServiceReference
+ * @see BundleContext#getServiceReferences
+ * @see BundleContext#getService
+ * @ThreadSafe
+ * @version $Revision: 1.20 $
+ */
+
+public interface ServiceReference<T> extends Comparable {
+    /**
+     * Returns the property value to which the specified property key is mapped
+     * in the properties <code>Dictionary</code> object of the service
+     * referenced by this <code>ServiceReference</code> object.
+     *
+     * <p>
+     * Property keys are case-insensitive.
+     *
+     * <p>
+     * This method must continue to return property values after the service has
+     * been unregistered. This is so references to unregistered services (for
+     * example, <code>ServiceReference</code> objects stored in the log) can
+     * still be interrogated.
+     *
+     * @param key The property key.
+     * @return The property value to which the key is mapped; <code>null</code>
+     *         if there is no property named after the key.
+     */
+    public Object getProperty(String key);
+
+    /**
+     * Returns an array of the keys in the properties <code>Dictionary</code>
+     * object of the service referenced by this <code>ServiceReference</code>
+     * object.
+     *
+     * <p>
+     * This method will continue to return the keys after the service has been
+     * unregistered. This is so references to unregistered services (for
+     * example, <code>ServiceReference</code> objects stored in the log) can
+     * still be interrogated.
+     *
+     * <p>
+     * This method is <i>case-preserving </i>; this means that every key in the
+     * returned array must have the same case as the corresponding key in the
+     * properties <code>Dictionary</code> that was passed to the
+     * {@link BundleContext#registerService(String[],Object,java.util.Dictionary)}
+     * or {@link ServiceRegistration#setProperties} methods.
+     *
+     * @return An array of property keys.
+     */
+    public String[] getPropertyKeys();
+
+    /**
+     * Returns the bundle that registered the service referenced by this
+     * <code>ServiceReference</code> object.
+     *
+     * <p>
+     * This method must return <code>null</code> when the service has been
+     * unregistered. This can be used to determine if the service has been
+     * unregistered.
+     *
+     * @return The bundle that registered the service referenced by this
+     *         <code>ServiceReference</code> object; <code>null</code> if
+     *         that service has already been unregistered.
+     * @see BundleContext#registerService(String[],Object,java.util.Dictionary)
+     */
+    public Bundle getBundle();
+
+    /**
+     * Returns the bundles that are using the service referenced by this
+     * <code>ServiceReference</code> object. Specifically, this method returns
+     * the bundles whose usage count for that service is greater than zero.
+     *
+     * @return An array of bundles whose usage count for the service referenced
+     *         by this <code>ServiceReference</code> object is greater than
+     *         zero; <code>null</code> if no bundles are currently using that
+     *         service.
+     *
+     * @since 1.1
+     */
+    public Bundle[] getUsingBundles();
+
+    /**
+     * Tests if the bundle that registered the service referenced by this
+     * <code>ServiceReference</code> and the specified bundle use the same
+     * source for the package of the specified class name.
+     * <p>
+     * This method performs the following checks:
+     * <ol>
+     * <li>Get the package name from the specified class name.</li>
+     * <li>For the bundle that registered the service referenced by this
+     * <code>ServiceReference</code> (registrant bundle); find the source for
+     * the package. If no source is found then return <code>true</code> if the
+     * registrant bundle is equal to the specified bundle; otherwise return
+     * <code>false</code>.</li>
+     * <li>If the package source of the registrant bundle is equal to the
+     * package source of the specified bundle then return <code>true</code>;
+     * otherwise return <code>false</code>.</li>
+     * </ol>
+     *
+     * @param bundle The <code>Bundle</code> object to check.
+     * @param className The class name to check.
+     * @return <code>true</code> if the bundle which registered the service
+     *         referenced by this <code>ServiceReference</code> and the
+     *         specified bundle use the same source for the package of the
+     *         specified class name. Otherwise <code>false</code> is returned.
+     *
+     * @since 1.3
+     */
+    public boolean isAssignableTo(Bundle bundle, String className);
+
+    /**
+     * Compares this <code>ServiceReference</code> with the specified
+     * <code>ServiceReference</code> for order.
+     *
+     * <p>
+     * If this <code>ServiceReference</code> and the specified
+     * <code>ServiceReference</code> have the same
+     * {@link Constants#SERVICE_ID service id} they are equal. This
+     * <code>ServiceReference</code> is less than the specified
+     * <code>ServiceReference</code> if it has a lower
+     * {@link Constants#SERVICE_RANKING service ranking} and greater if it has a
+     * higher service ranking. Otherwise, if this <code>ServiceReference</code>
+     * and the specified <code>ServiceReference</code> have the same
+     * {@link Constants#SERVICE_RANKING service ranking}, this
+     * <code>ServiceReference</code> is less than the specified
+     * <code>ServiceReference</code> if it has a higher
+     * {@link Constants#SERVICE_ID service id} and greater if it has a lower
+     * service id.
+     *
+     * @param reference The <code>ServiceReference</code> to be compared.
+     * @return Returns a negative integer, zero, or a positive integer if this
+     *         <code>ServiceReference</code> is less than, equal to, or
+     *         greater than the specified <code>ServiceReference</code>.
+     * @since 1.4
+     */
+    public int compareTo(Object reference);
+}

Modified: felix/trunk/configadmin/src/test/java/org/apache/felix/cm/MockBundle.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/test/java/org/apache/felix/cm/MockBundle.java?rev=1344193&r1=1344192&r2=1344193&view=diff
==============================================================================
--- felix/trunk/configadmin/src/test/java/org/apache/felix/cm/MockBundle.java (original)
+++ felix/trunk/configadmin/src/test/java/org/apache/felix/cm/MockBundle.java Wed May 30 11:07:49 2012
@@ -195,4 +195,18 @@ public class MockBundle implements Bundl
 
     }
 
+
+    public void start( int options ) throws BundleException
+    {
+        // TODO Auto-generated method stub
+
+    }
+
+
+    public void stop( int options ) throws BundleException
+    {
+        // TODO Auto-generated method stub
+
+    }
+
 }

Modified: felix/trunk/configadmin/src/test/java/org/apache/felix/cm/impl/RankingComparatorTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/test/java/org/apache/felix/cm/impl/RankingComparatorTest.java?rev=1344193&r1=1344192&r2=1344193&view=diff
==============================================================================
--- felix/trunk/configadmin/src/test/java/org/apache/felix/cm/impl/RankingComparatorTest.java (original)
+++ felix/trunk/configadmin/src/test/java/org/apache/felix/cm/impl/RankingComparatorTest.java Wed May 30 11:07:49 2012
@@ -252,6 +252,12 @@ public class RankingComparatorTest exten
         }
 
 
+        public int compareTo( Object reference )
+        {
+            return 0;
+        }
+
+
         public String toString()
         {
             return "ServiceReference " + getProperty( Constants.SERVICE_ID );

Modified: felix/trunk/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationAdminUpdateStressTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationAdminUpdateStressTest.java?rev=1344193&r1=1344192&r2=1344193&view=diff
==============================================================================
--- felix/trunk/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationAdminUpdateStressTest.java (original)
+++ felix/trunk/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationAdminUpdateStressTest.java Wed May 30 11:07:49 2012
@@ -23,6 +23,7 @@ import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.util.Dictionary;
 import java.util.HashSet;
+import java.util.Hashtable;
 import java.util.Properties;
 import java.util.Set;
 import java.util.concurrent.CountDownLatch;
@@ -266,7 +267,7 @@ public class ConfigurationAdminUpdateStr
                 {
                     // Create factory configuration
                     org.osgi.service.cm.Configuration conf = cm.createFactoryConfiguration( _FACTORYPID, null );
-                    Properties props = new Properties();
+                    Hashtable<String, Object> props = new Hashtable<String, Object>();
                     props.put( "foo", "bar" );
                     conf.update( props );
 
@@ -279,7 +280,7 @@ public class ConfigurationAdminUpdateStr
                     // Update factory configuration many times
                     for ( int i = 0; i < UPDATE_LOOP; i++ )
                     {
-                        props = new Properties();
+                        props = new Hashtable<String, Object>();
                         props.put( "foo", "bar" + i );
                         props.put( "number", new Long( UPDATE_LOOP - i ) );
                         conf.update( props );

Modified: felix/trunk/configadmin/src/test/java/org/apache/felix/cm/integration/FELIX2813_ConfigurationAdminStartupTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/test/java/org/apache/felix/cm/integration/FELIX2813_ConfigurationAdminStartupTest.java?rev=1344193&r1=1344192&r2=1344193&view=diff
==============================================================================
--- felix/trunk/configadmin/src/test/java/org/apache/felix/cm/integration/FELIX2813_ConfigurationAdminStartupTest.java (original)
+++ felix/trunk/configadmin/src/test/java/org/apache/felix/cm/integration/FELIX2813_ConfigurationAdminStartupTest.java Wed May 30 11:07:49 2012
@@ -21,9 +21,8 @@ package org.apache.felix.cm.integration;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Hashtable;
 import java.util.List;
-import java.util.Properties;
-
 import junit.framework.TestCase;
 
 import org.junit.Test;
@@ -130,7 +129,7 @@ public class FELIX2813_ConfigurationAdmi
             try
             {
                 org.osgi.service.cm.Configuration config = ca.getConfiguration( "test" );
-                Properties props = new Properties();
+                Hashtable<String, Object> props = new Hashtable<String, Object>();
                 props.put( "abc", "123" );
                 config.update( props );
             }