Bug 163705 - [ds] Declarative Services Does Not Support Configuration Admin ManagedServiceFactory
Summary: [ds] Declarative Services Does Not Support Configuration Admin ManagedService...
Status: RESOLVED WORKSFORME
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Compendium (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Stoyan Boshev CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2006-11-07 14:20 EST by Benjamin Schmaus CLA
Modified: 2008-09-30 05:31 EDT (History)
4 users (show)

See Also:


Attachments
Updated version of enableComponents that works with ManagedServiceFactories (20.00 KB, text/plain)
2006-11-07 14:23 EST, Benjamin Schmaus CLA
no flags Details
Fixed patch file for updated enabledComponents method that handles ManagedServiceFactories (6.78 KB, patch)
2006-11-07 14:30 EST, Benjamin Schmaus CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Schmaus CLA 2006-11-07 14:20:15 EST
From section 112.7, Deployment of Declarative Services (R4) Spec:

"Factory Configuration – If a factory PID exists, with zero or more Configu-
rations, that is equal to the component name, then for each Configuration, a component configuration must be created that will obtain additional component properties from Configuration Admin. This is the ManagedServiceFactory situation."

In org.eclipse.equinox.ds.resolver.Resolver.enableComponents(List componentDescriptions) the following code never checks to see if any Configurations are registered with a service.factoryPid matching the component's name, which prevents ManagedServiceFactories from being handled properly:

			// check for a Configuration properties for this component
			Configuration config = null;
			try {
				ConfigurationAdmin configurationAdmin = (ConfigurationAdmin) configAdminTracker.getService();
				if (configurationAdmin != null) {
					config = configurationAdmin.getConfiguration(cd.getName(), cd.getBundleContext().getBundle().getLocation());
				}
			} catch (IOException e) {
				// Log it and continue
				Log.log(1, "[SCR] IOException when getting Configuration Properties. ", e);
			}

			// if no Configuration
			if (config == null) {
				// create ComponentConfiguration
				map(cd, null);

			} else {

				// if ManagedServiceFactory
				if (config.getFactoryPid() != null) {

This code looks for configurations with a pid that has the same value of the name of the component.  This doesn't work in the case of ManagedServiceFactories since pids are programmatically generated for them.  So the code above only works with ManagedServices.

I'll submit a possible patch that looks for Configurations with a service.factoryPid that matches the component's name, and if none are found a lookup will be performed to see if any existing Configurations are registered with a service.pid that matches the component's name.  I believe this handles both cases.
Comment 1 Benjamin Schmaus CLA 2006-11-07 14:23:43 EST
Created attachment 53397 [details]
Updated version of enableComponents that works with ManagedServiceFactories
Comment 2 Benjamin Schmaus CLA 2006-11-07 14:30:16 EST
Created attachment 53401 [details]
Fixed patch file for updated enabledComponents method that handles ManagedServiceFactories
Comment 3 Benjamin Schmaus CLA 2006-11-07 14:32:50 EST
First attached patch is corrupt (I attached a tmp vim generated file by mistake) second should be ok.
Comment 4 Benjamin Schmaus CLA 2006-11-07 14:54:16 EST
Comment on attachment 53397 [details]
Updated version of enableComponents that works with ManagedServiceFactories

Attached vim .swp file by mistake.
Comment 5 Thomas Watson CLA 2007-01-10 13:32:46 EST
BJ, can you review the patch and release if appropriate?
Comment 6 Steven E. Harris CLA 2007-03-05 12:06:00 EST
I know the whole crowd here is probably busy with EclipseCon now, but I'd appreciate it if someone could apply the provided patch and make an updated bundle available, as my specific use case for DS relies upon this interaction between DS and a ManagedServiceFactory.
Comment 7 BJ Hargrave CLA 2008-08-12 15:56:00 EDT
Can we close this since the DS impl was replaced by a contribution from ProSyst?
Comment 8 Stoyan Boshev CLA 2008-09-30 05:31:22 EDT
There is no such problem with the new DS implementation