FELIX-3680 move RefPair to its own class
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1397393 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/helper/BindMethod.java b/scr/src/main/java/org/apache/felix/scr/impl/helper/BindMethod.java
index e00c551..24420c2 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/helper/BindMethod.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/helper/BindMethod.java
@@ -24,6 +24,7 @@
import org.apache.felix.scr.impl.Activator;
import org.apache.felix.scr.impl.manager.AbstractComponentManager;
+import org.apache.felix.scr.impl.manager.RefPair;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.log.LogService;
@@ -553,7 +554,7 @@
return null;
}
- public AbstractComponentManager.RefPair getServiceObject( ServiceReference ref, BundleContext context )
+ public RefPair getServiceObject( ServiceReference ref, BundleContext context )
{
//??? this resolves which we need.... better way?
if ( methodExists() )
@@ -568,15 +569,15 @@
return null;
}
- return new AbstractComponentManager.RefPair(ref, service);
+ return new RefPair(ref, service);
}
}
- return new AbstractComponentManager.RefPair(ref, null);
+ return new RefPair(ref, null);
}
protected Object[] getParameters( Method method, Object rawParameter )
{
- AbstractComponentManager.RefPair refPair = ( AbstractComponentManager.RefPair ) rawParameter;
+ RefPair refPair = ( RefPair ) rawParameter;
if (m_paramStyle == SERVICE_REFERENCE )
{
return new Object[] {refPair.getRef()};
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java b/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
index 6503561..72615f0 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
@@ -909,33 +909,6 @@
abstract void invokeUnbindMethod( DependencyManager dependencyManager, ServiceReference oldRef );
- public static class RefPair
- {
- private final ServiceReference ref;
- private Object serviceObject;
-
- public RefPair( ServiceReference ref, Object serviceObject )
- {
- this.ref = ref;
- this.serviceObject = serviceObject;
- }
-
- public ServiceReference getRef()
- {
- return ref;
- }
-
- public Object getServiceObject()
- {
- return serviceObject;
- }
-
- public void setServiceObject( Object serviceObject )
- {
- this.serviceObject = serviceObject;
- }
- }
-
Map getDependencyMap()
{
return ( Map ) m_dependencies_map.get();
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java b/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
index 55301f4..964c78b 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
@@ -810,14 +810,14 @@
* if the service is bound or <code>null</code> if the service is not
* bound.
*/
- private AbstractComponentManager.RefPair getBoundService( ServiceReference serviceReference )
+ private RefPair getBoundService( ServiceReference serviceReference )
{
Map dependencyMap = m_componentManager.getDependencyMap();
if (dependencyMap == null)
{
return null;
}
- return ( AbstractComponentManager.RefPair ) (( Map ) dependencyMap.get( this )).get(serviceReference);
+ return ( RefPair ) (( Map ) dependencyMap.get( this )).get(serviceReference);
}
@@ -835,7 +835,7 @@
Object getService( ServiceReference serviceReference )
{
// check whether we already have the service and return that one
- AbstractComponentManager.RefPair refPair = getBoundService( serviceReference );
+ RefPair refPair = getBoundService( serviceReference );
if ( refPair != null && refPair.getServiceObject() != null )
{
return refPair.getServiceObject();
@@ -866,7 +866,7 @@
}
else
{
- refPair = new AbstractComponentManager.RefPair( serviceReference, serviceObject );
+ refPair = new RefPair( serviceReference, serviceObject );
((Map)m_componentManager.getDependencyMap().get( this )).put( serviceReference, refPair );
}
}
@@ -886,7 +886,7 @@
Map dependencyMap = m_componentManager.getDependencyMap();
if ( dependencyMap != null )
{
- AbstractComponentManager.RefPair refPair = ( AbstractComponentManager.RefPair ) ((Map ) dependencyMap.get( this )).get( serviceReference );
+ RefPair refPair = ( RefPair ) ((Map ) dependencyMap.get( this )).get( serviceReference );
if ( refPair != null && refPair.getServiceObject() != null )
{
BundleComponentActivator activator = m_componentManager.getActivator();
@@ -1004,7 +1004,7 @@
{
for ( int index = 0; index < refs.length; index++ )
{
- AbstractComponentManager.RefPair refPair = m_bindMethods.getBind().getServiceObject( refs[index], m_componentManager.getActivator().getBundleContext() );
+ RefPair refPair = m_bindMethods.getBind().getServiceObject( refs[index], m_componentManager.getActivator().getBundleContext() );
// success is if we have the minimal required number of services bound
if ( refPair != null )
{
@@ -1021,7 +1021,7 @@
ServiceReference ref = getFrameworkServiceReference();
if ( ref != null )
{
- AbstractComponentManager.RefPair refPair = m_bindMethods.getBind().getServiceObject( ref, m_componentManager.getActivator().getBundleContext() );
+ RefPair refPair = m_bindMethods.getBind().getServiceObject( ref, m_componentManager.getActivator().getBundleContext() );
// success is if we have the minimal required number of services bound
if ( refPair != null )
{
@@ -1077,7 +1077,7 @@
for ( Iterator i = parameters.entrySet().iterator(); i.hasNext(); )
{
Map.Entry entry = ( Map.Entry ) i.next();
- if ( invokeBindMethod( componentInstance, ( AbstractComponentManager.RefPair ) entry.getValue() ) )
+ if ( invokeBindMethod( componentInstance, ( RefPair ) entry.getValue() ) )
{
success = true;
}
@@ -1158,7 +1158,7 @@
}
Map deps = ( Map ) dependencyMap.get( this );
BundleContext bundleContext = m_componentManager.getActivator().getBundleContext();
- AbstractComponentManager.RefPair refPair = m_bindMethods.getBind().getServiceObject( ref, bundleContext );
+ RefPair refPair = m_bindMethods.getBind().getServiceObject( ref, bundleContext );
if ( refPair == null )
{
//reference deactivated while we are processing.
@@ -1196,7 +1196,7 @@
* be handed over to the bind method but the service cannot be
* retrieved using the service reference.
*/
- private boolean invokeBindMethod( Object componentInstance, AbstractComponentManager.RefPair refPair )
+ private boolean invokeBindMethod( Object componentInstance, RefPair refPair )
{
// The bind method is only invoked if the implementation object is not
// null. This is valid for both immediate and delayed components
@@ -1243,7 +1243,7 @@
// null. This is valid for both immediate and delayed components
if ( componentInstance != null )
{
- AbstractComponentManager.RefPair refPair = ( AbstractComponentManager.RefPair ) ((Map )m_componentManager.getDependencyMap().get( this )).get( ref );
+ RefPair refPair = ( RefPair ) ((Map )m_componentManager.getDependencyMap().get( this )).get( ref );
MethodResult methodResult = m_bindMethods.getUpdated().invoke( componentInstance, refPair, MethodResult.VOID );
if ( methodResult != null)
{
@@ -1277,7 +1277,7 @@
// null. This is valid for both immediate and delayed components
if ( componentInstance != null )
{
- AbstractComponentManager.RefPair refPair = ( AbstractComponentManager.RefPair ) ((Map )m_componentManager.getDependencyMap().get( this )).get( ref );
+ RefPair refPair = ( RefPair ) ((Map )m_componentManager.getDependencyMap().get( this )).get( ref );
MethodResult methodResult = m_bindMethods.getUnbind().invoke( componentInstance, refPair, MethodResult.VOID );
if ( methodResult != null )
{
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/manager/RefPair.java b/scr/src/main/java/org/apache/felix/scr/impl/manager/RefPair.java
new file mode 100644
index 0000000..cdd7d13
--- /dev/null
+++ b/scr/src/main/java/org/apache/felix/scr/impl/manager/RefPair.java
@@ -0,0 +1,53 @@
+/*
+ * 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.scr.impl.manager;
+
+import org.osgi.framework.ServiceReference;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class RefPair
+{
+ private final ServiceReference ref;
+ private Object serviceObject;
+
+ public RefPair( ServiceReference ref, Object serviceObject )
+ {
+ this.ref = ref;
+ this.serviceObject = serviceObject;
+ }
+
+ public ServiceReference getRef()
+ {
+ return ref;
+ }
+
+ public Object getServiceObject()
+ {
+ return serviceObject;
+ }
+
+ public void setServiceObject( Object serviceObject )
+ {
+ this.serviceObject = serviceObject;
+ }
+}
diff --git a/scr/src/test/java/org/apache/felix/scr/impl/helper/BindMethodTest.java b/scr/src/test/java/org/apache/felix/scr/impl/helper/BindMethodTest.java
index 3b05736..b06bc3a 100644
--- a/scr/src/test/java/org/apache/felix/scr/impl/helper/BindMethodTest.java
+++ b/scr/src/test/java/org/apache/felix/scr/impl/helper/BindMethodTest.java
@@ -23,6 +23,7 @@
import org.apache.felix.scr.impl.manager.AbstractComponentManager;
import org.apache.felix.scr.impl.manager.ImmediateComponentManager;
+import org.apache.felix.scr.impl.manager.RefPair;
import org.apache.felix.scr.impl.manager.components.FakeService;
import org.apache.felix.scr.impl.manager.components.T1;
import org.apache.felix.scr.impl.manager.components.T1a;
@@ -435,7 +436,7 @@
ImmediateComponentManager icm = new ImmediateComponentManager( null, null, metadata, new ComponentMethods() );
BindMethod bm = new BindMethod( icm, methodName, component.getClass(),
FakeService.class.getName(), isDS11, false );
- AbstractComponentManager.RefPair refPair = bm.getServiceObject( m_serviceReference, m_context );
+ RefPair refPair = bm.getServiceObject( m_serviceReference, m_context );
bm.invoke( component, refPair, null );
assertEquals( expectCallPerformed, component.callPerformed );
}