felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1776251 [1/2] - in /felix/trunk/configadmin: ./ src/main/java/org/apache/felix/cm/file/ src/main/java/org/apache/felix/cm/impl/ src/main/java/org/apache/felix/cm/impl/helper/ src/test/java/org/apache/felix/cm/ src/test/java/org/apache/feli...
Date Wed, 28 Dec 2016 09:41:36 GMT
Author: cziegeler
Date: Wed Dec 28 09:41:36 2016
New Revision: 1776251

URL: http://svn.apache.org/viewvc?rev=1776251&view=rev
Log:
FELIX-5468 : Refactor persistence handling (WiP)

Added:
    felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/Activator.java   (with props)
    felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/Log.java   (with props)
Modified:
    felix/trunk/configadmin/pom.xml
    felix/trunk/configadmin/src/main/java/org/apache/felix/cm/file/ConfigurationHandler.java
    felix/trunk/configadmin/src/main/java/org/apache/felix/cm/file/FilePersistenceManager.java
    felix/trunk/configadmin/src/main/java/org/apache/felix/cm/file/package-info.java
    felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdapter.java
    felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdminImpl.java
    felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationBase.java
    felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationImpl.java
    felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
    felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/Factory.java
    felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/UpdateThread.java
    felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/helper/BaseTracker.java
    felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/helper/TargetedPID.java
    felix/trunk/configadmin/src/test/java/org/apache/felix/cm/MockBundle.java
    felix/trunk/configadmin/src/test/java/org/apache/felix/cm/impl/ConfigurationManagerTest.java
    felix/trunk/configadmin/src/test/java/org/apache/felix/cm/impl/helper/TargetedPidTest.java

Modified: felix/trunk/configadmin/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/pom.xml?rev=1776251&r1=1776250&r2=1776251&view=diff
==============================================================================
--- felix/trunk/configadmin/pom.xml (original)
+++ felix/trunk/configadmin/pom.xml Wed Dec 28 09:41:36 2016
@@ -158,7 +158,7 @@
             <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
-                <version>3.0.1</version>
+                <version>3.2.0</version>
                 <extensions>true</extensions>
                 <configuration>
                     <instructions>
@@ -171,7 +171,7 @@
                             http://felix.apache.org/site/apache-felix-config-admin.html
                         </Bundle-DocURL>
                         <Bundle-Activator>
-                            org.apache.felix.cm.impl.ConfigurationManager
+                            org.apache.felix.cm.impl.Activator
                         </Bundle-Activator>
                         <Export-Package>
                             <!-- just list, version from package-info classes -->
@@ -197,12 +197,17 @@
                         <Require-Capability><![CDATA[
                             osgi.service;filter:="(objectClass=org.osgi.service.log.LogService)";effective:=active;resolution:=optional
                         ]]></Require-Capability>
-                        <Embed-Dependency>
-                            org.osgi.core;inline=org/osgi/util/tracker/ServiceTracker*|org/osgi/util/tracker/AbstractTracked.class
-                        </Embed-Dependency>
                     </instructions>
                 </configuration>
-            </plugin>
+                   <executions>
+                        <execution>
+                            <id>baseline</id>
+                            <goals>
+                                <goal>baseline</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+              </plugin>
             <!--
                 Exclude Integration tests in (default) unit tests and
                 conversely enable integration tests for integration testing
@@ -275,24 +280,4 @@
             </build>
         </profile>
     </profiles>
-    
-    <!-- repositories for Pax Exam and BND tool -->
-    <repositories>
-        <repository>
-            <id>ops4j</id>
-            <name>ops4j</name>
-            <url>http://repository.ops4j.org/maven2</url>
-            <snapshots>
-                <enabled>false</enabled>
-            </snapshots>
-        </repository>
-        <repository>
-            <id>aqute</id>
-            <name>aqute</name>
-            <url>http://www.aqute.biz/repo</url>
-            <snapshots>
-                <enabled>false</enabled>
-            </snapshots>
-        </repository>
-    </repositories>
 </project>

