You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by dj...@apache.org on 2014/06/15 03:09:27 UTC
svn commit: r1602632 [1/2] - in /felix/trunk/scr/src:
main/java/org/apache/felix/scr/impl/
main/java/org/apache/felix/scr/impl/config/
main/java/org/apache/felix/scr/impl/helper/
main/java/org/apache/felix/scr/impl/manager/ main/java/org/apache/felix/s...
Author: djencks
Date: Sun Jun 15 01:09:26 2014
New Revision: 1602632
URL: http://svn.apache.org/r1602632
Log:
FELIX-4401 Temporarily add runtime spec packages to source
Added:
felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ComponentManager.java (with props)
felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ReferenceManager.java (with props)
felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/runtime/
felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/runtime/ServiceComponentRuntimeImpl.java (with props)
felix/trunk/scr/src/main/java/org/osgi/
felix/trunk/scr/src/main/java/org/osgi/dto/
felix/trunk/scr/src/main/java/org/osgi/dto/DTO.java (with props)
felix/trunk/scr/src/main/java/org/osgi/dto/package-info.java (with props)
felix/trunk/scr/src/main/java/org/osgi/dto/packageinfo
felix/trunk/scr/src/main/java/org/osgi/framework/
felix/trunk/scr/src/main/java/org/osgi/framework/dto/
felix/trunk/scr/src/main/java/org/osgi/framework/dto/BundleDTO.java (with props)
felix/trunk/scr/src/main/java/org/osgi/framework/dto/FrameworkDTO.java (with props)
felix/trunk/scr/src/main/java/org/osgi/framework/dto/ServiceReferenceDTO.java (with props)
felix/trunk/scr/src/main/java/org/osgi/framework/dto/package-info.java (with props)
felix/trunk/scr/src/main/java/org/osgi/framework/dto/packageinfo
felix/trunk/scr/src/main/java/org/osgi/service/
felix/trunk/scr/src/main/java/org/osgi/service/component/
felix/trunk/scr/src/main/java/org/osgi/service/component/runtime/
felix/trunk/scr/src/main/java/org/osgi/service/component/runtime/ServiceComponentRuntime.java (with props)
felix/trunk/scr/src/main/java/org/osgi/service/component/runtime/dto/
felix/trunk/scr/src/main/java/org/osgi/service/component/runtime/dto/BoundReferenceDTO.java (with props)
felix/trunk/scr/src/main/java/org/osgi/service/component/runtime/dto/ComponentConfigurationDTO.java (with props)
felix/trunk/scr/src/main/java/org/osgi/service/component/runtime/dto/ComponentDescriptionDTO.java (with props)
felix/trunk/scr/src/main/java/org/osgi/service/component/runtime/dto/ReferenceDTO.java (with props)
felix/trunk/scr/src/main/java/org/osgi/service/component/runtime/dto/package-info.java (with props)
felix/trunk/scr/src/main/java/org/osgi/service/component/runtime/dto/packageinfo
felix/trunk/scr/src/main/java/org/osgi/service/component/runtime/package-info.java (with props)
felix/trunk/scr/src/main/java/org/osgi/service/component/runtime/packageinfo
Modified:
felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java
felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java
felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ComponentHolder.java
felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurableComponentHolder.java
felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurationSupport.java
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/ComponentFactoryImpl.java
felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ConfigurationComponentFactoryImpl.java
felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleComponentManager.java
felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java
felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/manager/AbstractComponentManagerTest.java
Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java?rev=1602632&r1=1602631&r2=1602632&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java Sun Jun 15 01:09:26 2014
@@ -27,12 +27,15 @@ import java.util.concurrent.CountDownLat
import java.util.concurrent.TimeUnit;
import org.apache.felix.scr.impl.config.ScrConfiguration;
+import org.apache.felix.scr.impl.runtime.ServiceComponentRuntimeImpl;
import org.apache.felix.utils.extender.AbstractExtender;
import org.apache.felix.utils.extender.Extension;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.ComponentConstants;
+import org.osgi.service.component.runtime.ServiceComponentRuntime;
import org.osgi.service.log.LogService;
import org.osgi.util.tracker.ServiceTracker;
@@ -73,6 +76,8 @@ public class Activator extends AbstractE
// thread acting upon configurations
private ComponentActorThread m_componentActor;
+
+ private ServiceRegistration<ServiceComponentRuntime> m_runtime_reg;
public Activator() {
m_configuration = new ScrConfiguration( this );
@@ -136,7 +141,8 @@ public class Activator extends AbstractE
// prepare component registry
m_componentBundles = new HashMap<Long, BundleComponentActivator>();
m_componentRegistry = new ComponentRegistry( m_context );
-
+ ServiceComponentRuntime runtime = new ServiceComponentRuntimeImpl(m_context, m_componentRegistry);
+ m_runtime_reg = m_context.registerService(ServiceComponentRuntime.class, runtime, null);
// log SCR startup
log( LogService.LOG_INFO, m_bundle, " Version = {0}",
@@ -150,9 +156,10 @@ public class Activator extends AbstractE
super.doStart();
+ //TODO register runtime. Possibly register obsolete stuff too.
// register the Gogo and old Shell commands
- ScrCommand scrCommand = ScrCommand.register(m_context, m_componentRegistry, m_configuration);
- m_configuration.setScrCommand( scrCommand );
+// ScrCommand scrCommand = ScrCommand.register(m_context, m_componentRegistry, m_configuration);
+// m_configuration.setScrCommand( scrCommand );
}
public void stop(BundleContext context) throws Exception
@@ -173,7 +180,12 @@ public class Activator extends AbstractE
// stop tracking
super.doStop();
- // dispose component registry
+ if (m_runtime_reg != null)
+ {
+ m_runtime_reg.unregister();
+ m_runtime_reg = null;
+ }
+ // dispose component registry
m_componentRegistry.dispose();
// terminate the actor thread
Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java?rev=1602632&r1=1602631&r2=1602632&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java Sun Jun 15 01:09:26 2014
@@ -60,7 +60,7 @@ import org.osgi.service.log.LogService;
* registers itself as the {@link ScrService} to support access to the
* registered components.
*/
-public class ComponentRegistry implements ScrService, ServiceListener
+public class ComponentRegistry implements ServiceListener
{
// the name of the ConfigurationAdmin service
@@ -84,7 +84,7 @@ public class ComponentRegistry implement
* @see #registerComponentHolder(String, ComponentHolder)
* @see #unregisterComponentHolder(String)
*/
- private final Map<ComponentRegistryKey, ComponentHolder> m_componentHoldersByName;
+ private final Map<ComponentRegistryKey, ComponentHolder<?>> m_componentHoldersByName;
/**
* The map of known components indexed by component configuration pid. The values are
@@ -103,7 +103,7 @@ public class ComponentRegistry implement
* @see #unregisterComponentHolder(String)
* @see ConfigurationSupport#configurationEvent(org.osgi.service.cm.ConfigurationEvent)
*/
- private final Map<String, Set<ComponentHolder>> m_componentHoldersByPid;
+ private final Map<String, Set<ComponentHolder<?>>> m_componentHoldersByPid;
/**
* Map of components by component ID. This map indexed by the component
@@ -137,8 +137,8 @@ public class ComponentRegistry implement
protected ComponentRegistry( BundleContext context )
{
m_bundleContext = context;
- m_componentHoldersByName = new HashMap<ComponentRegistryKey, ComponentHolder>();
- m_componentHoldersByPid = new HashMap<String, Set<ComponentHolder>>();
+ m_componentHoldersByName = new HashMap<ComponentRegistryKey, ComponentHolder<?>>();
+ m_componentHoldersByPid = new HashMap<String, Set<ComponentHolder<?>>>();
m_componentsById = new HashMap<Long, AbstractComponentManager<?>>();
// keep me informed on ConfigurationAdmin state changes
@@ -159,11 +159,11 @@ public class ComponentRegistry implement
}
// register as ScrService
- Dictionary props = new Hashtable();
- props.put( Constants.SERVICE_DESCRIPTION, "Declarative Services Management Agent" );
- props.put( Constants.SERVICE_VENDOR, "The Apache Software Foundation" );
- m_registration = context.registerService( new String[]
- { ScrService.class.getName(), }, this, props );
+// Dictionary<String, Object> props = new Hashtable<String, Object>();
+// props.put( Constants.SERVICE_DESCRIPTION, "Declarative Services Management Agent" );
+// props.put( Constants.SERVICE_VENDOR, "The Apache Software Foundation" );
+// m_registration = context.registerService( new String[]
+// { ScrService.class.getName(), }, this, props );
}
@@ -187,79 +187,79 @@ public class ComponentRegistry implement
//---------- ScrService interface
- public Component[] getComponents()
- {
- ComponentHolder[] holders = getComponentHolders();
- ArrayList<Component> list = new ArrayList<Component>();
- for ( ComponentHolder holder: holders )
- {
- if ( holder != null )
- {
- list.addAll(holder.getComponents());
- }
- }
-
- // nothing to return
- if ( list.isEmpty() )
- {
- return null;
- }
-
- return ( Component[] ) list.toArray( new Component[list.size()] );
- }
-
-
- public Component[] getComponents( Bundle bundle )
- {
- ComponentHolder[] holders = getComponentHolders();
- List<Component> list = new ArrayList<Component>();
- for ( ComponentHolder<?> holder: holders )
- {
- if ( holder != null )
- {
- BundleComponentActivator activator = holder.getActivator();
- if ( activator != null && activator.getBundleContext().getBundle() == bundle )
- {
- list.addAll(holder.getComponents());
- }
- }
- }
-
- // nothing to return
- if ( list.isEmpty() )
- {
- return null;
- }
-
- return list.toArray( new Component[list.size()] );
- }
-
-
- public Component getComponent( long componentId )
- {
- synchronized ( m_componentsById )
- {
- return m_componentsById.get( componentId );
- }
- }
-
-
- public Component[] getComponents( String componentName )
- {
- List<Component> list = new ArrayList<Component>();
- synchronized ( m_componentHoldersByName )
- {
- for ( ComponentHolder<?> c: m_componentHoldersByName.values() )
- {
- if ( c.getComponentMetadata().getName().equals( componentName ) )
- {
- list.addAll( c.getComponents() );
- }
- }
- }
-
- return ( list.isEmpty() ) ? null : list.toArray( new Component[list.size()] );
- }
+// public Component[] getComponents()
+// {
+// List<ComponentHolder<?>> holders = getComponentHolders();
+// ArrayList<Component> list = new ArrayList<Component>();
+// for ( ComponentHolder holder: holders )
+// {
+// if ( holder != null )
+// {
+// list.addAll(holder.getComponents());
+// }
+// }
+//
+// // nothing to return
+// if ( list.isEmpty() )
+// {
+// return null;
+// }
+//
+// return ( Component[] ) list.toArray( new Component[list.size()] );
+// }
+
+
+// public Component[] getComponents( Bundle bundle )
+// {
+// List<ComponentHolder<?>> holders = getComponentHolders();
+// List<Component> list = new ArrayList<Component>();
+// for ( ComponentHolder<?> holder: holders )
+// {
+// if ( holder != null )
+// {
+// BundleComponentActivator activator = holder.getActivator();
+// if ( activator != null && activator.getBundleContext().getBundle() == bundle )
+// {
+// list.addAll(holder.getComponents());
+// }
+// }
+// }
+//
+// // nothing to return
+// if ( list.isEmpty() )
+// {
+// return null;
+// }
+//
+// return list.toArray( new Component[list.size()] );
+// }
+//
+//
+// public Component getComponent( long componentId )
+// {
+// synchronized ( m_componentsById )
+// {
+// return m_componentsById.get( componentId );
+// }
+// }
+
+
+// public Component[] getComponents( String componentName )
+// {
+// List<Component> list = new ArrayList<Component>();
+// synchronized ( m_componentHoldersByName )
+// {
+// for ( ComponentHolder<?> c: m_componentHoldersByName.values() )
+// {
+// if ( c.getComponentMetadata().getName().equals( componentName ) )
+// {
+// list.addAll( c.getComponents() );
+// }
+// }
+// }
+//
+// return ( list.isEmpty() ) ? null : list.toArray( new Component[list.size()] );
+// }
//---------- ComponentManager registration by component Id
@@ -406,10 +406,10 @@ public class ComponentRegistry implement
// Since several components may refer to the same configuration pid, we have to
// store the component holder in a Set, in order to be able to lookup every
// components from a given pid.
- Set<ComponentHolder> set = m_componentHoldersByPid.get( configurationPid );
+ Set<ComponentHolder<?>> set = m_componentHoldersByPid.get( configurationPid );
if ( set == null )
{
- set = new HashSet<ComponentHolder>();
+ set = new HashSet<ComponentHolder<?>>();
m_componentHoldersByPid.put( configurationPid, set );
}
set.add( componentHolder );
@@ -441,13 +441,13 @@ public class ComponentRegistry implement
* @param pid the pid candidate
* @return the set of ComponentHolders matching the singleton pid supplied
*/
- public final Collection<ComponentHolder> getComponentHoldersByPid(TargetedPID targetedPid)
+ public final Collection<ComponentHolder<?>> getComponentHoldersByPid(TargetedPID targetedPid)
{
String pid = targetedPid.getServicePid();
- Set<ComponentHolder> componentHoldersUsingPid = new HashSet<ComponentHolder>();
+ Set<ComponentHolder<?>> componentHoldersUsingPid = new HashSet<ComponentHolder<?>>();
synchronized (m_componentHoldersByPid)
{
- Set<ComponentHolder> set = m_componentHoldersByPid.get(pid);
+ Set<ComponentHolder<?>> set = m_componentHoldersByPid.get(pid);
// only return the entry if non-null and not a reservation
if (set != null)
{
@@ -469,12 +469,36 @@ public class ComponentRegistry implement
* name reservations or {@link ComponentHolder} instances for actual
* holders of components.
*/
- private ComponentHolder[] getComponentHolders()
+ public final List<ComponentHolder<?>> getComponentHolders()
{
+ List<ComponentHolder<?>> all = new ArrayList<ComponentHolder<?>>();
synchronized ( m_componentHoldersByName )
{
- return m_componentHoldersByName.values().toArray( new ComponentHolder[ m_componentHoldersByName.size() ]);
+ all.addAll(m_componentHoldersByName.values());
+ }
+ return all;
+ }
+
+ public final List<ComponentHolder<?>> getComponentHolders(Bundle...bundles)
+ {
+ List<ComponentHolder<?>> all =getComponentHolders();
+ List<ComponentHolder<?>> holders = new ArrayList<ComponentHolder<?>>();
+ for ( ComponentHolder<?> holder: all)
+ {
+ BundleComponentActivator activator = holder.getActivator();
+ if (activator != null)
+ {
+ Bundle holderBundle = activator.getBundleContext().getBundle();
+ for (Bundle b: bundles)
+ {
+ if (b == holderBundle)
+ {
+ holders.add(holder);
+ }
+ }
+ }
}
+ return holders;
}
@@ -498,7 +522,7 @@ public class ComponentRegistry implement
*/
final void unregisterComponentHolder( final ComponentRegistryKey key )
{
- ComponentHolder component;
+ ComponentHolder<?> component;
synchronized ( m_componentHoldersByName )
{
component = m_componentHoldersByName.remove( key );
@@ -513,7 +537,7 @@ public class ComponentRegistry implement
List<String> configurationPids = component.getComponentMetadata().getConfigurationPid();
for ( String configurationPid: configurationPids )
{
- Set<ComponentHolder> componentsForPid = m_componentHoldersByPid.get( configurationPid );
+ Set<ComponentHolder<?>> componentsForPid = m_componentHoldersByPid.get( configurationPid );
if ( componentsForPid != null )
{
componentsForPid.remove( component );
Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ComponentHolder.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ComponentHolder.java?rev=1602632&r1=1602631&r2=1602632&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ComponentHolder.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ComponentHolder.java Sun Jun 15 01:09:26 2014
@@ -61,14 +61,15 @@ public interface ComponentHolder<S>
* Configuration Admin service.
*
* @param pid The PID of the deleted configuration
+ * @param factoryPid TODO
*/
- void configurationDeleted( String pid );
+ void configurationDeleted( TargetedPID pid, TargetedPID factoryPid );
/**
* Configure a component with configuration from the given PID.
* @param targetedPid Targeted PID for the configuration
- * @param factoryTargetedPid TODO
+ * @param factoryTargetedPid the (targeted) factory pid or null for a singleton pid
* @param props the property dictionary from the configuration.
* @param changeCount change count of the configuration, or R4 imitation.
*
@@ -79,10 +80,11 @@ public interface ComponentHolder<S>
/**
* Change count (or fake R4 imitation)
- * @param pid PID of the component we are interested in.
+ * @param pid a PID for the component we are interested in.
+ * @param targetedPid For a singleton pid, same as "pid"; for a factory pid, the factory pid.
* @return the last change count from a configurationUpdated call for the given pid.
*/
- long getChangeCount( TargetedPID pid );
+ long getChangeCount( TargetedPID pid, TargetedPID targetedPid );
/**
* Returns the targeted PID used to configure this component
@@ -95,7 +97,7 @@ public interface ComponentHolder<S>
/**
* Returns all <code>Component</code> instances held by this holder.
*/
- List<? extends Component> getComponents();
+ List<? extends ComponentManager<?>> getComponents();
/**
* Enables all components of this holder and if satisifed activates
@@ -114,6 +116,12 @@ public interface ComponentHolder<S>
* asynchronously or not.
*/
void disableComponents( boolean async );
+
+ /**
+ * whether the component is currently enabled
+ * @return whether the component is enabled
+ */
+ boolean isEnabled();
/**
Added: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ComponentManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ComponentManager.java?rev=1602632&view=auto
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ComponentManager.java (added)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ComponentManager.java Sun Jun 15 01:09:26 2014
@@ -0,0 +1,27 @@
+package org.apache.felix.scr.impl.config;
+
+import java.util.List;
+import java.util.Map;
+
+import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
+
+
+public interface ComponentManager<S> {
+
+ int STATE_SATISFIED = ComponentConfigurationDTO.SATISFIED;
+ int STATE_UNSATISFIED = ComponentConfigurationDTO.UNSATISFIED;
+ int STATE_ACTIVE = ComponentConfigurationDTO.ACTIVE;
+ int STATE_FACTORY = 8;
+ int STATE_FACTORY_INSTANCE = 16;
+ int STATE_DISPOSED = 32;
+ int STATE_DISABLED = 64; //TODO????
+
+ Map<String, Object> getProperties();
+
+ long getId();
+
+ int getState();
+
+ List<? extends ReferenceManager<S, ?>> getReferenceManagers();
+
+}
\ No newline at end of file
Propchange: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ComponentManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ComponentManager.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ComponentManager.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurableComponentHolder.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurableComponentHolder.java?rev=1602632&r1=1602631&r2=1602632&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurableComponentHolder.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurableComponentHolder.java Sun Jun 15 01:09:26 2014
@@ -74,9 +74,9 @@ public class ConfigurableComponentHolder
/** the targeted pids corresponding to the pids specified in the config metadata, except possibly for the single
* factory pid
*/
- private final List<TargetedPID> m_targetedPids;
+ private final TargetedPID[] m_targetedPids;
- private final List<Long> m_changeCount;
+ private final Long[] m_changeCount;
private final Map<String, Long> m_factoryChangeCount = new HashMap<String, Long>();
@@ -89,7 +89,7 @@ public class ConfigurableComponentHolder
/**
* the non-factory configurations shared between all instances.
*/
- private final List<Dictionary<String, Object>> m_configurations;
+ private final Dictionary<String, Object>[] m_configurations;
/**
* the factory configurations indexed by pid (which cannot be a TargetedPID since it's generated by CA). We have to track these since
@@ -143,15 +143,9 @@ public class ConfigurableComponentHolder
this.m_activator = activator;
this.m_componentMetadata = metadata;
int pidCount = metadata.getConfigurationPid().size();
- this.m_targetedPids = new ArrayList<TargetedPID>(pidCount);
- this.m_configurations = new ArrayList<Dictionary<String, Object>>(pidCount);
- this.m_changeCount = new ArrayList<Long>(pidCount);
- for (int i = 0; i < pidCount; i++)
- {
- m_targetedPids.add(null);
- m_configurations.add(null);
- m_changeCount.add(null);
- }
+ this.m_targetedPids = new TargetedPID[pidCount];
+ this.m_configurations = new Dictionary[pidCount];
+ this.m_changeCount = new Long[pidCount];
this.m_components = new HashMap<String, SingleComponentManager<S>>();
this.m_componentMethods = new ComponentMethods();
this.m_enabled = false;
@@ -182,6 +176,10 @@ public class ConfigurableComponentHolder
manager = new SingleComponentManager<S>( m_activator, this, m_componentMetadata, m_componentMethods );
}
+ if ( m_enabled )
+ {
+ manager.enable( false );
+ }
return manager;
}
@@ -218,75 +216,67 @@ public class ConfigurableComponentHolder
* simply disposed off and removed from the internal map.</li>
* </ul>
*/
- public void configurationDeleted( final String pid )
+ public void configurationDeleted( final TargetedPID pid, TargetedPID factoryPid )
{
log( LogService.LOG_DEBUG, "ImmediateComponentHolder configuration deleted for pid {0}",
new Object[] {pid}, null);
// component to deconfigure or dispose of
- final SingleComponentManager icm;
+ final SingleComponentManager<S> icm;
boolean deconfigure = false;
synchronized ( m_components )
{
- // FELIX-2231: nothing to do any more, all components have been disposed off
- if (m_singleComponent == null)
- {
- return;
- }
-
- if ( pid.equals( getComponentMetadata().getConfigurationPid() ) )
- {
- // singleton configuration has pid equal to component name
- icm = m_singleComponent;
- deconfigure = true;
- }
- else
- {
- // remove the component configured with the deleted configuration
- icm = m_components.remove( pid );
- if ( icm == null )
- {
- // we already removed the component with the deleted configuration
- return;
- }
-
- // special casing if the single component is deconfigured
- if ( m_singleComponent == icm )
- {
-
- // if the single component is the last remaining, deconfig
- if ( m_components.isEmpty() )
- {
-
- // if the single component is the last remaining
- // deconfigure it
- deconfigure = true;
-
- }
- else
- {
-
- // replace the single component field with another
- // entry from the map
- m_singleComponent = m_components.values().iterator().next();
-
- }
- }
- }
+// // FELIX-2231: nothing to do any more, all components have been disposed off
+// if (m_singleComponent == null)
+// {
+// return;
+// }
+ if (factoryPid != null) {
+ checkFactoryPidIndex(factoryPid);
+ String servicePid = pid.getServicePid();
+ icm = m_components.remove(servicePid);
+ if (icm == null)
+ {
+ return;
+ }
+ m_factoryTargetedPids.remove(servicePid);
+ m_factoryChangeCount.remove(servicePid);
+ m_factoryConfigurations.remove(servicePid);
+ deconfigure = m_componentMetadata.isConfigurationOptional() && m_components.isEmpty();
+ if ( deconfigure )
+ {
+ m_singleComponent = icm;
+ }
+ if ( m_components.isEmpty() )
+ {
+ m_factoryPidIndex = null;
+ }
+ }
+ else
+ {
+ //singleton pid
+ int index = getSingletonPidIndex(pid);
+ m_targetedPids[index] = null;
+ m_changeCount[index] = null;
+ m_configurations[index] = null;
+ icm = m_singleComponent;
+ deconfigure = m_componentMetadata.isConfigurationOptional();
+ if ( !deconfigure )
+ {
+ m_singleComponent = null;
+ }
+ }
}
- // icm may be null if the last configuration deleted was the
- // single component's configuration. Otherwise the component
- // is not the "last" and has to be disposed off
- if ( deconfigure )
+ if ( icm != null )
{
- icm.reconfigure( null );
- }
- else
- {
- icm.dispose( ComponentConstants.DEACTIVATION_REASON_CONFIGURATION_DELETED );
- }
+ if ( deconfigure ) {
+ icm.reconfigure(null);
+ } else {
+ icm.dispose(ComponentConstants.DEACTIVATION_REASON_CONFIGURATION_DELETED);
+ }
+ }
}
@@ -310,7 +300,7 @@ public class ConfigurableComponentHolder
new Object[] {pid, props}, null);
// component to update or create
- final SingleComponentManager scm;
+ final SingleComponentManager<S> scm;
final String message;
Object[] notEnabledArguments = null;
boolean created = false;
@@ -320,34 +310,7 @@ public class ConfigurableComponentHolder
synchronized (m_components) {
//Find or create the component manager, or return if not satisfied.
if (factoryPid != null) {
- int index = m_componentMetadata.getPidIndex(factoryPid);
- if (index == -1) {
- log(LogService.LOG_ERROR,
- "Unrecognized factory pid {0], expected one of {1}",
- new Object[] { factoryPid,
- m_componentMetadata.getConfigurationPid() },
- null);
- throw new IllegalArgumentException(
- "Unrecognized factory pid " + factoryPid);
- }
- if (m_configurations.get(index) != null) {
- log(LogService.LOG_ERROR,
- "factory pid {0], but this pids already supplied as a singleton: {1}",
- new Object[] { factoryPid, m_targetedPids }, null);
- throw new IllegalStateException(
- "Factory pid supplied after all non-factory configurations supplied "
- + factoryPid);
- }
- if (m_factoryPidIndex == null) {
- m_factoryPidIndex = index;
- } else if (index != m_factoryPidIndex) {
- log(LogService.LOG_ERROR,
- "factory pid {0] supplied for index {1}, but a factory pid previously supplied at index {2}",
- new Object[] { factoryPid, index, m_factoryPidIndex },
- null);
- throw new IllegalStateException(
- "Factory pid supplied at wrong index " + factoryPid);
- }
+ checkFactoryPidIndex(factoryPid);
m_factoryConfigurations.put(pid.getServicePid(), props);
m_factoryTargetedPids.put(pid.getServicePid(), factoryPid);
m_factoryChangeCount.put(pid.getServicePid(), changeCount);
@@ -369,27 +332,10 @@ public class ConfigurableComponentHolder
} else {
//singleton pid
- int index = m_componentMetadata.getPidIndex(pid);
- if (index == -1) {
- log(LogService.LOG_ERROR,
- "Unrecognized pid {0], expected one of {1}",
- new Object[] { pid,
- m_componentMetadata.getConfigurationPid() },
- null);
- throw new IllegalArgumentException("Unrecognized pid "
- + pid);
- }
- if (m_factoryPidIndex != null && index == m_factoryPidIndex) {
- log(LogService.LOG_ERROR,
- "singleton pid {0] supplied, but matches an existing factory pid at index: {1}",
- new Object[] { pid, m_factoryPidIndex }, null);
- throw new IllegalStateException(
- "Singleton pid supplied matching a previous factory pid "
- + pid);
- }
- m_targetedPids.set(index, pid);
- m_changeCount.set(index, changeCount);
- m_configurations.set(index, props);
+ int index = getSingletonPidIndex(pid);
+ m_targetedPids[index] = pid;
+ m_changeCount[index] = changeCount;
+ m_configurations[index] = props;
if (isSatisfied()) {
if (m_singleComponent != null) {
scm = m_singleComponent;
@@ -403,17 +349,16 @@ public class ConfigurableComponentHolder
}
}
- properties = new HashMap<String, Object>();
- copyTo(properties, m_componentMetadata.getProperties());
- for (int i = 0; i < m_configurations.size(); i++)
+ properties = new HashMap<String, Object>(m_componentMetadata.getProperties());
+ for (int i = 0; i < m_configurations.length; i++)
{
if ( m_factoryPidIndex != null && i == m_factoryPidIndex)
{
copyTo(properties, props);
}
- else if ( m_configurations.get(i) != null )
+ else if ( m_configurations[i] != null )
{
- copyTo(properties, m_configurations.get(i));
+ copyTo(properties, m_configurations[i]);
}
}
@@ -502,6 +447,60 @@ public class ConfigurableComponentHolder
return created;
}
+ private int getSingletonPidIndex(TargetedPID pid) {
+ int index = m_componentMetadata.getPidIndex(pid);
+ if (index == -1) {
+ log(LogService.LOG_ERROR,
+ "Unrecognized pid {0], expected one of {1}",
+ new Object[] { pid,
+ m_componentMetadata.getConfigurationPid() },
+ null);
+ throw new IllegalArgumentException("Unrecognized pid "
+ + pid);
+ }
+ if (m_factoryPidIndex != null && index == m_factoryPidIndex) {
+ log(LogService.LOG_ERROR,
+ "singleton pid {0] supplied, but matches an existing factory pid at index: {1}",
+ new Object[] { pid, m_factoryPidIndex }, null);
+ throw new IllegalStateException(
+ "Singleton pid supplied matching a previous factory pid "
+ + pid);
+ }
+ return index;
+ }
+
+ //TODO update error messages so they make sense for deleting config too.
+ private void checkFactoryPidIndex(TargetedPID factoryPid) {
+ int index = m_componentMetadata.getPidIndex(factoryPid);
+ if (index == -1) {
+ log(LogService.LOG_ERROR,
+ "Unrecognized factory pid {0], expected one of {1}",
+ new Object[] { factoryPid,
+ m_componentMetadata.getConfigurationPid() },
+ null);
+ throw new IllegalArgumentException(
+ "Unrecognized factory pid " + factoryPid);
+ }
+ if (m_configurations[index] != null) {
+ log(LogService.LOG_ERROR,
+ "factory pid {0], but this pids already supplied as a singleton: {1}",
+ new Object[] { factoryPid, m_targetedPids }, null);
+ throw new IllegalStateException(
+ "Factory pid supplied after all non-factory configurations supplied "
+ + factoryPid);
+ }
+ if (m_factoryPidIndex == null) {
+ m_factoryPidIndex = index;
+ } else if (index != m_factoryPidIndex) {
+ log(LogService.LOG_ERROR,
+ "factory pid {0] supplied for index {1}, but a factory pid previously supplied at index {2}",
+ new Object[] { factoryPid, index, m_factoryPidIndex },
+ null);
+ throw new IllegalStateException(
+ "Factory pid supplied at wrong index " + factoryPid);
+ }
+ }
+
protected static void copyTo( Map<String, Object> target, Dictionary<String, ?> source )
{
@@ -522,10 +521,9 @@ public class ConfigurableComponentHolder
{
return true;
}
- boolean satisfied = true;
for ( int i = 0; i < m_componentMetadata.getConfigurationPid().size(); i++)
{
- if ( m_configurations.get(i) != null)
+ if ( m_configurations[i] != null)
{
continue;
}
@@ -540,11 +538,12 @@ public class ConfigurableComponentHolder
/**
* @param pid the Targeted PID we need the change count for
+ * @param targetedPid the targeted factory pid for a factory configuration or the pid for a singleton configuration
* @return pid for this service pid.
*/
- public long getChangeCount( TargetedPID pid)
+ public long getChangeCount( TargetedPID pid, TargetedPID targetedPid)
{
- int index = m_componentMetadata.getPidIndex(pid);
+ int index = m_componentMetadata.getPidIndex(targetedPid);
Long result;
if ( index == -1 )
{
@@ -556,13 +555,13 @@ public class ConfigurableComponentHolder
}
else
{
- result = m_changeCount.get(index);
+ result = m_changeCount[index];
}
return result == null? -1: result;
}
- public List<? extends Component> getComponents()
+ public List<? extends ComponentManager<?>> getComponents()
{
synchronized ( m_components )
{
@@ -571,6 +570,10 @@ public class ConfigurableComponentHolder
}
+ public boolean isEnabled() {
+ return m_enabled;
+ }
+
public void enableComponents( final boolean async )
{
List<SingleComponentManager<S>> cms;
@@ -619,21 +622,21 @@ public class ConfigurableComponentHolder
{
cms = getComponentManagers( true );
}
- for ( SingleComponentManager cm : cms )
+ for ( SingleComponentManager<S> cm : cms )
{
cm.dispose( reason );
}
}
- public void disposed( SingleComponentManager component )
+ public void disposed( SingleComponentManager<S> component )
{
// ensure the component is removed from the components map
synchronized ( m_components )
{
if ( !m_components.isEmpty() )
{
- for ( Iterator vi = m_components.values().iterator(); vi.hasNext(); )
+ for ( Iterator<SingleComponentManager<S>> vi = m_components.values().iterator(); vi.hasNext(); )
{
if ( component == vi.next() )
{
@@ -643,20 +646,9 @@ public class ConfigurableComponentHolder
}
}
- // if the component is the single component, we have to replace it
- // by another entry in the map
if ( component == m_singleComponent )
{
- if ( m_components.isEmpty() )
- {
- // now what ??
- // is it correct to create a new manager ???
- m_singleComponent = createComponentManager();
- }
- else
- {
- m_singleComponent = m_components.values().iterator().next();
- }
+ m_singleComponent = null;
}
}
}
@@ -681,7 +673,7 @@ public class ConfigurableComponentHolder
return false;
}
- ConfigurableComponentHolder other = (ConfigurableComponentHolder) object;
+ ConfigurableComponentHolder<S> other = (ConfigurableComponentHolder<S>) object;
return m_activator == other.m_activator
&& getName().equals(other.getName());
}
@@ -774,7 +766,7 @@ public class ConfigurableComponentHolder
int index = m_componentMetadata.getPidIndex(pid);
if (index != -1)
{
- return m_targetedPids.get(index);
+ return m_targetedPids[index];
}
return null;
}
Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurationSupport.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurationSupport.java?rev=1602632&r1=1602631&r2=1602632&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurationSupport.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurationSupport.java Sun Jun 15 01:09:26 2014
@@ -19,19 +19,13 @@
package org.apache.felix.scr.impl.config;
import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.text.MessageFormat;
import java.util.Collection;
import java.util.Collections;
import java.util.Dictionary;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Hashtable;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import org.apache.felix.scr.impl.Activator;
import org.apache.felix.scr.impl.BundleComponentActivator;
@@ -58,7 +52,7 @@ public class ConfigurationSupport implem
ChangeCount cc = null;
try
{
- Configuration.class.getMethod( "getChangeCount", null );
+ Configuration.class.getMethod( "getChangeCount", (Class<?>[]) null );
cc = new R5ChangeCount();
}
catch ( SecurityException e )
@@ -78,14 +72,14 @@ public class ConfigurationSupport implem
private final ComponentRegistry m_registry;
// the service m_registration of the ConfigurationListener service
- private ServiceRegistration m_registration;
+ private ServiceRegistration<?> m_registration;
public ConfigurationSupport(final BundleContext bundleContext, final ComponentRegistry registry)
{
this.m_registry = registry;
// register as listener for configurations
- Dictionary props = new Hashtable();
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put(Constants.SERVICE_DESCRIPTION, "Declarative Services Configuration Support Listener");
props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
this.m_registration = bundleContext.registerService(new String[]
@@ -103,7 +97,7 @@ public class ConfigurationSupport implem
// ---------- BaseConfigurationSupport overwrites
- public boolean configureComponentHolder(final ComponentHolder holder)
+ public boolean configureComponentHolder(final ComponentHolder<?> holder)
{
// 112.7 configure unless configuration not required
@@ -246,7 +240,7 @@ public class ConfigurationSupport implem
// iterate over all components which must be configured with this pid
// (since DS 1.2, components may specify a specific configuration PID (112.4.4 configuration-pid)
- Collection<ComponentHolder> holders;
+ Collection<ComponentHolder<?>> holders;
if (factoryPid == null)
{
@@ -261,7 +255,7 @@ public class ConfigurationSupport implem
new Object[] {getEventType(event), pid, holders},
null);
- for ( ComponentHolder componentHolder: holders )
+ for ( ComponentHolder<?> componentHolder: holders )
{
if (!componentHolder.getComponentMetadata().isConfigurationIgnored())
{
@@ -269,7 +263,7 @@ public class ConfigurationSupport implem
case ConfigurationEvent.CM_DELETED:
if ( factoryPid != null || !configureComponentHolder( componentHolder ) )
{
- componentHolder.configurationDeleted( pid.getServicePid() );
+ componentHolder.configurationDeleted( pid, factoryPid );
}
break;
@@ -291,13 +285,13 @@ public class ConfigurationSupport implem
TargetedPID oldTargetedPID = componentHolder.getConfigurationTargetedPID(pid, factoryPid);
if ( factoryPid != null || targetedPid.equals(oldTargetedPID) || targetedPid.bindsStronger( oldTargetedPID ))
{
- final ConfigurationInfo configInfo = getConfigurationInfo( pid, componentHolder, bundleContext );
+ final ConfigurationInfo configInfo = getConfigurationInfo( pid, targetedPid, componentHolder, bundleContext );
if ( checkBundleLocation( configInfo.getBundleLocation(), bundleContext.getBundle() ) )
{
//If this is replacing a weaker targetedPID delete the old one.
if ( factoryPid == null && !targetedPid.equals(oldTargetedPID) && oldTargetedPID != null)
{
- componentHolder.configurationDeleted( pid.getServicePid() );
+ componentHolder.configurationDeleted( pid, factoryPid );
}
componentHolder.configurationUpdated( pid, factoryPid, configInfo.getProps(), configInfo.getChangeCount() );
}
@@ -326,7 +320,7 @@ public class ConfigurationSupport implem
{
//this sets the location to this component's bundle if not already set. OK here
//since it used to be set to this bundle, ok to reset it
- final ConfigurationInfo configInfo = getConfigurationInfo( pid, componentHolder, bundleContext );
+ final ConfigurationInfo configInfo = getConfigurationInfo( pid, targetedPid, componentHolder, bundleContext );
Activator.log(LogService.LOG_DEBUG, null, "LocationChanged event, same targetedPID {0}, location now {1}",
new Object[] {targetedPid, configInfo.getBundleLocation()},
null);
@@ -339,7 +333,7 @@ public class ConfigurationSupport implem
if (!checkBundleLocation( configInfo.getBundleLocation(), bundleContext.getBundle() ))
{
//no, delete it
- componentHolder.configurationDeleted( pid.getServicePid() );
+ componentHolder.configurationDeleted( pid, factoryPid );
//maybe there's another match
configureComponentHolder(componentHolder);
@@ -352,7 +346,7 @@ public class ConfigurationSupport implem
{
//this sets the location to this component's bundle if not already set. OK here
//because if it is set to this bundle we will use it.
- final ConfigurationInfo configInfo = getConfigurationInfo( pid, componentHolder, bundleContext );
+ final ConfigurationInfo configInfo = getConfigurationInfo( pid, targetedPid, componentHolder, bundleContext );
Activator.log(LogService.LOG_DEBUG, null, "LocationChanged event, better targetedPID {0} compared to {1}, location now {2}",
new Object[] {targetedPid, oldTargetedPID, configInfo.getBundleLocation()},
null);
@@ -367,7 +361,7 @@ public class ConfigurationSupport implem
if ( oldTargetedPID != null )
{
//this is a better match, delete old before setting new
- componentHolder.configurationDeleted( pid.getServicePid() );
+ componentHolder.configurationDeleted( pid, factoryPid );
}
componentHolder.configurationUpdated( pid, factoryPid,
configInfo.getProps(), configInfo.getChangeCount() );
@@ -448,12 +442,13 @@ public class ConfigurationSupport implem
* are ungot. Extracting the info we need into "configInfo" solves this problem.
*
* @param pid TargetedPID for the desired configuration
+ * @param targetedPid the targeted factory pid for a factory configuration or the pid for a singleton configuration
* @param componentHolder ComponentHolder that holds the old change count (for r4 fake change counting)
* @param bundleContext BundleContext to get the CA from
* @return ConfigurationInfo object containing the info we need from the configuration.
*/
- private ConfigurationInfo getConfigurationInfo(final TargetedPID pid, ComponentHolder componentHolder,
- final BundleContext bundleContext)
+ private ConfigurationInfo getConfigurationInfo(final TargetedPID pid, TargetedPID targetedPid,
+ ComponentHolder<?> componentHolder, final BundleContext bundleContext)
{
final ServiceReference caRef = bundleContext
.getServiceReference(ComponentRegistry.CONFIGURATION_ADMIN);
@@ -471,7 +466,7 @@ public class ConfigurationSupport implem
final ConfigurationAdmin ca = ( ConfigurationAdmin ) cao;
final Configuration config = getConfiguration( ca, pid.getRawPid() );
return new ConfigurationInfo(config.getProperties(), config.getBundleLocation(),
- changeCounter.getChangeCount( config, true, componentHolder.getChangeCount( pid ) ) );
+ changeCounter.getChangeCount( config, true, componentHolder.getChangeCount( pid, targetedPid ) ) );
}
else
{
Added: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ReferenceManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ReferenceManager.java?rev=1602632&view=auto
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ReferenceManager.java (added)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ReferenceManager.java Sun Jun 15 01:09:26 2014
@@ -0,0 +1,30 @@
+package org.apache.felix.scr.impl.config;
+
+import java.util.List;
+
+import org.osgi.framework.ServiceReference;
+
+public interface ReferenceManager<S, T> {
+
+ /**
+ * Returns an array of <code>ServiceReference</code> instances of all
+ * services this instance is bound to or <code>null</code> if no services
+ * are actually bound.
+ */
+ List<ServiceReference<?>> getServiceReferences();
+
+ /**
+ * Returns the name of the service reference.
+ */
+ String getName();
+
+ /**
+ * Returns the target filter of this dependency as a string or
+ * <code>null</code> if this dependency has no target filter set.
+ *
+ * @return The target filter of this dependency or <code>null</code> if
+ * none is set.
+ */
+ String getTarget();
+
+}
\ No newline at end of file
Propchange: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ReferenceManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ReferenceManager.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ReferenceManager.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
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=1602632&r1=1602631&r2=1602632&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 Sun Jun 15 01:09:26 2014
@@ -45,7 +45,7 @@ public class ReadOnlyDictionary<S, T> ex
* Creates a wrapper for the given delegate dictionary providing read
* only access to the data.
*/
- public ReadOnlyDictionary( final Dictionary<S, T> delegate )
+ public ReadOnlyDictionary( final Map<S, T> delegate )
{
if ( delegate instanceof Hashtable )
{
@@ -54,10 +54,9 @@ public class ReadOnlyDictionary<S, T> ex
else
{
this.m_delegate = new Hashtable<S, T>();
- for ( Enumeration<S> ke = delegate.keys(); ke.hasMoreElements(); )
+ for ( Map.Entry<S, T> entry: delegate.entrySet() )
{
- S key = ke.nextElement();
- this.m_delegate.put( key, delegate.get( key ) );
+ this.m_delegate.put( entry.getKey(), entry.getValue() );
}
}
}
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=1602632&r1=1602631&r2=1602632&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 Sun Jun 15 01:09:26 2014
@@ -24,26 +24,26 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Dictionary;
import java.util.Enumeration;
+import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
-import org.apache.felix.scr.Component;
-import org.apache.felix.scr.Reference;
import org.apache.felix.scr.impl.Activator;
import org.apache.felix.scr.impl.BundleComponentActivator;
+import org.apache.felix.scr.impl.config.ComponentManager;
+import org.apache.felix.scr.impl.config.ReferenceManager;
import org.apache.felix.scr.impl.config.ScrConfiguration;
import org.apache.felix.scr.impl.helper.ComponentMethods;
import org.apache.felix.scr.impl.helper.MethodResult;
@@ -54,7 +54,6 @@ import org.apache.felix.scr.impl.metadat
import org.apache.felix.scr.impl.metadata.ServiceMetadata.Scope;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServicePermission;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
@@ -67,7 +66,7 @@ import org.osgi.service.log.LogService;
* implementation object's lifecycle.
*
*/
-public abstract class AbstractComponentManager<S> implements Component, SimpleLogger
+public abstract class AbstractComponentManager<S> implements SimpleLogger, ComponentManager<S>
{
//useful text for deactivation reason numbers
static final String[] REASONS = {"Unspecified",
@@ -388,20 +387,20 @@ public abstract class AbstractComponentM
//---------- Asynchronous frontend to state change methods ----------------
private static final AtomicLong taskCounter = new AtomicLong( );
- /**
- * Enables this component and - if satisfied - also activates it. If
- * enabling the component fails for any reason, the component ends up
- * disabled.
- * <p>
- * This method ignores the <i>enabled</i> flag of the component metadata
- * and just enables as requested.
- * <p>
- * This method enables and activates the component immediately.
- */
- public final void enable()
- {
- enable( true );
- }
+// /**
+// * Enables this component and - if satisfied - also activates it. If
+// * enabling the component fails for any reason, the component ends up
+// * disabled.
+// * <p>
+// * This method ignores the <i>enabled</i> flag of the component metadata
+// * and just enables as requested.
+// * <p>
+// * This method enables and activates the component immediately.
+// */
+// public final void enable()
+// {
+// enable( true );
+// }
public final void enable( final boolean async )
@@ -645,17 +644,6 @@ public abstract class AbstractComponentM
return m_componentMetadata.getFactoryIdentifier();
}
- public Reference[] getReferences()
- {
- if ( m_dependencyManagers != null && m_dependencyManagers.size() > 0 )
- {
- return (Reference[]) m_dependencyManagers.toArray(
- new Reference[m_dependencyManagers.size()] );
- }
-
- return null;
- }
-
public boolean isImmediate()
{
return m_componentMetadata.isImmediate();
@@ -782,7 +770,7 @@ public abstract class AbstractComponentM
null );
return;
}
- if ( !isEnabled())
+ if ( !isInternalEnabled())
{
log( LogService.LOG_DEBUG, "Component is not enabled; not activating component",
null );
@@ -829,7 +817,7 @@ public abstract class AbstractComponentM
null );
return;
}
- if ( !isEnabled() )
+ if ( !isInternalEnabled() )
{
log( LogService.LOG_DEBUG, "Component is not enabled; not activating component",
null );
@@ -1259,7 +1247,7 @@ public abstract class AbstractComponentM
return depMgrList;
}
- final void updateTargets(Dictionary<String, Object> properties)
+ final void updateTargets(Map<String, Object> properties)
{
for ( DependencyManager<S, ?> dm: getDependencyManagers() )
{
@@ -1312,6 +1300,11 @@ public abstract class AbstractComponentM
{
return m_dependencyManagers;
}
+
+ public List<? extends ReferenceManager<S, ?>> getReferenceManagers()
+ {
+ return m_dependencyManagers;
+ }
/**
* Returns an iterator over the {@link DependencyManager} objects
@@ -1327,11 +1320,11 @@ public abstract class AbstractComponentM
DependencyManager<S, ?> getDependencyManager(String name)
{
- for ( DependencyManager<S, ?> dm: getDependencyManagers() )
+ for ( ReferenceManager<S, ?> dm: getDependencyManagers() )
{
if ( name.equals(dm.getName()) )
{
- return dm;
+ return (DependencyManager<S, ?>) dm;
}
}
@@ -1360,7 +1353,10 @@ public abstract class AbstractComponentM
public abstract boolean hasConfiguration();
- public abstract Dictionary<String, Object> getProperties();
+ /* (non-Javadoc)
+ * @see org.apache.felix.scr.impl.manager.ComponentManager#getProperties()
+ */
+ public abstract Map<String, Object> getProperties();
public abstract void setServiceProperties( Dictionary<String, Object> serviceProperties );
@@ -1377,21 +1373,44 @@ public abstract class AbstractComponentM
/**
* Copies the properties from the <code>source</code> <code>Dictionary</code>
- * into the <code>target</code> <code>Dictionary</code>.
+ * into the <code>target</code> <code>Dictionary</code> except for private
+ * properties (whose name has a leading dot) which are only copied if the
+ * <code>allProps</code> parameter is <code>true</code>.
*
- * @param target The <code>Dictionary</code> into which to copy the
- * properties. If <code>null</code> a new <code>Hashtable</code> is
- * created.
- * @param source The <code>Dictionary</code> providing the properties to
- * copy. If <code>null</code> or empty, nothing is copied.
+ * @param target The <code>Dictionary</code> into which to copy the
+ * properties. If <code>null</code> a new <code>Hashtable</code> is
+ * created.
+ * @param source The <code>Dictionary</code> providing the properties to
+ * copy. If <code>null</code> or empty, nothing is copied.
+ * @param allProps Whether all properties (<code>true</code>) or only the
+ * public properties (<code>false</code>) are to be copied.
*
* @return The <code>target</code> is returned, which may be empty if
- * <code>source</code> is <code>null</code> or empty and
- * <code>target</code> was <code>null</code>.
+ * <code>source</code> is <code>null</code> or empty and
+ * <code>target</code> was <code>null</code> or all properties are
+ * private and had not to be copied
*/
- protected static Dictionary<String, Object> copyTo( Dictionary<String, Object> target, Dictionary<String, ?> source )
+ protected static Dictionary<String, Object> copyTo( Dictionary<String, Object> target, final Map<String, ?> source, final boolean allProps )
{
- return copyTo( target, source, true );
+ if ( target == null )
+ {
+ target = new Hashtable<String, Object>();
+ }
+
+ if ( source != null && !source.isEmpty() )
+ {
+ for ( Map.Entry<String, ?> entry: source.entrySet() )
+ {
+ // cast is save, because key must be a string as per the spec
+ String key = entry.getKey();
+ if ( allProps || key.charAt( 0 ) != '.' )
+ {
+ target.put( key, entry.getValue() );
+ }
+ }
+ }
+
+ return target;
}
/**
@@ -1399,10 +1418,6 @@ public abstract class AbstractComponentM
* into the <code>target</code> <code>Dictionary</code> except for private
* properties (whose name has a leading dot) which are only copied if the
* <code>allProps</code> parameter is <code>true</code>.
- *
- * @param target The <code>Dictionary</code> into which to copy the
- * properties. If <code>null</code> a new <code>Hashtable</code> is
- * created.
* @param source The <code>Dictionary</code> providing the properties to
* copy. If <code>null</code> or empty, nothing is copied.
* @param allProps Whether all properties (<code>true</code>) or only the
@@ -1413,19 +1428,36 @@ public abstract class AbstractComponentM
* <code>target</code> was <code>null</code> or all properties are
* private and had not to be copied
*/
- protected static Dictionary<String, Object> copyTo( Dictionary<String, Object> target, final Dictionary<String, ?> source, final boolean allProps )
+ protected static Map<String, Object> copyToMap( final Dictionary<String, ?> source, final boolean allProps )
{
- if ( target == null )
+ Map<String, Object> target = new HashMap<String, Object>();
+
+ if ( source != null && !source.isEmpty() )
{
- target = new Hashtable<String, Object>();
+ for ( Enumeration<String> ce = source.keys(); ce.hasMoreElements(); )
+ {
+ // cast is save, because key must be a string as per the spec
+ String key = ce.nextElement();
+ if ( allProps || key.charAt( 0 ) != '.' )
+ {
+ target.put( key, source.get( key ) );
+ }
+ }
}
+ return target;
+ }
+
+ protected static Dictionary<String, Object> copyToDictionary( final Dictionary<String, ?> source, final boolean allProps )
+ {
+ Hashtable<String, Object> target = new Hashtable<String, Object>();
+
if ( source != null && !source.isEmpty() )
{
- for ( Enumeration ce = source.keys(); ce.hasMoreElements(); )
+ for ( Enumeration<String> ce = source.keys(); ce.hasMoreElements(); )
{
// cast is save, because key must be a string as per the spec
- String key = ( String ) ce.nextElement();
+ String key = ce.nextElement();
if ( allProps || key.charAt( 0 ) != '.' )
{
target.put( key, source.get( key ) );
@@ -1445,29 +1477,32 @@ public abstract class AbstractComponentM
return m_componentMetadata;
}
+ /**
+ * TODO now returning bizarre mix of values!!
+ */
public int getState()
{
if (m_disposed)
{
- return Component.STATE_DISPOSED;
+ return STATE_DISPOSED;
}
if ( !m_internalEnabled)
{
- return Component.STATE_DISABLED;
+ return STATE_DISABLED;
}
if ( getServiceRegistration() == null && (getProvidedServices() != null || !hasInstance()))
{
- return Component.STATE_UNSATISFIED;
+ return STATE_UNSATISFIED;
}
if ( isFactory() && !m_factoryInstance )
{
- return Component.STATE_FACTORY;
+ return STATE_FACTORY;
}
if ( hasInstance() )
{
- return Component.STATE_ACTIVE;
+ return STATE_ACTIVE;
}
- return Component.STATE_REGISTERED;
+ return STATE_SATISFIED;
}
abstract boolean hasInstance();
@@ -1481,7 +1516,7 @@ public abstract class AbstractComponentM
}
}
- boolean isEnabled()
+ boolean isInternalEnabled()
{
return m_internalEnabled;
}
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=1602632&r1=1602631&r2=1602632&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 Sun Jun 15 01:09:26 2014
@@ -89,8 +89,7 @@ public class ComponentContextImpl<S> imp
public final Dictionary<String, Object> getProperties()
{
// 112.12.3.5 The Dictionary is read-only and cannot be modified
- Dictionary<String, Object> ctxProperties = m_componentManager.getProperties();
- return new ReadOnlyDictionary<String, Object>( ctxProperties );
+ return new ReadOnlyDictionary<String, Object>( m_componentManager.getProperties() );
}
Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentFactoryImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentFactoryImpl.java?rev=1602632&r1=1602631&r2=1602632&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentFactoryImpl.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentFactoryImpl.java Sun Jun 15 01:09:26 2014
@@ -32,6 +32,7 @@ import org.apache.felix.scr.component.Ex
import org.apache.felix.scr.impl.BundleComponentActivator;
import org.apache.felix.scr.impl.TargetedPID;
import org.apache.felix.scr.impl.config.ComponentHolder;
+import org.apache.felix.scr.impl.config.ComponentManager;
import org.apache.felix.scr.impl.helper.ComponentMethods;
import org.apache.felix.scr.impl.metadata.ComponentMetadata;
import org.apache.felix.scr.impl.metadata.ReferenceMetadata;
@@ -252,9 +253,13 @@ public class ComponentFactoryImpl<S> ext
}
- public Dictionary<String, Object> getProperties()
+ /**
+ * For ComponentFactoryImpl, this is used only for updating targets on the dependency managers, so we don't need any other
+ * properties.
+ */
+ public Map<String, Object> getProperties()
{
- Dictionary<String, Object> props = getServiceProperties();
+ Map<String, Object> props = new HashMap<String, Object>();
// add target properties of references
List<ReferenceMetadata> depMetaData = getComponentMetadata().getDependencies();
@@ -332,7 +337,7 @@ public class ComponentFactoryImpl<S> ext
//---------- ComponentHolder interface
- public void configurationDeleted( String pid )
+ public void configurationDeleted( TargetedPID pid, TargetedPID factoryPid )
{
m_targetedPID = null;
if ( pid.equals( getComponentMetadata().getConfigurationPid() ) )
@@ -451,18 +456,13 @@ public class ComponentFactoryImpl<S> ext
}
- public synchronized long getChangeCount( TargetedPID pid)
+ public synchronized long getChangeCount( TargetedPID pid, TargetedPID targetedPid)
{
return m_changeCount;
}
- public List<? extends Component> getComponents()
- {
- return getComponentList();
- }
-
- protected List<AbstractComponentManager<S>> getComponentList()
+ public List<? extends ComponentManager<S>> getComponents()
{
List<AbstractComponentManager<S>> cms = new ArrayList<AbstractComponentManager<S>>( );
cms.add( this );
@@ -557,4 +557,9 @@ public class ComponentFactoryImpl<S> ext
}
+ public boolean isEnabled() {
+ return isInternalEnabled();
+ }
+
+
}
Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ConfigurationComponentFactoryImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ConfigurationComponentFactoryImpl.java?rev=1602632&r1=1602631&r2=1602632&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ConfigurationComponentFactoryImpl.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ConfigurationComponentFactoryImpl.java Sun Jun 15 01:09:26 2014
@@ -29,6 +29,7 @@ import org.apache.felix.scr.Component;
import org.apache.felix.scr.impl.BundleComponentActivator;
import org.apache.felix.scr.impl.TargetedPID;
import org.apache.felix.scr.impl.config.ComponentHolder;
+import org.apache.felix.scr.impl.config.ComponentManager;
import org.apache.felix.scr.impl.helper.ComponentMethods;
import org.apache.felix.scr.impl.metadata.ComponentMetadata;
import org.osgi.framework.Constants;
@@ -117,11 +118,11 @@ public class ConfigurationComponentFacto
//---------- ComponentHolder interface
- public void configurationDeleted( String pid )
+ public void configurationDeleted( TargetedPID pid, TargetedPID factoryPid )
{
if ( pid.equals( getComponentMetadata().getConfigurationPid() ) )
{
- super.configurationDeleted( pid );
+ super.configurationDeleted( pid, factoryPid );
}
else
{
@@ -189,9 +190,9 @@ public class ConfigurationComponentFacto
}
- public List<? extends Component> getComponents()
+ public List<? extends ComponentManager<S>> getComponents()
{
- List<AbstractComponentManager<S>> cms = getComponentList();
+ List<AbstractComponentManager<S>> cms = (List<AbstractComponentManager<S>>) super.getComponents();
getComponentManagers( m_configuredServices, cms );
return cms;
}
Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java?rev=1602632&r1=1602631&r2=1602632&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java Sun Jun 15 01:09:26 2014
@@ -39,6 +39,7 @@ import java.util.concurrent.atomic.Atomi
import org.apache.felix.scr.Component;
import org.apache.felix.scr.Reference;
import org.apache.felix.scr.impl.BundleComponentActivator;
+import org.apache.felix.scr.impl.config.ReferenceManager;
import org.apache.felix.scr.impl.helper.BindMethod;
import org.apache.felix.scr.impl.helper.BindMethods;
import org.apache.felix.scr.impl.helper.Coercions;
@@ -60,7 +61,7 @@ import org.osgi.service.log.LogService;
* declared by a single <code><reference></code element in component
* descriptor.
*/
-public class DependencyManager<S, T> implements Reference
+public class DependencyManager<S, T> implements ReferenceManager<S, T>
{
// mask of states ok to send events
private static final int STATE_MASK =
@@ -1303,37 +1304,21 @@ public class DependencyManager<S, T> imp
//---------- bound services maintenance -----------------------------------
- /**
- * Returns an array of <code>ServiceReference</code> instances of all
- * services this instance is bound to or <code>null</code> if no services
- * are actually bound.
- */
- public ServiceReference<T>[] getServiceReferences()
+ /* (non-Javadoc)
+ * @see org.apache.felix.scr.impl.manager.ReferenceManager#getServiceReferences()
+ */
+ public List<ServiceReference<?>> getServiceReferences()
{
Collection<RefPair<T>> bound = m_customizer.getRefs( new AtomicInteger( ) );
- if ( bound.isEmpty() )
- {
- return null;
- }
- ServiceReference<T>[] result = new ServiceReference[bound.size()];
- int i = 0;
+ List<ServiceReference<?>> result = new ArrayList<ServiceReference<?>>(bound.size());
for (RefPair<T> ref: bound)
{
- result[i++] = ref.getRef();
+ result.add(ref.getRef());
}
return result;
}
/**
- * a mistake, use getServiceReferences instead
- */
- @Deprecated
- public ServiceReference[] getBoundServiceReferences()
- {
- return getServiceReferences();
- }
-
- /**
* Returns the RefPair containing the given service reference and the bound service
* or <code>null</code> if this is instance is not currently bound to that
* service.
@@ -1424,9 +1409,9 @@ public class DependencyManager<S, T> imp
//---------- DependencyManager core ---------------------------------------
- /**
- * Returns the name of the service reference.
- */
+ /* (non-Javadoc)
+ * @see org.apache.felix.scr.impl.manager.ReferenceManager#getName()
+ */
public String getName()
{
return m_dependencyMetadata.getName();
@@ -1785,7 +1770,7 @@ public class DependencyManager<S, T> imp
* apply.</li>
* </ol>
*/
- boolean canUpdateDynamically( Dictionary<String, Object> properties )
+ boolean canUpdateDynamically( Map<String, Object> properties )
{
// 1. no target filter change
final String newTarget = ( String ) properties.get( m_dependencyMetadata.getTargetPropertyName() );
@@ -1845,14 +1830,14 @@ public class DependencyManager<S, T> imp
* @param properties The properties containing the optional target service
* filter property
*/
- void setTargetFilter( Dictionary<String, Object> properties )
+ void setTargetFilter( Map<String, Object> properties )
{
Integer minimumCardinality = getMinimumCardinality( properties );
setTargetFilter( ( String ) properties.get( m_dependencyMetadata.getTargetPropertyName() ),
minimumCardinality);
}
- private int getMinimumCardinality(Dictionary<String, Object> properties)
+ private int getMinimumCardinality(Map<String, Object> properties)
{
Integer minimumCardinality = null;
try
@@ -2043,13 +2028,9 @@ public class DependencyManager<S, T> imp
}
- /**
- * Returns the target filter of this dependency as a string or
- * <code>null</code> if this dependency has no target filter set.
- *
- * @return The target filter of this dependency or <code>null</code> if
- * none is set.
- */
+ /* (non-Javadoc)
+ * @see org.apache.felix.scr.impl.manager.ReferenceManager#getTarget()
+ */
public String getTarget()
{
return m_target;
Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleComponentManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleComponentManager.java?rev=1602632&r1=1602631&r2=1602632&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleComponentManager.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleComponentManager.java Sun Jun 15 01:09:26 2014
@@ -22,6 +22,7 @@ package org.apache.felix.scr.impl.manage
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Dictionary;
+import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
@@ -31,6 +32,8 @@ import java.util.concurrent.atomic.Atomi
import org.apache.felix.scr.impl.BundleComponentActivator;
import org.apache.felix.scr.impl.TargetedPID;
import org.apache.felix.scr.impl.config.ComponentHolder;
+import org.apache.felix.scr.impl.config.ComponentManager;
+import org.apache.felix.scr.impl.config.ReferenceManager;
import org.apache.felix.scr.impl.helper.ActivateMethod.ActivatorParameter;
import org.apache.felix.scr.impl.helper.ComponentMethods;
import org.apache.felix.scr.impl.helper.MethodResult;
@@ -66,10 +69,10 @@ public class SingleComponentManager<S> e
private Map<String, Object> m_configurationProperties;
// optional properties provided in the ComponentFactory.newInstance method
- private Dictionary<String, Object> m_factoryProperties;
+ private Map<String, Object> m_factoryProperties;
// the component properties, also used as service properties
- private Dictionary<String, Object> m_properties;
+ private Map<String, Object> m_properties;
// properties supplied ot ExtComponentContext.updateProperties
// null if properties are not to be overwritten
@@ -265,7 +268,7 @@ public class SingleComponentManager<S> e
// 4. Bind the target services
- DependencyManager<S, ?> failedDm = null;
+ ReferenceManager<S, ?> failedDm = null;
for ( DependencyManager<S, ?> dm: getDependencyManagers())
{
if ( failedDm == null )
@@ -406,7 +409,7 @@ public class SingleComponentManager<S> e
protected void setFactoryProperties( Dictionary<String, ?> dictionary )
{
- m_factoryProperties = copyTo( null, dictionary );
+ m_factoryProperties = copyToMap( dictionary, true );
}
@@ -437,9 +440,9 @@ public class SingleComponentManager<S> e
* Method implements the Component Properties provisioning as described
* in 112.6, Component Properties.
*
- * @return a private Hashtable of component properties
+ * @return a private map of component properties
*/
- public Dictionary<String, Object> getProperties()
+ public Map<String, Object> getProperties()
{
if ( m_properties == null )
@@ -447,14 +450,14 @@ public class SingleComponentManager<S> e
// 1. Merge all the config properties
- Hashtable<String, Object> props = new Hashtable<String, Object>();
+ Map<String, Object> props = new HashMap<String, Object>();
if ( m_configurationProperties != null )
{
props.putAll(m_configurationProperties);
}
if ( m_factoryProperties != null)
{
- copyTo(props, m_factoryProperties);
+ props.putAll(m_factoryProperties);
}
// 2. set component.name and component.id
@@ -475,7 +478,7 @@ public class SingleComponentManager<S> e
}
else
{
- m_serviceProperties = copyTo( null, serviceProperties, false );
+ m_serviceProperties = copyToDictionary( serviceProperties, false );
// set component.name and component.id
m_serviceProperties.put( ComponentConstants.COMPONENT_NAME, getComponentMetadata().getName() );
m_serviceProperties.put( ComponentConstants.COMPONENT_ID, getId() );
@@ -679,7 +682,7 @@ public class SingleComponentManager<S> e
// 3. check whether we can dynamically apply the configuration if
// any target filters influence the bound services
- final Dictionary<String, Object> props = getProperties();
+ final Map<String, Object> props = getProperties();
for ( DependencyManager dm: getDependencyManagers() )
{
if ( !dm.canUpdateDynamically( props ) )
@@ -867,7 +870,7 @@ public class SingleComponentManager<S> e
private S getService()
{
//should be write locked
- if (!isEnabled())
+ if (!isInternalEnabled())
{
return null;
}
Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java?rev=1602632&r1=1602631&r2=1602632&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java Sun Jun 15 01:09:26 2014
@@ -23,10 +23,12 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Dictionary;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
@@ -102,7 +104,7 @@ public class ComponentMetadata
private List<String> m_configurationPid;
// Associated properties (0..*)
- private Dictionary<String, Object> m_properties = new Hashtable<String, Object>();
+ private Map<String, Object> m_properties = new HashMap<String, Object>();
// List of Property metadata - used while building the meta data
// while validating the properties contained in the PropertyMetadata
@@ -520,7 +522,11 @@ public class ComponentMetadata
{
throw new IllegalStateException("not yet validated");
}
- return m_configurationPid == null? -1: m_configurationPid.indexOf(pid.getServicePid());
+ if (m_configurationPid == null )
+ {
+ throw new IllegalStateException( "Apparently trying to configure a component " + m_name + " without a configurationPid using " + pid);
+ }
+ return m_configurationPid.indexOf(pid.getServicePid());
}
/**
@@ -695,7 +701,7 @@ public class ComponentMetadata
*
* @return the properties as a Dictionary
*/
- public Dictionary<String, Object> getProperties()
+ public Map<String, Object> getProperties()
{
return m_properties;
}