felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1463770 - in /felix/trunk/scr/src/main/java/org/apache/felix/scr/impl: helper/ReadOnlyDictionary.java manager/AbstractComponentManager.java manager/ComponentContextImpl.java manager/ImmediateComponentManager.java
Date Tue, 02 Apr 2013 21:50:47 GMT
Author: djencks
Date: Tue Apr  2 21:50:47 2013
New Revision: 1463770

URL: http://svn.apache.org/r1463770
Log:
FELIX-4011 genericize stuff, fix a bug in ReadOnlyDictionary

Modified:
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ReadOnlyDictionary.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentContextImpl.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ReadOnlyDictionary.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ReadOnlyDictionary.java?rev=1463770&r1=1463769&r2=1463770&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ReadOnlyDictionary.java
(original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ReadOnlyDictionary.java
Tue Apr  2 21:50:47 2013
@@ -35,28 +35,28 @@ import org.osgi.framework.ServiceReferen
  * a <code>Map</code> whose modificaiton methods (like {@link #put(Object, Object)},
  * {@link #remove(Object)}, etc.) have no effect.
  */
-public class ReadOnlyDictionary extends Dictionary implements Map
+public class ReadOnlyDictionary<S, T> extends Dictionary<S, T> implements Map<S,
T>
 {
 
-    private final Hashtable m_delegatee;
+    private final Hashtable<S, T> m_delegatee;
 
 
     /**
      * Creates a wrapper for the given delegatee dictionary providing read
      * only access to the data.
      */
-    public ReadOnlyDictionary( final Dictionary delegatee )
+    public ReadOnlyDictionary( final Dictionary<S, T> delegatee )
     {
         if ( delegatee instanceof Hashtable )
         {
-            this.m_delegatee = ( Hashtable ) delegatee;
+            this.m_delegatee = ( Hashtable<S, T> ) delegatee;
         }
         else
         {
-            this.m_delegatee = new Hashtable();
-            for ( Enumeration ke = delegatee.elements(); ke.hasMoreElements(); )
+            this.m_delegatee = new Hashtable<S, T>();
+            for ( Enumeration<S> ke = delegatee.keys(); ke.hasMoreElements(); )
             {
-                Object key = ke.nextElement();
+                S key = ke.nextElement();
                 this.m_delegatee.put( key, delegatee.get( key ) );
             }
         }
@@ -85,13 +85,12 @@ public class ReadOnlyDictionary extends 
 
     //---------- Dictionary API
 
-    public Enumeration elements()
+    public Enumeration<T> elements()
     {
         return m_delegatee.elements();
     }
 
-
-    public Object get( final Object key )
+    public T get( final Object key )
     {
         return m_delegatee.get( key );
     }
@@ -103,7 +102,7 @@ public class ReadOnlyDictionary extends 
     }
 
 
-    public Enumeration keys()
+    public Enumeration<S> keys()
     {
         return m_delegatee.keys();
     }
@@ -113,7 +112,7 @@ public class ReadOnlyDictionary extends 
      * This method has no effect and always returns <code>null</code> as this
      * instance is read-only and cannot modify and properties.
      */
-    public Object put( final Object key, final Object value )
+    public T put( final S key, final T value )
     {
         return null;
     }
@@ -123,7 +122,7 @@ public class ReadOnlyDictionary extends 
      * This method has no effect and always returns <code>null</code> as this
      * instance is read-only and cannot modify and properties.
      */
-    public Object remove( final Object key )
+    public T remove( final Object key )
     {
         return null;
     }

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java?rev=1463770&r1=1463769&r2=1463770&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
(original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
Tue Apr  2 21:50:47 2013
@@ -87,7 +87,7 @@ public abstract class AbstractComponentM
     private final ComponentMethods m_componentMethods;
 
     // The dependency managers that manage every dependency
-    private final List<DependencyManager> m_dependencyManagers;
+    private final List<DependencyManager<S, ?>> m_dependencyManagers;
 
     private volatile boolean m_dependencyManagersInitialized;
 
@@ -669,9 +669,9 @@ public abstract class AbstractComponentM
     }
 
 
-    final ServiceReference getServiceReference()
+    final ServiceReference<S> getServiceReference()
     {
-        ServiceRegistration reg = getServiceRegistration();
+        ServiceRegistration<S> reg = getServiceRegistration();
         if (reg != null)
         {
             return reg.getReference();
@@ -961,9 +961,9 @@ public abstract class AbstractComponentM
     }
 
 
-    private List<DependencyManager> loadDependencyManagers( ComponentMetadata metadata
)
+    private List<DependencyManager<S, ?>> loadDependencyManagers( ComponentMetadata
metadata )
     {
-        List<DependencyManager> depMgrList = new ArrayList<DependencyManager>(metadata.getDependencies().size());
+        List<DependencyManager<S, ?>> depMgrList = new ArrayList<DependencyManager<S,
?>>(metadata.getDependencies().size());
 
         // If this component has got dependencies, create dependency managers for each one
of them.
         if ( metadata.getDependencies().size() != 0 )
@@ -971,7 +971,7 @@ public abstract class AbstractComponentM
             int index = 0;
             for ( ReferenceMetadata currentdependency: metadata.getDependencies() )
             {
-                DependencyManager depmanager = new DependencyManager( this, currentdependency,
index++ );
+                DependencyManager<S, ?> depmanager = new DependencyManager( this, currentdependency,
index++ );
 
                 depMgrList.add( depmanager );
             }
@@ -1040,7 +1040,7 @@ public abstract class AbstractComponentM
      * Returns an iterator over the {@link DependencyManager} objects
      * representing the declared references in declaration order
      */
-    List<DependencyManager> getDependencyManagers()
+    List<DependencyManager<S, ?>> getDependencyManagers()
     {
         return m_dependencyManagers;
     }
@@ -1049,17 +1049,17 @@ public abstract class AbstractComponentM
      * Returns an iterator over the {@link DependencyManager} objects
      * representing the declared references in reversed declaration order
      */
-    List<DependencyManager> getReversedDependencyManagers()
+    List<DependencyManager<S, ?>> getReversedDependencyManagers()
     {
-        List list = new ArrayList( m_dependencyManagers );
+        List<DependencyManager<S, ?>> list = new ArrayList<DependencyManager<S,
?>>( m_dependencyManagers );
         Collections.reverse( list );
         return list;
     }
 
 
-    DependencyManager getDependencyManager(String name)
+    DependencyManager<S, ?> getDependencyManager(String name)
     {
-        for ( DependencyManager dm: getDependencyManagers() )
+        for ( DependencyManager<S, ?> dm: getDependencyManagers() )
         {
             if ( name.equals(dm.getName()) )
             {

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentContextImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentContextImpl.java?rev=1463770&r1=1463769&r2=1463770&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentContextImpl.java
(original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentContextImpl.java
Tue Apr  2 21:50:47 2013
@@ -34,21 +34,21 @@ import org.osgi.service.component.Compon
  * Implementation for the ComponentContext interface
  *
  */
-public class ComponentContextImpl implements ExtComponentContext {
+public class ComponentContextImpl<S> implements ExtComponentContext {
 
-    private final AbstractComponentManager m_componentManager;
+    private final AbstractComponentManager<S> m_componentManager;
     
     private final EdgeInfo[] edgeInfos;
     
     private volatile ComponentInstance m_componentInstance;
 
-    ComponentContextImpl( AbstractComponentManager componentManager )
+    ComponentContextImpl( AbstractComponentManager<S> componentManager )
     {
         m_componentManager = componentManager;
         edgeInfos = new EdgeInfo[componentManager.getComponentMetadata().getDependencies().size()];
     }
     
-    EdgeInfo getEdgeInfo(DependencyManager dm)
+    EdgeInfo getEdgeInfo(DependencyManager<S, ?> dm)
     {
         int index = dm.getIndex();
         if (edgeInfos[index] == null)
@@ -63,29 +63,29 @@ public class ComponentContextImpl implem
         Arrays.fill( edgeInfos, null );
     }
 
-    protected AbstractComponentManager getComponentManager()
+    protected AbstractComponentManager<S> getComponentManager()
     {
         return m_componentManager;
     }
 
-    public final Dictionary getProperties()
+    public final Dictionary<String, Object> getProperties()
     {
         // 112.12.3.5 The Dictionary is read-only and cannot be modified
-        Dictionary ctxProperties = m_componentManager.getProperties();
-        return new ReadOnlyDictionary( ctxProperties );
+        Dictionary<String, Object> ctxProperties = m_componentManager.getProperties();
+        return new ReadOnlyDictionary<String, Object>( ctxProperties );
     }
 
 
     public Object locateService( String name )
     {
-        DependencyManager dm = m_componentManager.getDependencyManager( name );
+        DependencyManager<S, ?> dm = m_componentManager.getDependencyManager( name
);
         return ( dm != null ) ? dm.getService() : null;
     }
 
 
     public Object locateService( String name, ServiceReference ref )
     {
-        DependencyManager dm = m_componentManager.getDependencyManager( name );
+        DependencyManager<S, ?> dm = m_componentManager.getDependencyManager( name
);
         return ( dm != null ) ? dm.getService( ref ) : null;
     }
 
@@ -127,7 +127,7 @@ public class ComponentContextImpl implem
     }
 
 
-    public ServiceReference getServiceReference()
+    public ServiceReference<S> getServiceReference()
     {
         return m_componentManager.getServiceReference();
     }

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java?rev=1463770&r1=1463769&r2=1463770&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java
(original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java
Tue Apr  2 21:50:47 2013
@@ -59,7 +59,7 @@ public class ImmediateComponentManager<S
     private final AtomicInteger m_useCount = new AtomicInteger( );
 
     // The context that will be passed to the implementationObject
-    private final ComponentContextImpl m_componentContext = new ComponentContextImpl(this);
+    private final ComponentContextImpl<S> m_componentContext = new ComponentContextImpl<S>(this);
 
     // the component holder responsible for managing this component
     private ComponentHolder m_componentHolder;



Mime
View raw message