Modified: felix/trunk/configadmin/src/main/java/org/apache/felix/cm/file/ConfigurationHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/apache/felix/cm/file/ConfigurationHandler.java?rev=1776251&r1=1776250&r2=1776251&view=diff
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/apache/felix/cm/file/ConfigurationHandler.java (original)
+++ felix/trunk/configadmin/src/main/java/org/apache/felix/cm/file/ConfigurationHandler.java Wed Dec 28 09:41:36 2016
@@ -510,7 +510,7 @@ public class ConfigurationHandler
 
     private String readQuoted( PushbackReader pr ) throws IOException
     {
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
         for ( ;; )
         {
             int c = read( pr );

Modified: felix/trunk/configadmin/src/main/java/org/apache/felix/cm/file/FilePersistenceManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/apache/felix/cm/file/FilePersistenceManager.java?rev=1776251&r1=1776250&r2=1776251&view=diff
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/apache/felix/cm/file/FilePersistenceManager.java (original)
+++ felix/trunk/configadmin/src/main/java/org/apache/felix/cm/file/FilePersistenceManager.java Wed Dec 28 09:41:36 2016
@@ -33,9 +33,7 @@ import java.security.PrivilegedException
 import java.util.BitSet;
 import java.util.Dictionary;
 import java.util.Enumeration;
-import java.util.HashSet;
 import java.util.NoSuchElementException;
-import java.util.Set;
 import java.util.Stack;
 import java.util.StringTokenizer;
 
@@ -178,7 +176,7 @@ public class FilePersistenceManager impl
         final String osName = System.getProperty( "os.name" );
         isWin = osName != null && osName.startsWith( "Windows" );
     }
-    
+
     private static boolean equalsNameWithPrefixPlusOneDigit( String name, String prefix) {
         if ( name.length() != prefix.length() + 1 ) {
             return false;
@@ -383,7 +381,7 @@ public class FilePersistenceManager impl
         // check whether we exhausted
         if ( first < pid.length() )
         {
-            StringBuffer buf = new StringBuffer( pid.substring( 0, first ) );
+            StringBuilder buf = new StringBuilder( pid.substring( 0, first ) );
 
             for ( int i = first; i < pid.length(); i++ )
             {
@@ -405,7 +403,7 @@ public class FilePersistenceManager impl
         if ( isWin )
         {
             final StringTokenizer segments = new StringTokenizer( pid, File.separator, true );
-            final StringBuffer pidBuffer = new StringBuffer( pid.length() );
+            final StringBuilder pidBuffer = new StringBuilder( pid.length() );
             while ( segments.hasMoreTokens() )
             {
                 final String segment = segments.nextToken();
@@ -426,7 +424,7 @@ public class FilePersistenceManager impl
     }
 
 
-    private void appendEncoded( StringBuffer buf, final char c )
+    private void appendEncoded( StringBuilder buf, final char c )
     {
         String val = "000" + Integer.toHexString( c );
         buf.append( '%' );
@@ -456,6 +454,7 @@ public class FilePersistenceManager impl
      * @return an enumeration of configuration data returned as instances of
      *      the <code>Dictionary</code> class.
      */
+    @Override
     public Enumeration getDictionaries()
     {
         return new DictionaryEnumeration();
@@ -467,6 +466,7 @@ public class FilePersistenceManager impl
      *
      * @param pid The identifier of the configuration file to delete.
      */
+    @Override
     public void delete( final String pid )
     {
         if ( System.getSecurityManager() != null )
@@ -484,6 +484,7 @@ public class FilePersistenceManager impl
     {
         AccessController.doPrivileged( new PrivilegedAction()
         {
+            @Override
             public Object run()
             {
                 _delete( pid );
@@ -510,6 +511,7 @@ public class FilePersistenceManager impl
      *
      * @return <code>true</code> if the file exists
      */
+    @Override
     public boolean exists( final String pid )
     {
         if ( System.getSecurityManager() != null )
@@ -525,6 +527,7 @@ public class FilePersistenceManager impl
     {
         final Object result = AccessController.doPrivileged( new PrivilegedAction()
         {
+            @Override
             public Object run()
             {
                 // FELIX-2771: Boolean.valueOf(boolean) is not in Foundation
@@ -554,6 +557,7 @@ public class FilePersistenceManager impl
      *      may be empty if the file contains no configuration information
      *      or is not properly formatted.
      */
+    @Override
     public Dictionary load( String pid ) throws IOException
     {
         final File cfgFile = getFile( pid );
@@ -573,6 +577,7 @@ public class FilePersistenceManager impl
         {
             Object result = AccessController.doPrivileged( new PrivilegedExceptionAction()
             {
+                @Override
                 public Object run() throws IOException
                 {
                     return _load( cfgFile );
@@ -649,6 +654,7 @@ public class FilePersistenceManager impl
      *
      * @throws IOException If an error occurrs writing the configuration data.
      */
+    @Override
     public void store( final String pid, final Dictionary props ) throws IOException
     {
         if ( System.getSecurityManager() != null )
@@ -668,6 +674,7 @@ public class FilePersistenceManager impl
         {
             AccessController.doPrivileged( new PrivilegedExceptionAction()
             {
+                @Override
                 public Object run() throws IOException
                 {
                     _store( pid, props );
@@ -798,12 +805,14 @@ public class FilePersistenceManager impl
         }
 
 
+        @Override
         public boolean hasMoreElements()
         {
             return next != null;
         }
 
 
+        @Override
         public Object nextElement()
         {
             if ( next == null )
@@ -832,6 +841,7 @@ public class FilePersistenceManager impl
         {
             Object result = AccessController.doPrivileged( new PrivilegedAction()
             {
+                @Override
                 public Object run()
                 {
                     return _seek();

Modified: 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=1776251&r1=1776250&r2=1776251&view=diff
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/apache/felix/cm/file/package-info.java (original)
+++ felix/trunk/configadmin/src/main/java/org/apache/felix/cm/file/package-info.java Wed Dec 28 09:41:36 2016
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-@org.osgi.annotation.versioning.Version("1.0.1")
+@org.osgi.annotation.versioning.Version("1.0.0")
 package org.apache.felix.cm.file;
 
 

Added: felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/Activator.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/Activator.java?rev=1776251&view=auto
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/Activator.java (added)
+++ felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/Activator.java Wed Dec 28 09:41:36 2016
@@ -0,0 +1,54 @@
+/*
+ * 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.cm.impl;
+
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+public class Activator implements BundleActivator
+{
+    private volatile ConfigurationManager manager;
+
+    @Override
+    public void start( final BundleContext bundleContext )
+    {
+        // setup log
+        Log.logger.start(bundleContext);
+        this.manager = new ConfigurationManager();
+        final ServiceReference<ConfigurationAdmin> ref = this.manager.start(bundleContext);
+        Log.logger.set(ref);
+    }
+
+
+    @Override
+    public void stop( final BundleContext bundleContext )
+    {
+        // stop logger
+        Log.logger.stop();
+        if ( this.manager != null )
+        {
+            this.manager.stop(bundleContext);
+            this.manager = null;
+        }
+    }
+}
+

Propchange: felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/Activator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/Activator.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Modified: felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdapter.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdapter.java?rev=1776251&r1=1776250&r2=1776251&view=diff
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdapter.java (original)
+++ felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdapter.java Wed Dec 28 09:41:36 2016
@@ -99,7 +99,7 @@ public class ConfigurationAdapter implem
     @Override
     public void setBundleLocation( String bundleLocation )
     {
-        delegatee.getConfigurationManager().log( LogService.LOG_DEBUG, "setBundleLocation(bundleLocation={0})",
+        Log.logger.log( LogService.LOG_DEBUG, "setBundleLocation(bundleLocation={0})",
             new Object[]
                 { bundleLocation } );
 
@@ -120,7 +120,7 @@ public class ConfigurationAdapter implem
     @Override
     public void update() throws IOException
     {
-        delegatee.getConfigurationManager().log( LogService.LOG_DEBUG, "update()", ( Throwable ) null );
+        Log.logger.log( LogService.LOG_DEBUG, "update()", ( Throwable ) null );
 
         checkActive();
         checkDeleted();
@@ -136,7 +136,7 @@ public class ConfigurationAdapter implem
     @Override
     public void update( Dictionary<String, ?> properties ) throws IOException
     {
-        delegatee.getConfigurationManager().log( LogService.LOG_DEBUG, "update(properties={0})", new Object[]
+        Log.logger.log( LogService.LOG_DEBUG, "update(properties={0})", new Object[]
             { properties } );
 
         checkActive();
@@ -177,7 +177,7 @@ public class ConfigurationAdapter implem
     @Override
     public void delete() throws IOException
     {
-        delegatee.getConfigurationManager().log( LogService.LOG_DEBUG, "delete()", ( Throwable ) null );
+        Log.logger.log( LogService.LOG_DEBUG, "delete()", ( Throwable ) null );
 
         checkActive();
         checkDeleted();
@@ -192,7 +192,7 @@ public class ConfigurationAdapter implem
     @Override
     public void updateIfDifferent(final Dictionary<String, ?> properties) throws IOException
     {
-        delegatee.getConfigurationManager().log( LogService.LOG_DEBUG, "setProperties(properties={0})", new Object[]
+        Log.logger.log( LogService.LOG_DEBUG, "setProperties(properties={0})", new Object[]
                 { properties } );
 
         checkActive();
@@ -219,7 +219,7 @@ public class ConfigurationAdapter implem
                         ConfigurationPermission.ATTRIBUTE,
                         true);
 
-        delegatee.getConfigurationManager().log( LogService.LOG_DEBUG, "addAttributes({0})", attrs );
+        Log.logger.log( LogService.LOG_DEBUG, "addAttributes({0})", attrs );
 
         if ( attrs != null )
         {
@@ -264,7 +264,7 @@ public class ConfigurationAdapter implem
                         ConfigurationPermission.ATTRIBUTE,
                         true);
 
-        delegatee.getConfigurationManager().log( LogService.LOG_DEBUG, "removeAttributes({0})", attrs );
+        Log.logger.log( LogService.LOG_DEBUG, "removeAttributes({0})", attrs );
 
         if ( attrs != null )
         {

Modified: felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdminImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdminImpl.java?rev=1776251&r1=1776250&r2=1776251&view=diff
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdminImpl.java (original)
+++ felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdminImpl.java Wed Dec 28 09:41:36 2016
@@ -75,7 +75,7 @@ public class ConfigurationAdminImpl impl
     {
         final ConfigurationManager configurationManager = getConfigurationManager();
 
-        configurationManager.log( LogService.LOG_DEBUG, "createFactoryConfiguration(factoryPid={0})", new Object[]
+        Log.logger.log( LogService.LOG_DEBUG, "createFactoryConfiguration(factoryPid={0})", new Object[]
             { factoryPid } );
 
         // FELIX-3360: new factory configuration with implicit binding is dynamic
@@ -93,7 +93,7 @@ public class ConfigurationAdminImpl impl
     {
         final ConfigurationManager configurationManager = getConfigurationManager();
 
-        configurationManager.log( LogService.LOG_DEBUG, "createFactoryConfiguration(factoryPid={0}, location={1})",
+        Log.logger.log( LogService.LOG_DEBUG, "createFactoryConfiguration(factoryPid={0}, location={1})",
             new Object[]
                 { factoryPid, location } );
 
@@ -113,7 +113,7 @@ public class ConfigurationAdminImpl impl
     {
         final ConfigurationManager configurationManager = getConfigurationManager();
 
-        configurationManager.log( LogService.LOG_DEBUG, "getConfiguration(pid={0})", new Object[]
+        Log.logger.log( LogService.LOG_DEBUG, "getConfiguration(pid={0})", new Object[]
             { pid } );
 
         ConfigurationImpl config = configurationManager.getConfiguration( pid );
@@ -128,7 +128,7 @@ public class ConfigurationAdminImpl impl
         {
             if ( config.getBundleLocation() == null )
             {
-                configurationManager.log( LogService.LOG_DEBUG, "Binding configuration {0} (isNew: {1}) to bundle {2}",
+                Log.logger.log( LogService.LOG_DEBUG, "Binding configuration {0} (isNew: {1}) to bundle {2}",
                     new Object[]
                         { config.getPid(), config.isNew() ? Boolean.TRUE : Boolean.FALSE,
                             this.getBundle().getLocation() } );
@@ -155,7 +155,7 @@ public class ConfigurationAdminImpl impl
     {
         final ConfigurationManager configurationManager = getConfigurationManager();
 
-        configurationManager.log( LogService.LOG_DEBUG, "getConfiguration(pid={0}, location={1})", new Object[]
+        Log.logger.log( LogService.LOG_DEBUG, "getConfiguration(pid={0}, location={1})", new Object[]
             { pid, location } );
 
         // CM 1.4 / 104.13.2.3
@@ -184,7 +184,7 @@ public class ConfigurationAdminImpl impl
     {
         final ConfigurationManager configurationManager = getConfigurationManager();
 
-        configurationManager.log( LogService.LOG_DEBUG, "listConfigurations(filter={0})", new Object[]
+        Log.logger.log( LogService.LOG_DEBUG, "listConfigurations(filter={0})", new Object[]
             { filter } );
 
         ConfigurationImpl ci[] = configurationManager.listConfigurations( this, filter );
@@ -274,14 +274,14 @@ public class ConfigurationAdminImpl impl
                 {
                     sm.checkPermission( new ConfigurationPermission( name, action ) );
 
-                    configurationManager.log( LogService.LOG_DEBUG,
+                    Log.logger.log( LogService.LOG_DEBUG,
                         "Explicit Permission; grant {0} permission on configuration bound to {1} to bundle {2}",
                         new Object[]
                             { action, name, getBundle().getLocation() } );
                 }
                 catch ( SecurityException se )
                 {
-                    configurationManager
+                    Log.logger
                         .log(
                             LogService.LOG_DEBUG,
                             "No Permission; denied {0} permission on configuration bound to {1} to bundle {2}; reason: {3}",
@@ -290,18 +290,18 @@ public class ConfigurationAdminImpl impl
                     throw se;
                 }
             }
-            else if ( configurationManager.isLogEnabled( LogService.LOG_DEBUG ) )
+            else if ( Log.logger.isLogEnabled( LogService.LOG_DEBUG ) )
             {
-                configurationManager.log( LogService.LOG_DEBUG,
+                Log.logger.log( LogService.LOG_DEBUG,
                     "Implicit Permission; grant {0} permission on configuration bound to {1} to bundle {2}",
                     new Object[]
                         { action, name, getBundle().getLocation() } );
 
             }
         }
-        else if ( configurationManager.isLogEnabled( LogService.LOG_DEBUG ) )
+        else if ( Log.logger.isLogEnabled( LogService.LOG_DEBUG ) )
         {
-            configurationManager.log( LogService.LOG_DEBUG,
+            Log.logger.log( LogService.LOG_DEBUG,
                 "No SecurityManager installed; grant {0} permission on configuration bound to {1} to bundle {2}",
                 new Object[]
                     { action, name, getBundle().getLocation() } );
@@ -337,7 +337,7 @@ public class ConfigurationAdminImpl impl
     {
         final ConfigurationManager configurationManager = getConfigurationManager();
 
-        configurationManager.log( LogService.LOG_DEBUG, "getFactoryConfiguration(factoryPid={0}, alias={1}, location={2})", new Object[]
+        Log.logger.log( LogService.LOG_DEBUG, "getFactoryConfiguration(factoryPid={0}, alias={1}, location={2})", new Object[]
             { factoryPid, alias, location } );
 
         final String pid = factoryPid + '#' + alias;
@@ -367,7 +367,7 @@ public class ConfigurationAdminImpl impl
     public Configuration getFactoryConfiguration(String factoryPid, String alias) throws IOException {
         final ConfigurationManager configurationManager = getConfigurationManager();
 
-        configurationManager.log( LogService.LOG_DEBUG, "getFactoryConfiguration(factoryPid={0}, alias={1})", new Object[]
+        Log.logger.log( LogService.LOG_DEBUG, "getFactoryConfiguration(factoryPid={0}, alias={1})", new Object[]
             { factoryPid, alias } );
 
         final String pid = factoryPid + '#' + alias;
@@ -384,7 +384,7 @@ public class ConfigurationAdminImpl impl
         {
             if ( config.getBundleLocation() == null )
             {
-                configurationManager.log( LogService.LOG_DEBUG, "Binding configuration {0} (isNew: {1}) to bundle {2}",
+                Log.logger.log( LogService.LOG_DEBUG, "Binding configuration {0} (isNew: {1}) to bundle {2}",
                     new Object[]
                         { config.getPid(), config.isNew() ? Boolean.TRUE : Boolean.FALSE,
                             this.getBundle().getLocation() } );

Modified: felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationBase.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationBase.java?rev=1776251&r1=1776250&r2=1776251&view=diff
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationBase.java (original)
+++ felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationBase.java Wed Dec 28 09:41:36 2016
@@ -21,6 +21,7 @@ package org.apache.felix.cm.impl;
 
 import java.io.IOException;
 import java.util.Dictionary;
+
 import org.apache.felix.cm.PersistenceManager;
 import org.apache.felix.cm.impl.helper.TargetedPID;
 import org.osgi.service.log.LogService;
@@ -99,7 +100,7 @@ abstract class ConfigurationBase
         }
         catch ( IOException ioe )
         {
-            configurationManager.log( LogService.LOG_ERROR, "Persisting ID {0} failed", new Object[]
+            Log.logger.log( LogService.LOG_ERROR, "Persisting ID {0} failed", new Object[]
                 { getBaseId(), ioe } );
         }
     }

Modified: felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationImpl.java?rev=1776251&r1=1776250&r2=1776251&view=diff
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationImpl.java (original)
+++ felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationImpl.java Wed Dec 28 09:41:36 2016
@@ -147,7 +147,7 @@ public class ConfigurationImpl extends C
     private volatile boolean locked;
 
 
-    ConfigurationImpl( ConfigurationManager configurationManager, PersistenceManager persistenceManager,
+    public ConfigurationImpl( ConfigurationManager configurationManager, PersistenceManager persistenceManager,
         Dictionary<String, Object> properties )
     {
         super( configurationManager, persistenceManager, ( String ) properties.remove( Constants.SERVICE_PID ) );
@@ -301,7 +301,7 @@ public class ConfigurationImpl extends C
     {
         if ( this.getBundleLocation() == null )
         {
-            getConfigurationManager().log( LogService.LOG_DEBUG, "Dynamically binding config {0} to {1}", new Object[]
+            Log.logger.log( LogService.LOG_DEBUG, "Dynamically binding config {0} to {1}", new Object[]
                 { getPidString(), bundleLocation } );
             setDynamicBundleLocation( bundleLocation, true );
         }
@@ -378,7 +378,7 @@ public class ConfigurationImpl extends C
         {
             CaseInsensitiveDictionary newProperties = new CaseInsensitiveDictionary( properties );
 
-            getConfigurationManager().log( LogService.LOG_DEBUG, "Updating config {0} with {1}", new Object[]
+            Log.logger.log( LogService.LOG_DEBUG, "Updating config {0} with {1}", new Object[]
                 { getPidString(), newProperties } );
 
             setAutoProperties( newProperties, true );
@@ -494,7 +494,7 @@ public class ConfigurationImpl extends C
                 }
                 catch ( IOException ioe )
                 {
-                    getConfigurationManager().log( LogService.LOG_ERROR,
+                    Log.logger.log( LogService.LOG_ERROR,
                         "Failure storing factory {0} with new configuration {1}", new Object[]
                             { factoryPid, getPidString(), ioe } );
                 }

Modified: felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java?rev=1776251&r1=1776250&r2=1776251&view=diff
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java (original)
+++ felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java Wed Dec 28 09:41:36 2016
@@ -21,7 +21,6 @@ package org.apache.felix.cm.impl;
 
 import java.io.IOException;
 import java.security.SecureRandom;
-import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Dictionary;
@@ -41,7 +40,6 @@ import org.apache.felix.cm.impl.helper.M
 import org.apache.felix.cm.impl.helper.ManagedServiceTracker;
 import org.apache.felix.cm.impl.helper.TargetedPID;
 import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
 import org.osgi.framework.BundleListener;
@@ -90,7 +88,7 @@ import org.osgi.util.tracker.ServiceTrac
  * working directory as specified in the <code>user.dir</code> system property
  * is used.
  */
-public class ConfigurationManager implements BundleActivator, BundleListener
+public class ConfigurationManager implements BundleListener
 {
 
     /**
@@ -101,24 +99,6 @@ public class ConfigurationManager implem
      */
     public static final String CM_CONFIG_DIR = "felix.cm.dir";
 
-    /**
-     * The name of the bundle context property defining the maximum log level
-     * (value is "felix.cm.loglevel"). The log level setting is only used if
-     * there is no OSGi LogService available. Otherwise this setting is ignored.
-     * <p>
-     * This value of this property is expected to be an integer number
-     * corresponding to the log level values of the OSGi LogService. That is 1
-     * for errors, 2 for warnings, 3 for informational messages and 4 for debug
-     * messages. The default value is 2, such that only warnings and errors are
-     * logged in the absence of a LogService.
-     */
-    public static final String CM_LOG_LEVEL = "felix.cm.loglevel";
-
-    // The name of the LogService (not using the class, which might be missing)
-    private static final String LOG_SERVICE_NAME = "org.osgi.service.log.LogService";
-
-    private static final int CM_LOG_LEVEL_DEFAULT = 2;
-
     // random number generator to create configuration PIDs for factory
     // configurations
     private static Random numberGenerator;
@@ -130,10 +110,7 @@ public class ConfigurationManager implem
     private volatile ServiceRegistration filepmRegistration;
 
     // the service registration of the configuration admin
-    private volatile ServiceRegistration configurationAdminRegistration;
-
-    // the ServiceTracker to emit log services (see log(int, String, Throwable))
-    private ServiceTracker logTracker;
+    private volatile ServiceRegistration<ConfigurationAdmin> configurationAdminRegistration;
 
     // the ConfigurationEvent listeners
     private ServiceTracker configurationListenerTracker;
@@ -188,40 +165,14 @@ public class ConfigurationManager implem
      */
     private DynamicBindings dynamicBindings;
 
-    // the maximum log level when no LogService is available
-    private int logLevel = CM_LOG_LEVEL_DEFAULT;
-
     // flag indicating whether BundleChange events should be consumed (FELIX-979)
     private volatile boolean handleBundleEvents;
 
     // flag indicating whether the manager is considered alive
     private volatile boolean isActive;
 
-    @Override
-    public void start( BundleContext bundleContext )
+    public ServiceReference<ConfigurationAdmin> start( BundleContext bundleContext )
     {
-        // track the log service using a ServiceTracker
-        logTracker = new ServiceTracker( bundleContext, LOG_SERVICE_NAME , null );
-        logTracker.open();
-
-        // assign the log level
-        String logLevelProp = bundleContext.getProperty( CM_LOG_LEVEL );
-        if ( logLevelProp == null )
-        {
-            logLevel = CM_LOG_LEVEL_DEFAULT;
-        }
-        else
-        {
-            try
-            {
-                logLevel = Integer.parseInt( logLevelProp );
-            }
-            catch ( NumberFormatException nfe )
-            {
-                logLevel = CM_LOG_LEVEL_DEFAULT;
-            }
-        }
-
         // set up some fields
         this.bundleContext = bundleContext;
 
@@ -235,8 +186,8 @@ public class ConfigurationManager implem
         // initialize the asynchonous updater thread
         ThreadGroup tg = new ThreadGroup( "Configuration Admin Service" );
         tg.setDaemon( true );
-        this.updateThread = new UpdateThread( this, tg, "CM Configuration Updater" );
-        this.eventThread = new UpdateThread( this, tg, "CM Event Dispatcher" );
+        this.updateThread = new UpdateThread( tg, "CM Configuration Updater" );
+        this.eventThread = new UpdateThread( tg, "CM Event Dispatcher" );
 
         // set up the location (might throw IllegalArgumentException)
         try
@@ -255,11 +206,11 @@ public class ConfigurationManager implem
         }
         catch ( IOException ioe )
         {
-            log( LogService.LOG_ERROR, "Failure setting up dynamic configuration bindings", ioe );
+            Log.logger.log( LogService.LOG_ERROR, "Failure setting up dynamic configuration bindings", ioe );
         }
         catch ( IllegalArgumentException iae )
         {
-            log( LogService.LOG_ERROR, "Cannot create the FilePersistenceManager", iae );
+            Log.logger.log( LogService.LOG_ERROR, "Cannot create the FilePersistenceManager", iae );
         }
 
         // register as bundle and service listener
@@ -281,7 +232,7 @@ public class ConfigurationManager implem
         props.put( Constants.SERVICE_PID, "org.apache.felix.cm.ConfigurationAdmin" );
         props.put( Constants.SERVICE_DESCRIPTION, "Configuration Admin Service Specification 1.6 Implementation" );
         props.put( Constants.SERVICE_VENDOR, "Apache Software Foundation" );
-        configurationAdminRegistration = bundleContext.registerService( ConfigurationAdmin.class.getName(), caf, props );
+        configurationAdminRegistration = bundleContext.registerService( ConfigurationAdmin.class, caf, props );
 
         // start handling ManagedService[Factory] services
         managedServiceTracker = new ManagedServiceTracker(this);
@@ -291,10 +242,11 @@ public class ConfigurationManager implem
         // see FELIX-2813 for details
         this.updateThread.start();
         this.eventThread.start();
+
+        return configurationAdminRegistration.getReference();
     }
 
 
-    @Override
     public void stop( BundleContext bundleContext )
     {
 
@@ -355,11 +307,6 @@ public class ConfigurationManager implem
             syncConfigurationListenerTracker.close();
         }
 
-        if ( logTracker != null )
-        {
-            logTracker.close();
-        }
-
         // just ensure the configuration cache is empty
         synchronized ( configurations )
         {
@@ -475,7 +422,7 @@ public class ConfigurationManager implem
             }
             catch ( IOException ioe )
             {
-                log( LogService.LOG_ERROR, "Failed storing dynamic configuration binding for {0} to {1}", new Object[]
+                Log.logger.log( LogService.LOG_ERROR, "Failed storing dynamic configuration binding for {0} to {1}", new Object[]
                     { pid, location, ioe } );
             }
         }
@@ -520,14 +467,13 @@ public class ConfigurationManager implem
         if ( serviceBundle != null )
         {
             // list of targeted PIDs to check
-            // (StringBuffer for pre-1.5 API compatibility)
-            final StringBuffer targetedPid = new StringBuffer( rawPid );
+            final StringBuilder targetedPid = new StringBuilder( rawPid );
             int i = 3;
             String[] names = new String[4];
             names[i--] = targetedPid.toString();
             targetedPid.append( '|' ).append( serviceBundle.getSymbolicName() );
             names[i--] = targetedPid.toString();
-            targetedPid.append( '|' ).append( TargetedPID.getBundleVersion( serviceBundle ) );
+            targetedPid.append( '|' ).append( serviceBundle.getVersion().toString() );
             names[i--] = targetedPid.toString();
             targetedPid.append( '|' ).append( serviceBundle.getLocation() );
             names[i--] = targetedPid.toString();
@@ -546,17 +492,17 @@ public class ConfigurationManager implem
 
                     // CM 1.4 / 104.13.2.2 / 104.5.3
                     // act as if there is no configuration
-                    log(
+                    Log.logger.log(
                         LogService.LOG_DEBUG,
                         "Cannot use configuration {0} for {1}: No visibility to configuration bound to {2}; calling with null",
                         new Object[]
-                            { config.getPid(), toString( target ), config.getBundleLocation() } );
+                            { config.getPid(), target , config.getBundleLocation() } );
                 }
             }
         }
         else
         {
-            log( LogService.LOG_INFO,
+            Log.logger.log( LogService.LOG_INFO,
                 "Service for PID {0} seems to already have been unregistered, not updating with configuration",
                 new Object[]
                     { rawPid } );
@@ -582,7 +528,7 @@ public class ConfigurationManager implem
         ConfigurationImpl config = getCachedConfiguration( pid );
         if ( config != null )
         {
-            log( LogService.LOG_DEBUG, "Found cached configuration {0} bound to {1}", new Object[]
+            Log.logger.log( LogService.LOG_DEBUG, "Found cached configuration {0} bound to {1}", new Object[]
                 { pid, config.getBundleLocation() } );
 
             config.ensureFactoryConfigPersisted();
@@ -597,7 +543,7 @@ public class ConfigurationManager implem
             {
                 Dictionary props = pmList[i].load( pid );
                 config = new ConfigurationImpl( this, pmList[i], props );
-                log( LogService.LOG_DEBUG, "Found existing configuration {0} bound to {1}", new Object[]
+                Log.logger.log( LogService.LOG_DEBUG, "Found existing configuration {0} bound to {1}", new Object[]
                     { pid, config.getBundleLocation() } );
                 return cacheConfiguration( config );
             }
@@ -649,7 +595,7 @@ public class ConfigurationManager implem
             filter = SimpleFilter.parse( filterString );
         }
 
-        log( LogService.LOG_DEBUG, "Listing configurations matching {0}", new Object[]
+        Log.logger.log( LogService.LOG_DEBUG, "Listing configurations matching {0}", new Object[]
             { filterString } );
 
         List configList = new ArrayList();
@@ -673,7 +619,7 @@ public class ConfigurationManager implem
                 if ( !configurationAdmin.hasPermission( this,
                     ( String ) config.get( ConfigurationAdmin.SERVICE_BUNDLELOCATION ) ) )
                 {
-                    log(
+                    Log.logger.log(
                         LogService.LOG_DEBUG,
                         "Omitting configuration {0}: No permission for bundle {1} on configuration bound to {2}",
                         new Object[]
@@ -699,13 +645,13 @@ public class ConfigurationManager implem
                 // FELIX-611: Ignore configuration objects without props
                 if ( !cfg.isNew() )
                 {
-                    log( LogService.LOG_DEBUG, "Adding configuration {0}", new Object[]
+                    Log.logger.log( LogService.LOG_DEBUG, "Adding configuration {0}", new Object[]
                         { pid } );
                     configList.add( cfg );
                 }
                 else
                 {
-                    log( LogService.LOG_DEBUG, "Omitting configuration {0}: Is new", new Object[]
+                    Log.logger.log( LogService.LOG_DEBUG, "Omitting configuration {0}: Is new", new Object[]
                         { pid } );
                 }
             }
@@ -726,7 +672,7 @@ public class ConfigurationManager implem
         removeConfiguration( config );
         fireConfigurationEvent( ConfigurationEvent.CM_DELETED, config.getPidString(), config.getFactoryPidString() );
         updateThread.schedule( new DeleteConfiguration( config ) );
-        log( LogService.LOG_DEBUG, "DeleteConfiguration({0}) scheduled", new Object[]
+        Log.logger.log( LogService.LOG_DEBUG, "DeleteConfiguration({0}) scheduled", new Object[]
             { config.getPid() } );
     }
 
@@ -738,7 +684,7 @@ public class ConfigurationManager implem
             fireConfigurationEvent( ConfigurationEvent.CM_UPDATED, config.getPidString(), config.getFactoryPidString() );
         }
         updateThread.schedule( new UpdateConfiguration( config ) );
-        log( LogService.LOG_DEBUG, "UpdateConfiguration({0}) scheduled", new Object[]
+        Log.logger.log( LogService.LOG_DEBUG, "UpdateConfiguration({0}) scheduled", new Object[]
             { config.getPid() } );
     }
 
@@ -749,12 +695,12 @@ public class ConfigurationManager implem
         if ( oldLocation != null && !config.isNew() )
         {
             updateThread.schedule( new LocationChanged( config, oldLocation ) );
-            log( LogService.LOG_DEBUG, "LocationChanged({0}, {1}=>{2}) scheduled", new Object[]
+            Log.logger.log( LogService.LOG_DEBUG, "LocationChanged({0}, {1}=>{2}) scheduled", new Object[]
                 { config.getPid(), oldLocation, config.getBundleLocation() } );
         }
         else
         {
-            log( LogService.LOG_DEBUG,
+            Log.logger.log( LogService.LOG_DEBUG,
                 "LocationChanged not scheduled for {0} (old location is null or configuration is new)", new Object[]
                     { config.getPid() } );
         }
@@ -776,7 +722,7 @@ public class ConfigurationManager implem
         }
         else
         {
-            log( LogService.LOG_DEBUG, "No SynchronousConfigurationListeners to send {0} event to.", new Object[]
+            Log.logger.log( LogService.LOG_DEBUG, "No SynchronousConfigurationListeners to send {0} event to.", new Object[]
                 { syncSender.getTypeName() } );
         }
 
@@ -787,7 +733,7 @@ public class ConfigurationManager implem
         }
         else
         {
-            log( LogService.LOG_DEBUG, "No ConfigurationListeners to send {0} event to.", new Object[]
+            Log.logger.log( LogService.LOG_DEBUG, "No ConfigurationListeners to send {0} event to.", new Object[]
                 { asyncSender.getTypeName() } );
         }
     }
@@ -924,10 +870,10 @@ public class ConfigurationManager implem
      */
     public void configure( String[] pid, ServiceReference sr, final boolean factory, final ConfigurationMap<?> configs )
     {
-        if ( this.isLogEnabled( LogService.LOG_DEBUG ) )
+        if ( Log.logger.isLogEnabled( LogService.LOG_DEBUG ) )
         {
-            this.log( LogService.LOG_DEBUG, "configure(ManagedService {0})", new Object[]
-                { toString( sr ) } );
+            Log.logger.log( LogService.LOG_DEBUG, "configure(ManagedService {0})", new Object[]
+                { sr } );
         }
 
         Runnable r;
@@ -940,7 +886,7 @@ public class ConfigurationManager implem
             r = new ManagedServiceUpdate( pid, sr, configs );
         }
         updateThread.schedule( r );
-        log( LogService.LOG_DEBUG, "[{0}] scheduled", new Object[]
+        Log.logger.log( LogService.LOG_DEBUG, "[{0}] scheduled", new Object[]
             { r } );
     }
 
@@ -969,7 +915,7 @@ public class ConfigurationManager implem
      */
     ConfigurationImpl createConfiguration( String pid, String factoryPid, String bundleLocation ) throws IOException
     {
-        log( LogService.LOG_DEBUG, "createConfiguration({0}, {1}, {2})", new Object[]
+        Log.logger.log( LogService.LOG_DEBUG, "createConfiguration({0}, {1}, {2})", new Object[]
             { pid, factoryPid, bundleLocation } );
         return new ConfigurationImpl( this, getPersistenceManagers()[0], pid, factoryPid, bundleLocation );
     }
@@ -997,8 +943,7 @@ public class ConfigurationManager implem
         final Bundle serviceBundle = target.getBundle();
         if ( serviceBundle != null )
         {
-            // for pre-1.5 API compatibility
-            final StringBuffer targetedPid = new StringBuffer( rawFactoryPid );
+            final StringBuilder targetedPid = new StringBuilder( rawFactoryPid );
             factories.add( getOrCreateFactory( targetedPid.toString() ) );
 
             targetedPid.append( '|' ).append( serviceBundle.getSymbolicName() );
@@ -1008,7 +953,7 @@ public class ConfigurationManager implem
                 factories.add( 0, f );
             }
 
-            targetedPid.append( '|' ).append( TargetedPID.getBundleVersion( serviceBundle ) );
+            targetedPid.append( '|' ).append( serviceBundle.getVersion().toString() );
             f = getFactory( targetedPid.toString() );
             if ( f != null )
             {
@@ -1166,8 +1111,8 @@ public class ConfigurationManager implem
                 }
                 catch ( Throwable t )
                 {
-                    log( LogService.LOG_ERROR, "Unexpected problem calling configuration plugin {0}", new Object[]
-                        { toString( pluginRef ), t } );
+                    Log.logger.log( LogService.LOG_ERROR, "Unexpected problem calling configuration plugin {0}", new Object[]
+                        { pluginRef , t } );
                 }
                 finally
                 {
@@ -1210,7 +1155,7 @@ public class ConfigurationManager implem
         randomBytes[8] &= 0x3f; /* clear variant */
         randomBytes[8] |= 0x80; /* set to IETF variant */
 
-        StringBuffer buf = new StringBuffer( factoryPid.length() + 1 + 36 );
+        StringBuilder buf = new StringBuilder( factoryPid.length() + 1 + 36 );
 
         // prefix the new pid with the factory pid
         buf.append( factoryPid ).append( "." );
@@ -1233,104 +1178,6 @@ public class ConfigurationManager implem
     }
 
 
-    public boolean isLogEnabled( int level )
-    {
-        return level <= logLevel;
-    }
-
-
-    public void log( int level, String format, Object[] args )
-    {
-        if ( isLogEnabled( level ) )
-        {
-            Throwable throwable = null;
-            String message = format;
-
-            if ( args != null && args.length > 0 )
-            {
-                if ( args[args.length - 1] instanceof Throwable )
-                {
-                    throwable = ( Throwable ) args[args.length - 1];
-                }
-                message = MessageFormat.format( format, args );
-            }
-
-            log( level, message, throwable );
-        }
-    }
-
-
-    public void log( int level, String message, Throwable t )
-    {
-        // log using the LogService if available
-        Object log = logTracker.getService();
-        if ( log != null )
-        {
-            ( ( LogService ) log ).log( getServiceReference(), level, message, t );
-            return;
-        }
-
-        // Otherwise only log if more serious than the configured level
-        if ( isLogEnabled( level ) )
-        {
-            String code;
-            switch ( level )
-            {
-                case LogService.LOG_INFO:
-                    code = "*INFO *";
-                    break;
-
-                case LogService.LOG_WARNING:
-                    code = "*WARN *";
-                    break;
-
-                case LogService.LOG_ERROR:
-                    code = "*ERROR*";
-                    break;
-
-                case LogService.LOG_DEBUG:
-                default:
-                    code = "*DEBUG*";
-            }
-
-            System.err.println( code + " " + message );
-            if ( t != null )
-            {
-                t.printStackTrace( System.err );
-            }
-        }
-    }
-
-
-    public static String toString( ServiceReference ref )
-    {
-        String[] ocs = ( String[] ) ref.getProperty( "objectClass" );
-        StringBuffer buf = new StringBuffer( "[" );
-        for ( int i = 0; i < ocs.length; i++ )
-        {
-            buf.append( ocs[i] );
-            if ( i < ocs.length - 1 )
-                buf.append( ", " );
-        }
-
-        buf.append( ", id=" ).append( ref.getProperty( Constants.SERVICE_ID ) );
-
-        Bundle provider = ref.getBundle();
-        if ( provider != null )
-        {
-            buf.append( ", bundle=" ).append( provider.getBundleId() );
-            buf.append( '/' ).append( provider.getLocation() );
-        }
-        else
-        {
-            buf.append( ", unregistered" );
-        }
-
-        buf.append( "]" );
-        return buf.toString();
-    }
-
-
     /**
      * Checks whether the bundle is allowed to receive the configuration
      * with the given location binding.
@@ -1351,7 +1198,7 @@ public class ConfigurationManager implem
     {
         if ( location == null )
         {
-            log( LogService.LOG_DEBUG, "canReceive=true; bundle={0}; configuration=(unbound)", new Object[]
+            Log.logger.log( LogService.LOG_DEBUG, "canReceive=true; bundle={0}; configuration=(unbound)", new Object[]
                 { bundle.getLocation() } );
             return true;
         }
@@ -1362,13 +1209,13 @@ public class ConfigurationManager implem
             {
                 final boolean hasPermission = bundle.hasPermission( new ConfigurationPermission( location,
                     ConfigurationPermission.TARGET ) );
-                log( LogService.LOG_DEBUG, "canReceive={0}: bundle={1}; configuration={2} (SecurityManager check)",
+                Log.logger.log( LogService.LOG_DEBUG, "canReceive={0}: bundle={1}; configuration={2} (SecurityManager check)",
                     new Object[]
                         { new Boolean( hasPermission ), bundle.getLocation(), location } );
                 return hasPermission;
             }
 
-            log( LogService.LOG_DEBUG, "canReceive=true; bundle={0}; configuration={1} (no SecurityManager)",
+            Log.logger.log( LogService.LOG_DEBUG, "canReceive=true; bundle={0}; configuration={1} (no SecurityManager)",
                 new Object[]
                     { bundle.getLocation(), location } );
             return true;
@@ -1377,7 +1224,7 @@ public class ConfigurationManager implem
         {
             // single location, must match
             final boolean hasPermission = location.equals( bundle.getLocation() );
-            log( LogService.LOG_DEBUG, "canReceive={0}: bundle={1}; configuration={2}", new Object[]
+            Log.logger.log( LogService.LOG_DEBUG, "canReceive={0}: bundle={1}; configuration={2}", new Object[]
                 { new Boolean( hasPermission ), bundle.getLocation(), location } );
             return hasPermission;
         }
@@ -1421,14 +1268,14 @@ public class ConfigurationManager implem
                 }
                 catch ( IOException ioe )
                 {
-                    log( LogService.LOG_ERROR, "Error loading configuration for {0}", new Object[]
+                    Log.logger.log( LogService.LOG_ERROR, "Error loading configuration for {0}", new Object[]
                         { pid, ioe } );
                 }
                 catch ( Exception e )
                 {
-                    log( LogService.LOG_ERROR, "Unexpected problem providing configuration {0} to service {1}",
+                    Log.logger.log( LogService.LOG_ERROR, "Unexpected problem providing configuration {0} to service {1}",
                         new Object[]
-                            { pid, ConfigurationManager.toString( this.sr ), e } );
+                            { pid, this.sr, e } );
                 }
             }
         }
@@ -1458,7 +1305,7 @@ public class ConfigurationManager implem
                 revision = -1;
             }
 
-            log( LogService.LOG_DEBUG, "Updating service {0} with configuration {1}@{2}", new Object[]
+            Log.logger.log( LogService.LOG_DEBUG, "Updating service {0} with configuration {1}@{2}", new Object[]
                 { servicePid, configPid, new Long( revision ) } );
 
             managedServiceTracker.provideConfiguration( sr, configPid, null, properties, revision, this.configs );
@@ -1517,7 +1364,7 @@ public class ConfigurationManager implem
                             }
                             catch ( IOException ioe )
                             {
-                                log( LogService.LOG_ERROR, "Error loading configuration for {0}", new Object[]
+                                Log.logger.log( LogService.LOG_ERROR, "Error loading configuration for {0}", new Object[]
                                     { pid, ioe } );
                                 continue;
                             }
@@ -1525,7 +1372,7 @@ public class ConfigurationManager implem
                             // sanity check on the configuration
                             if ( cfg == null )
                             {
-                                log( LogService.LOG_ERROR,
+                                Log.logger.log( LogService.LOG_ERROR,
                                     "Configuration {0} referred to by factory {1} does not exist", new Object[]
                                         { pid, factoryPid } );
                                 factory.removePID( pid );
@@ -1540,7 +1387,7 @@ public class ConfigurationManager implem
                                 // As of FELIX-612 (not storing new factory configurations)
                                 // this should not happen. We keep this for added stability
                                 // but raise the logging level to error.
-                                log( LogService.LOG_ERROR, "Ignoring new configuration pid={0}", new Object[]
+                                Log.logger.log( LogService.LOG_ERROR, "Ignoring new configuration pid={0}", new Object[]
                                     { pid } );
                                 continue;
                             }
@@ -1569,7 +1416,7 @@ public class ConfigurationManager implem
                 }
                 catch ( IOException ioe )
                 {
-                    log( LogService.LOG_ERROR, "Cannot get factory mapping for factory PID {0}", new Object[]
+                    Log.logger.log( LogService.LOG_ERROR, "Cannot get factory mapping for factory PID {0}", new Object[]
                         { factoryPid, ioe } );
                 }
             }
@@ -1586,14 +1433,14 @@ public class ConfigurationManager implem
                 revision = config.getRevision();
             }
 
-            log( LogService.LOG_DEBUG, "Updating service {0} with configuration {1}/{2}@{3}", new Object[]
+            Log.logger.log( LogService.LOG_DEBUG, "Updating service {0} with configuration {1}/{2}@{3}", new Object[]
                 { factoryPid, config.getFactoryPid(), config.getPid(), new Long( revision ) } );
 
             // CM 1.4 / 104.13.2.1
             final Bundle serviceBundle = this.sr.getBundle();
             if ( serviceBundle == null )
             {
-                log(
+                Log.logger.log(
                     LogService.LOG_INFO,
                     "ManagedServiceFactory for factory PID {0} seems to already have been unregistered, not updating with factory",
                     new Object[]
@@ -1603,10 +1450,10 @@ public class ConfigurationManager implem
 
             if ( !canReceive( serviceBundle, config.getBundleLocation() ) )
             {
-                log( LogService.LOG_ERROR,
+                Log.logger.log( LogService.LOG_ERROR,
                     "Cannot use configuration {0} for {1}: No visibility to configuration bound to {2}",
                     new Object[]
-                        { config.getPid(), ConfigurationManager.toString( sr ), config.getBundleLocation() } );
+                        { config.getPid(), sr , config.getBundleLocation() } );
 
                 // no service, really, bail out
                 return;
@@ -1618,8 +1465,8 @@ public class ConfigurationManager implem
             // update the service with the configuration (if non-null)
             if ( rawProperties != null )
             {
-                log( LogService.LOG_DEBUG, "{0}: Updating configuration pid={1}", new Object[]
-                    { ConfigurationManager.toString( sr ), config.getPid() } );
+                Log.logger.log( LogService.LOG_DEBUG, "{0}: Updating configuration pid={1}", new Object[]
+                    { sr, config.getPid() } );
                 managedServiceFactoryTracker.provideConfiguration( sr, config.getPid(), config.getFactoryPid(),
                     rawProperties, revision, this.configs );
             }
@@ -1705,14 +1552,14 @@ public class ConfigurationManager implem
                 }
                 catch ( IOException ioe )
                 {
-                    log( LogService.LOG_ERROR, "Error loading configuration for {0}", new Object[]
+                    Log.logger.log( LogService.LOG_ERROR, "Error loading configuration for {0}", new Object[]
                         { this.config.getPid(), ioe } );
                 }
                 catch ( Exception e )
                 {
-                    log( LogService.LOG_ERROR, "Unexpected problem providing configuration {0} to service {1}",
+                    Log.logger.log( LogService.LOG_ERROR, "Unexpected problem providing configuration {0} to service {1}",
                         new Object[]
-                            { this.config.getPid(), ConfigurationManager.toString( sr ), e } );
+                            { this.config.getPid(), sr, e } );
                 }
             }
 
@@ -1739,7 +1586,7 @@ public class ConfigurationManager implem
         @Override
         public void run()
         {
-            log( LogService.LOG_DEBUG, "Updating configuration {0} to revision #{1}", new Object[]
+            Log.logger.log( LogService.LOG_DEBUG, "Updating configuration {0} to revision #{1}", new Object[]
                 { config.getPid(), new Long( revision ) } );
 
             final List<ServiceReference<?>> srList = this.getHelper().getServices( getTargetedServicePid() );
@@ -1748,10 +1595,10 @@ public class ConfigurationManager implem
                 // optionally bind dynamically to the first service
                 Bundle bundle = srList.get(0).getBundle();
                 if (bundle == null) {
-                    log( LogService.LOG_DEBUG,
+                    Log.logger.log( LogService.LOG_DEBUG,
                         "Service {0} seems to be unregistered concurrently (not providing configuration)",
                         new Object[]
-                            { ConfigurationManager.toString( srList.get(0) ) } );
+                            { srList.get(0) } );
                     return;
                 }
                 config.tryBindLocation( bundle.getLocation() );
@@ -1765,10 +1612,10 @@ public class ConfigurationManager implem
                     final Bundle refBundle = ref.getBundle();
                     if ( refBundle == null )
                     {
-                        log( LogService.LOG_DEBUG,
+                        Log.logger.log( LogService.LOG_DEBUG,
                             "Service {0} seems to be unregistered concurrently (not providing configuration)",
                             new Object[]
-                                { ConfigurationManager.toString( ref ) } );
+                                { ref } );
                     }
                     else if ( canReceive( refBundle, configBundleLocation ) )
                     {
@@ -1778,17 +1625,17 @@ public class ConfigurationManager implem
                     else
                     {
                         // CM 1.4 / 104.13.2.2
-                        log( LogService.LOG_ERROR,
+                        Log.logger.log( LogService.LOG_ERROR,
                             "Cannot use configuration {0} for {1}: No visibility to configuration bound to {2}",
                             new Object[]
-                                { config.getPid(), ConfigurationManager.toString( ref ), configBundleLocation } );
+                                { config.getPid(), ref, configBundleLocation } );
                     }
 
                 }
             }
-            else if ( isLogEnabled( LogService.LOG_DEBUG ) )
+            else if ( Log.logger.isLogEnabled( LogService.LOG_DEBUG ) )
             {
-                log( LogService.LOG_DEBUG, "No ManagedService[Factory] registered for updates to configuration {0}",
+                Log.logger.log( LogService.LOG_DEBUG, "No ManagedService[Factory] registered for updates to configuration {0}",
                     new Object[]
                         { config.getPid() } );
             }
@@ -1837,10 +1684,10 @@ public class ConfigurationManager implem
                     final Bundle srBundle = sr.getBundle();
                     if ( srBundle == null )
                     {
-                        log( LogService.LOG_DEBUG,
+                        Log.logger.log( LogService.LOG_DEBUG,
                             "Service {0} seems to be unregistered concurrently (not removing configuration)",
                             new Object[]
-                                { ConfigurationManager.toString( sr ) } );
+                                { sr } );
                     }
                     else if ( canReceive( srBundle, configLocation ) )
                     {
@@ -1854,10 +1701,10 @@ public class ConfigurationManager implem
                     else
                     {
                         // CM 1.4 / 104.13.2.2
-                        log( LogService.LOG_ERROR,
+                        Log.logger.log( LogService.LOG_ERROR,
                             "Cannot remove configuration {0} for {1}: No visibility to configuration bound to {2}",
                             new Object[]
-                                { config.getPid(), ConfigurationManager.toString( sr ), configLocation } );
+                                { config.getPid(), sr, configLocation } );
                     }
                 }
             }
@@ -1875,7 +1722,7 @@ public class ConfigurationManager implem
                 }
                 catch ( IOException ioe )
                 {
-                    log( LogService.LOG_ERROR, "Failed removing {0} from the factory {1}", new Object[]
+                    Log.logger.log( LogService.LOG_ERROR, "Failed removing {0} from the factory {1}", new Object[]
                         { pid, factoryPid, ioe } );
                 }
             }
@@ -1911,9 +1758,9 @@ public class ConfigurationManager implem
                     final Bundle srBundle = sr.getBundle();
                     if ( srBundle == null )
                     {
-                        log( LogService.LOG_DEBUG,
+                        Log.logger.log( LogService.LOG_DEBUG,
                             "Service {0} seems to be unregistered concurrently (not processing)", new Object[]
-                                { ConfigurationManager.toString( sr ) } );
+                                { sr } );
                         continue;
                     }
 
@@ -1934,9 +1781,9 @@ public class ConfigurationManager implem
                         if ( !this.provideReplacement( sr ) )
                         {
                             this.getHelper().removeConfiguration( sr, this.config.getPid(), this.config.getFactoryPid() );
-                            log( LogService.LOG_DEBUG, "Configuration {0} revoked from {1} (no more visibility)",
+                            Log.logger.log( LogService.LOG_DEBUG, "Configuration {0} revoked from {1} (no more visibility)",
                                 new Object[]
-                                    { config.getPid(), ConfigurationManager.toString( sr ) } );
+                                    { config.getPid(), sr } );
                         }
                     }
                     else if ( !wasVisible && isVisible )
@@ -1944,14 +1791,14 @@ public class ConfigurationManager implem
                         // call updated method
                         this.getHelper().provideConfiguration( sr, this.config.getPid(), this.config.getFactoryPid(),
                             this.properties, this.revision, null );
-                        log( LogService.LOG_DEBUG, "Configuration {0} provided to {1} (new visibility)", new Object[]
-                            { config.getPid(), ConfigurationManager.toString( sr ) } );
+                        Log.logger.log( LogService.LOG_DEBUG, "Configuration {0} provided to {1} (new visibility)", new Object[]
+                            { config.getPid(), sr } );
                     }
                     else
                     {
                         // same visibility as before
-                        log( LogService.LOG_DEBUG, "Unmodified visibility to configuration {0} for {1}", new Object[]
-                            { config.getPid(), ConfigurationManager.toString( sr ) } );
+                        Log.logger.log( LogService.LOG_DEBUG, "Unmodified visibility to configuration {0} for {1}", new Object[]
+                            { config.getPid(), sr } );
                     }
                 }
             }
@@ -2063,8 +1910,8 @@ public class ConfigurationManager implem
             if ( (listenerProvider[serviceIndex].getState() & (Bundle.ACTIVE | Bundle.STARTING)) > 0
                     && this.listeners[serviceIndex] != null )
             {
-                log( LogService.LOG_DEBUG, "Sending {0} event for {1} to {2}", new Object[]
-                    { getTypeName(), pid, ConfigurationManager.toString( listenerReferences[serviceIndex] ) } );
+                Log.logger.log( LogService.LOG_DEBUG, "Sending {0} event for {1} to {2}", new Object[]
+                    { getTypeName(), pid, listenerReferences[serviceIndex]} );
 
                 try
                 {
@@ -2072,8 +1919,8 @@ public class ConfigurationManager implem
                 }
                 catch ( Throwable t )
                 {
-                    log( LogService.LOG_ERROR, "Unexpected problem delivering configuration event to {0}", new Object[]
-                        { ConfigurationManager.toString( listenerReferences[serviceIndex] ), t } );
+                    Log.logger.log( LogService.LOG_ERROR, "Unexpected problem delivering configuration event to {0}", new Object[]
+                        { listenerReferences[serviceIndex], t } );
                 }
                 finally
                 {

Modified: felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/Factory.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/Factory.java?rev=1776251&r1=1776250&r2=1776251&view=diff
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/Factory.java (original)
+++ felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/Factory.java Wed Dec 28 09:41:36 2016
@@ -33,7 +33,7 @@ import org.apache.felix.cm.impl.helper.T
  * The <code>Factory</code> class is used to manage mappings between factory
  * PIDs the configuration PID belonging to it.
  */
-class Factory extends ConfigurationBase
+public class Factory extends ConfigurationBase
 {
 
     public static final String FACTORY_PID = "factory.pid";
@@ -58,7 +58,7 @@ class Factory extends ConfigurationBase
     }
 
 
-    static String factoryPidToIdentifier( String factoryPid )
+    public static String factoryPidToIdentifier( String factoryPid )
     {
         return factoryPid + ".factory";
     }
@@ -117,6 +117,7 @@ class Factory extends ConfigurationBase
     }
 
 
+    @Override
     void store() throws IOException
     {
         Hashtable props = new Hashtable();

Added: felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/Log.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/Log.java?rev=1776251&view=auto
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/Log.java (added)
+++ felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/Log.java Wed Dec 28 09:41:36 2016
@@ -0,0 +1,250 @@
+/*
+ * 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.cm.impl;
+
+import java.text.MessageFormat;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.service.log.LogService;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * Log implementation either logging to a {@code LogService} or to {@code System.err}.
+ * The logger can be get using the static {@link #logger} field.
+ *
+ * The logger is initialized through {@link #start(BundleContext)} and {@link #set(ServiceReference)}.
+ * It gets cleaned up through {@link #stop()}.
+ */
+public class Log
+{
+    /** The shared logger instance. */
+    public static final Log logger = new Log();
+
+    /**
+     * The name of the bundle context property defining the maximum log level
+     * (value is "felix.cm.loglevel"). The log level setting is only used if
+     * there is no OSGi LogService available. Otherwise this setting is ignored.
+     * <p>
+     * This value of this property is expected to be an integer number
+     * corresponding to the log level values of the OSGi LogService. That is 1
+     * for errors, 2 for warnings, 3 for informational messages and 4 for debug
+     * messages. The default value is 2, such that only warnings and errors are
+     * logged in the absence of a LogService.
+     */
+    private static final String CM_LOG_LEVEL = "felix.cm.loglevel";
+
+    // The name of the LogService (not using the class, which might be missing)
+    private static final String LOG_SERVICE_NAME = "org.osgi.service.log.LogService";
+
+    private static final int CM_LOG_LEVEL_DEFAULT = 2;
+
+    // the ServiceTracker to emit log services (see log(int, String, Throwable))
+    private volatile ServiceTracker logTracker;
+
+    // the maximum log level when no LogService is available
+    private volatile int logLevel = CM_LOG_LEVEL_DEFAULT;
+
+    private volatile ServiceReference<ConfigurationAdmin> serviceReference;
+
+    /**
+     * Start the tracker for the logger and set the log level according to the configuration.
+     * @param bundleContext The bundle context
+     */
+    public void start( final BundleContext bundleContext)
+    {
+        // track the log service using a ServiceTracker
+        logTracker = new ServiceTracker( bundleContext, LOG_SERVICE_NAME , null );
+        logTracker.open();
+
+        // assign the log level
+        String logLevelProp = bundleContext.getProperty( CM_LOG_LEVEL );
+        if ( logLevelProp == null )
+        {
+            logLevel = CM_LOG_LEVEL_DEFAULT;
+        }
+        else
+        {
+            try
+            {
+                logLevel = Integer.parseInt( logLevelProp );
+            }
+            catch ( NumberFormatException nfe )
+            {
+                logLevel = CM_LOG_LEVEL_DEFAULT;
+            }
+        }
+    }
+
+    /**
+     * Set the service reference to the configuration admin in order to include this
+     * in every log message.
+     * @param ref The service reference
+     */
+    public void set(final ServiceReference<ConfigurationAdmin> ref)
+    {
+        this.serviceReference = ref;
+    }
+
+    /**
+     * Stop the log service tracker and clear the service reference
+     */
+    public void stop()
+    {
+        if ( logTracker != null )
+        {
+            logTracker.close();
+            logTracker = null;
+        }
+        serviceReference = null;
+    }
+
+    /**
+     * Is the log level enabled?
+     * @param level The level
+     * @return {@code true} if enabled
+     */
+    public boolean isLogEnabled( final int level )
+    {
+        return level <= logLevel;
+    }
+
+    /**
+     * Log a message in the given level.
+     * If arguments are provided and contain a {@code ServiceReference} then
+     * the argument is replaced with the result of {@link #toString(ServiceReference)}.
+     *
+     * @param level The log level
+     * @param format The message text
+     * @param args The optional arguments
+     */
+    public void log( final int level, final String format, final Object[] args )
+    {
+        final ServiceTracker tracker = this.logTracker;
+        final Object log = tracker == null ? null : tracker.getService();
+        if ( log != null || isLogEnabled( level ) )
+        {
+            Throwable throwable = null;
+            String message = format;
+
+            if ( args != null && args.length > 0 )
+            {
+                for(int i=0; i<args.length; i++)
+                {
+                    if ( args[i] instanceof ServiceReference )
+                    {
+                        args[i] = toString((ServiceReference)args[i]);
+                    }
+                }
+                if ( args[args.length - 1] instanceof Throwable )
+                {
+                    throwable = ( Throwable ) args[args.length - 1];
+                }
+                message = MessageFormat.format( format, args );
+            }
+
+            log( level, message, throwable );
+        }
+    }
+
+    /**
+     * Log the message with the given level and throwable.
+     * @param level The log level
+     * @param message The message
+     * @param t The exception
+     */
+    public void log( final int level, final String message, final Throwable t )
+    {
+        // log using the LogService if available
+        final ServiceTracker tracker = this.logTracker;
+        final Object log = tracker == null ? null : tracker.getService();
+        if ( log != null )
+        {
+            ( ( LogService ) log ).log( serviceReference, level, message, t );
+            return;
+        }
+
+        // Otherwise only log if more serious than the configured level
+        if ( isLogEnabled( level ) )
+        {
+            String code;
+            switch ( level )
+            {
+                case LogService.LOG_INFO:
+                    code = "*INFO *";
+                    break;
+
+                case LogService.LOG_WARNING:
+                    code = "*WARN *";
+                    break;
+
+                case LogService.LOG_ERROR:
+                    code = "*ERROR*";
+                    break;
+
+                case LogService.LOG_DEBUG:
+                default:
+                    code = "*DEBUG*";
+            }
+
+            System.err.println( code + " " + message );
+            if ( t != null )
+            {
+                t.printStackTrace( System.err );
+            }
+        }
+    }
+
+    /**
+     * Create a string representation of the service reference
+     * @param ref The service reference
+     * @return The string representation
+     */
+    private static String toString( final ServiceReference<?> ref )
+    {
+        String[] ocs = ( String[] ) ref.getProperty( "objectClass" );
+        StringBuilder buf = new StringBuilder( "[" );
+        for ( int i = 0; i < ocs.length; i++ )
+        {
+            buf.append( ocs[i] );
+            if ( i < ocs.length - 1 )
+                buf.append( ", " );
+        }
+
+        buf.append( ", id=" ).append( ref.getProperty( Constants.SERVICE_ID ) );
+
+        Bundle provider = ref.getBundle();
+        if ( provider != null )
+        {
+            buf.append( ", bundle=" ).append( provider.getBundleId() );
+            buf.append( '/' ).append( provider.getLocation() );
+        }
+        else
+        {
+            buf.append( ", unregistered" );
+        }
+
+        buf.append( "]" );
+        return buf.toString();
+    }
+}
+

Propchange: felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/Log.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/Log.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Modified: felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/UpdateThread.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/UpdateThread.java?rev=1776251&r1=1776250&r2=1776251&view=diff
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/UpdateThread.java (original)
+++ felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/UpdateThread.java Wed Dec 28 09:41:36 2016
@@ -34,10 +34,6 @@ import org.osgi.service.log.LogService;
 public class UpdateThread implements Runnable
 {
 
-    // the configuration manager on whose behalf this thread is started
-    // (this is mainly used for logging)
-    private final ConfigurationManager configurationManager;
-
     // the thread group into which the worker thread will be placed
     private final ThreadGroup workerThreadGroup;
 
@@ -53,9 +49,8 @@ public class UpdateThread implements Run
     // the access control context
     private final AccessControlContext acc;
 
-    public UpdateThread( final ConfigurationManager configurationManager, final ThreadGroup tg, final String name )
+    public UpdateThread( final ThreadGroup tg, final String name )
     {
-        this.configurationManager = configurationManager;
         this.workerThreadGroup = tg;
         this.workerBaseName = name;
         this.acc = AccessController.getContext();
@@ -69,6 +64,7 @@ public class UpdateThread implements Run
     // happening and keeps on waiting for the next Runnable. If the Runnable
     // taken from the queue is this thread instance itself, the thread
     // terminates.
+    @Override
     public void run()
     {
         for ( ;; )
@@ -103,14 +99,14 @@ public class UpdateThread implements Run
                 // set the thread name indicating the current task
                 Thread.currentThread().setName( workerBaseName + " (" + task + ")" );
 
-                configurationManager.log( LogService.LOG_DEBUG, "Running task {0}", new Object[]
+                Log.logger.log( LogService.LOG_DEBUG, "Running task {0}", new Object[]
                     { task } );
 
                 run0(task);
             }
             catch ( Throwable t )
             {
-                configurationManager.log( LogService.LOG_ERROR, "Unexpected problem executing task", t );
+                Log.logger.log( LogService.LOG_ERROR, "Unexpected problem executing task", t );
             }
             finally
             {
@@ -125,6 +121,7 @@ public class UpdateThread implements Run
             try {
                 AccessController.doPrivileged(
                     new PrivilegedExceptionAction<Void>() {
+                        @Override
                         public Void run() throws Exception {
                             task.run();
                             return null;
@@ -194,7 +191,7 @@ public class UpdateThread implements Run
 
             if ( workerThread.isAlive() )
             {
-                this.configurationManager.log( LogService.LOG_ERROR,
+                Log.logger.log( LogService.LOG_ERROR,
                     "Worker thread {0} did not terminate within 5 seconds; trying to kill", new Object[]
                         { workerBaseName } );
                 workerThread.stop();
@@ -208,7 +205,7 @@ public class UpdateThread implements Run
     {
         synchronized ( updateTasks )
         {
-            configurationManager.log( LogService.LOG_DEBUG, "Scheduling task {0}", new Object[]
+            Log.logger.log( LogService.LOG_DEBUG, "Scheduling task {0}", new Object[]
                 { update } );
 
             // append to the task queue

Modified: felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/helper/BaseTracker.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/helper/BaseTracker.java?rev=1776251&r1=1776250&r2=1776251&view=diff
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/helper/BaseTracker.java (original)
+++ felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/helper/BaseTracker.java Wed Dec 28 09:41:36 2016
@@ -32,6 +32,7 @@ import java.util.List;
 
 import org.apache.felix.cm.impl.CaseInsensitiveDictionary;
 import org.apache.felix.cm.impl.ConfigurationManager;
+import org.apache.felix.cm.impl.Log;
 import org.apache.felix.cm.impl.RankingComparator;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
@@ -66,10 +67,11 @@ public abstract class BaseTracker<S> ext
     }
 
 
+    @Override
     public ConfigurationMap<?> addingService( ServiceReference<S> reference )
     {
-        this.cm.log( LogService.LOG_DEBUG, "Registering service {0}", new String[]
-            { ConfigurationManager.toString( reference ) } );
+        Log.logger.log( LogService.LOG_DEBUG, "Registering service {0}", new Object[]
+            { reference } );
 
         final String[] pids = getServicePid( reference );
         final ConfigurationMap<?> configurations = createConfigurationMap( pids );
@@ -81,8 +83,8 @@ public abstract class BaseTracker<S> ext
     @Override
     public void modifiedService( ServiceReference<S> reference, ConfigurationMap<?> service )
     {
-        this.cm.log( LogService.LOG_DEBUG, "Modified service {0}", new String[]
-            { ConfigurationManager.toString( reference ) } );
+        Log.logger.log( LogService.LOG_DEBUG, "Modified service {0}", new Object[]
+            { reference} );
 
         String[] pids = getServicePid( reference );
         if ( service.isDifferentPids( pids ) )
@@ -97,8 +99,8 @@ public abstract class BaseTracker<S> ext
     public void removedService( ServiceReference<S> reference, ConfigurationMap<?> service )
     {
         // just log
-        this.cm.log( LogService.LOG_DEBUG, "Unregistering service {0}", new String[]
-            { ConfigurationManager.toString( reference ) } );
+        Log.logger.log( LogService.LOG_DEBUG, "Unregistering service {0}", new Object[]
+            { reference } );
     }
 
 
@@ -228,22 +230,22 @@ public abstract class BaseTracker<S> ext
             final ConfigurationException ce = ( ConfigurationException ) error;
             if ( ce.getProperty() != null )
             {
-                this.cm.log( LogService.LOG_ERROR,
+                Log.logger.log( LogService.LOG_ERROR,
                     "{0}: Updating property {1} of configuration {2} caused a problem: {3}", new Object[]
-                        { ConfigurationManager.toString( target ), ce.getProperty(), pid, ce.getReason(), ce } );
+                        { target , ce.getProperty(), pid, ce.getReason(), ce } );
             }
             else
             {
-                this.cm.log( LogService.LOG_ERROR, "{0}: Updating configuration {1} caused a problem: {2}",
+                Log.logger.log( LogService.LOG_ERROR, "{0}: Updating configuration {1} caused a problem: {2}",
                     new Object[]
-                        { ConfigurationManager.toString( target ), pid, ce.getReason(), ce } );
+                        { target, pid, ce.getReason(), ce } );
             }
         }
         else
         {
             {
-                this.cm.log( LogService.LOG_ERROR, "{0}: Unexpected problem updating configuration {1}", new Object[]
-                    { ConfigurationManager.toString( target ), pid, error } );
+                Log.logger.log( LogService.LOG_ERROR, "{0}: Unexpected problem updating configuration {1}", new Object[]
+                    { target, pid, error } );
             }
 
         }
@@ -302,6 +304,7 @@ public abstract class BaseTracker<S> ext
             this.bundle = bundle;
         }
 
+        @Override
         public ProtectionDomain[] combine(ProtectionDomain[] arg0,
                                           ProtectionDomain[] arg1) {
             return new ProtectionDomain[] { new CMProtectionDomain(bundle) };
@@ -318,6 +321,7 @@ public abstract class BaseTracker<S> ext
             this.bundle = bundle;
         }
 
+        @Override
         public boolean implies(Permission permission) {
             try {
                 return bundle.hasPermission(permission);

Modified: felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/helper/TargetedPID.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/helper/TargetedPID.java?rev=1776251&r1=1776250&r2=1776251&view=diff
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/helper/TargetedPID.java (original)
+++ felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/helper/TargetedPID.java Wed Dec 28 09:41:36 2016
@@ -20,9 +20,7 @@ package org.apache.felix.cm.impl.helper;
 
 
 import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
-import org.osgi.framework.Version;
 
 
 /**
@@ -55,27 +53,6 @@ public class TargetedPID
      */
     private final short bindingLevel;
 
-
-    /**
-     * Returns the bundle's version as required for targeted PIDs: If the
-     * bundle has a version the string representation of the version
-     * string converted to a Version object is returned. Otherwise the
-     * string representation of <code>Version.emptyVersion</code> is
-     * returned.
-     * <p>
-     * To remain compatible with pre-R4.2 (Framework API < 1.5) we cannot
-     * use the <code>Bundle.getVersion()</code> method.
-     *
-     * @param bundle The bundle whose version is to be returned.
-     */
-    public static String getBundleVersion( final Bundle bundle )
-    {
-        Object vHeader = bundle.getHeaders().get( Constants.BUNDLE_VERSION );
-        Version version = ( vHeader == null ) ? Version.emptyVersion : new Version( vHeader.toString() );
-        return version.toString();
-    }
-
-
     public TargetedPID( final String rawPid )
     {
         this.rawPid = rawPid;
@@ -173,7 +150,7 @@ public class TargetedPID
 
         // bundle version does not match
 
-        if ( !this.version.equals( getBundleVersion( serviceBundle ) ) )
+        if ( !this.version.equals( serviceBundle.getVersion().toString() ) )
         {
             return false;
         }



Mime
View raw message