felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1776381 - in /felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl: ConfigurationBase.java ConfigurationManager.java Factory.java Log.java helper/BaseTracker.java
Date Thu, 29 Dec 2016 07:29:00 GMT
Author: cziegeler
Date: Thu Dec 29 07:29:00 2016
New Revision: 1776381

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

Modified:
    felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationBase.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/Log.java
    felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/helper/BaseTracker.java

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=1776381&r1=1776380&r2=1776381&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
Thu Dec 29 07:29:00 2016
@@ -106,7 +106,7 @@ abstract class ConfigurationBase
     }
 
 
-    static protected void replaceProperty( Dictionary properties, String key, String value
)
+    static protected void replaceProperty( Dictionary<String, Object> properties, String
key, String value )
     {
         if ( value == null )
         {

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=1776381&r1=1776380&r2=1776381&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
Thu Dec 29 07:29:00 2016
@@ -55,6 +55,8 @@ import org.osgi.service.cm.Configuration
 import org.osgi.service.cm.ConfigurationListener;
 import org.osgi.service.cm.ConfigurationPermission;
 import org.osgi.service.cm.ConfigurationPlugin;
+import org.osgi.service.cm.ManagedService;
+import org.osgi.service.cm.ManagedServiceFactory;
 import org.osgi.service.cm.SynchronousConfigurationListener;
 import org.osgi.service.log.LogService;
 import org.osgi.util.tracker.ServiceTracker;
@@ -179,7 +181,7 @@ public class ConfigurationManager implem
 
         // get all persistence managers to begin with
         pmtCount = 1; // make sure to get the persistence managers at least once
-        persistenceManagerTracker = new ServiceTracker( bundleContext, PersistenceManager.class.getName(),
null );
+        persistenceManagerTracker = new ServiceTracker<PersistenceManager, PersistenceManager>(
bundleContext, PersistenceManager.class.getName(), null );
         persistenceManagerTracker.open();
 
         // consider alive now (before clients use Configuration Admin
@@ -1008,7 +1010,7 @@ public class ConfigurationManager implem
      * configurations) or the PID of the configuration (for non-factory
      * configurations).
      *
-     * @param props The configuraiton properties run through the registered
+     * @param props The configuration properties run through the registered
      *          ConfigurationPlugin services. This must not be
      *          <code>null</code>.
      * @param sr The service reference of the managed service (factory) which
@@ -1019,7 +1021,7 @@ public class ConfigurationManager implem
      *          properties are to be augmented. This is non-<code>null</code>
      *          only for a factory configuration.
      */
-    public void callPlugins( final Dictionary props, final ServiceReference sr, final String
configPid,
+    public void callPlugins( final Dictionary<String, Object> props, final ServiceReference<?>
sr, final String configPid,
         final String factoryPid )
     {
         ServiceReference<?>[] plugins = null;
@@ -1200,12 +1202,12 @@ public class ConfigurationManager implem
     {
         private final String[] pids;
 
-        private final ServiceReference sr;
+        private final ServiceReference<ManagedService> sr;
 
         private final ConfigurationMap<?> configs;
 
 
-        ManagedServiceUpdate( String[] pids, ServiceReference sr, ConfigurationMap<?>
configs )
+        ManagedServiceUpdate( String[] pids, ServiceReference<ManagedService> sr, ConfigurationMap<?>
configs )
         {
             this.pids = pids;
             this.sr = sr;
@@ -1242,7 +1244,7 @@ public class ConfigurationManager implem
         {
             // check configuration
             final TargetedPID configPid;
-            final Dictionary properties;
+            final Dictionary<String, Object> properties;
             final long revision;
             if ( config != null )
             {
@@ -1286,12 +1288,12 @@ public class ConfigurationManager implem
     {
         private final String[] factoryPids;
 
-        private final ServiceReference sr;
+        private final ServiceReference<ManagedServiceFactory> sr;
 
         private final ConfigurationMap<?> configs;
 
 
-        ManagedServiceFactoryUpdate( String[] factoryPids, ServiceReference sr, final ConfigurationMap<?>
configs )
+        ManagedServiceFactoryUpdate( String[] factoryPids, ServiceReference<ManagedServiceFactory>
sr, final ConfigurationMap<?> configs )
         {
             this.factoryPids = factoryPids;
             this.sr = sr;
@@ -1312,9 +1314,9 @@ public class ConfigurationManager implem
                     for ( Factory factory : factories )
                     {
                         synchronized (factory) {
-                            for ( Iterator pi = factory.getPIDs().iterator(); pi.hasNext();
)
+                            for ( Iterator<String> pi = factory.getPIDs().iterator();
pi.hasNext(); )
                             {
-                                final String pid = ( String ) pi.next();
+                                final String pid = pi.next();
                                 ConfigurationImpl cfg;
                                 try
                                 {
@@ -1384,7 +1386,7 @@ public class ConfigurationManager implem
 
         private void provide(final String factoryPid, final ConfigurationImpl config) {
 
-            final Dictionary rawProperties;
+            final Dictionary<String, Object> rawProperties;
             final long revision;
             synchronized ( config )
             {
@@ -1495,7 +1497,7 @@ public class ConfigurationManager implem
                     if ( rc != null )
                     {
                         final TargetedPID configPid;
-                        final Dictionary properties;
+                        final Dictionary<String, Object> properties;
                         final long revision;
                         synchronized ( rc )
                         {

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=1776381&r1=1776380&r2=1776381&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 Thu Dec 29
07:29:00 2016
@@ -41,7 +41,7 @@ public class Factory extends Configurati
     public static final String FACTORY_PID_LIST = "factory.pidList";
 
     // the set of configuration PIDs belonging to this factory
-    private final Set pids = new HashSet();;
+    private final Set<String> pids = new HashSet<String>();
 
 
     static boolean exists( PersistenceManager persistenceManager, String factoryPid )
@@ -53,7 +53,8 @@ public class Factory extends Configurati
     static Factory load( ConfigurationManager configurationManager, PersistenceManager persistenceManager,
         String factoryPid ) throws IOException
     {
-        Dictionary dict = persistenceManager.load( factoryPidToIdentifier( factoryPid ) );
+        @SuppressWarnings("unchecked")
+        Dictionary<String, Object> dict = persistenceManager.load( factoryPidToIdentifier(
factoryPid ) );
         return new Factory( configurationManager, persistenceManager, factoryPid, dict );
     }
 
@@ -71,7 +72,7 @@ public class Factory extends Configurati
 
 
     Factory( ConfigurationManager configurationManager, PersistenceManager persistenceManager,
String factoryPid,
-        Dictionary props )
+        Dictionary<String, Object> props )
     {
         super( configurationManager, persistenceManager, factoryPid );
 
@@ -99,9 +100,9 @@ public class Factory extends Configurati
     }
 
 
-    Set getPIDs()
+    Set<String> getPIDs()
     {
-        return new HashSet( pids );
+        return new HashSet<String>( pids );
     }
 
 
@@ -120,7 +121,7 @@ public class Factory extends Configurati
     @Override
     void store() throws IOException
     {
-        Hashtable props = new Hashtable();
+        Dictionary<String, Object> props = new Hashtable<String, Object>();
 
         if ( !pids.isEmpty() )
         {

Modified: 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=1776381&r1=1776380&r2=1776381&view=diff
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/Log.java (original)
+++ felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/Log.java Thu Dec 29 07:29:00
2016
@@ -59,6 +59,7 @@ public class Log
     private static final int CM_LOG_LEVEL_DEFAULT = 2;
 
     // the ServiceTracker to emit log services (see log(int, String, Throwable))
+    @SuppressWarnings("rawtypes")
     private volatile ServiceTracker logTracker;
 
     // the maximum log level when no LogService is available
@@ -70,6 +71,7 @@ public class Log
      * Start the tracker for the logger and set the log level according to the configuration.
      * @param bundleContext The bundle context
      */
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     public void start( final BundleContext bundleContext)
     {
         // track the log service using a ServiceTracker
@@ -139,6 +141,7 @@ public class Log
      */
     public void log( final int level, final String format, final Object[] args )
     {
+        @SuppressWarnings("rawtypes")
         final ServiceTracker tracker = this.logTracker;
         final Object log = tracker == null ? null : tracker.getService();
         if ( log != null || isLogEnabled( level ) )
@@ -152,7 +155,7 @@ public class Log
                 {
                     if ( args[i] instanceof ServiceReference )
                     {
-                        args[i] = toString((ServiceReference)args[i]);
+                        args[i] = toString((ServiceReference<?>)args[i]);
                     }
                 }
                 if ( args[args.length - 1] instanceof Throwable )
@@ -175,6 +178,7 @@ public class Log
     public void log( final int level, final String message, final Throwable t )
     {
         // log using the LogService if available
+        @SuppressWarnings("rawtypes")
         final ServiceTracker tracker = this.logTracker;
         final Object log = tracker == null ? null : tracker.getService();
         if ( log != null )

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=1776381&r1=1776380&r2=1776381&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
Thu Dec 29 07:29:00 2016
@@ -214,10 +214,10 @@ public abstract class BaseTracker<S> ext
     }
 
 
-    protected final Dictionary getProperties( Dictionary<String, ?> rawProperties,
ServiceReference service,
+    protected final Dictionary<String, Object> getProperties( Dictionary<String,
?> rawProperties, ServiceReference<?> service,
         String configPid, String factoryPid )
     {
-        Dictionary props = new CaseInsensitiveDictionary( rawProperties );
+        Dictionary<String, Object> props = new CaseInsensitiveDictionary( rawProperties
);
         this.cm.callPlugins( props, service, configPid, factoryPid );
         return props;
     }



Mime
View raw message