Hi,

If I look into the coding, I would guess, that this is supposed to work (but 
the code in question has been reworked between 0.3 and 1.0 and the 
ServiceFactory use case seems to be forgotten in some places). I have opened a 
bug (https://issues.apache.org/jira/browse/ARIES-1063) for this where I 
provided this example and a (three line) patch for the issue.

Best regards
Stephan

From: Siano, Stephan [mailto:[email protected]]
Sent: Montag, 6. Mai 2013 14:28
To: [email protected]
Subject: Aries Blueprint 1.1.0 and ServiceFactory

Hi,

I am trying to upgrade the blueprint implementation from aries blueprint 0.3.1 
to aries blueprint 1.1.0, but I am having issues with OSGi services based on a 
ServiceFactory.

If I set up the following project:
package com.foo.aries.issue;

public interface FooService {
}

package com.foo.aries.issue.impl;

import com.foo.aries.issue.FooService;

public class FooServiceImpl implements FooService {
}

package com.foo.aries.issue.impl;

import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceFactory;
import org.osgi.framework.ServiceRegistration;

import com.foo.aries.issue.FooService;

public class FooServiceFactory implements ServiceFactory<FooService> {

    @Override
    public FooService getService(Bundle bundle, ServiceRegistration<FooService> 
registration) {
        return new FooServiceImpl();
    }

    @Override
    public void ungetService(Bundle bundle, ServiceRegistration<FooService> 
registration, FooService service) {
    }
}

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xsi:schemaLocation="
            http://www.osgi.org/xmlns/blueprint/v1.0.0 
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd";>
    <service id="fooService" interface="com.foo.aries.issue.FooService">
        <bean class="com.foo.aries.issue.impl.FooServiceFactory"/>
    </service>
</blueprint>

the bundle starts the service on aries blueprint 0.3.1, but on aries blueprint 
1.1.0, I get the following error:
14:13:09.994 ERROR [Blueprint Extender: 2] o.a.a.b.c.BlueprintContainerImpl 
[BlueprintContainerImpl.java:393] - Unable to start blueprint container for 
bundle com.foo.aries.issue
org.osgi.service.blueprint.container.ComponentDefinitionException: 
org.osgi.service.blueprint.container.ComponentDefinitionException: The service 
implementation does not implement the required interfaces: 
[com.foo.aries.issue.FooService]
                at 
org.apache.aries.blueprint.container.ServiceRecipe.createService(ServiceRecipe.java:297)
 ~[bundlefile:1.1.0]
                at 
org.apache.aries.blueprint.container.ServiceRecipe.internalGetService(ServiceRecipe.java:249)
 ~[bundlefile:1.1.0]
                at 
org.apache.aries.blueprint.container.ServiceRecipe.internalCreate(ServiceRecipe.java:146)
 ~[bundlefile:1.1.0]
                at 
org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79) 
~[bundlefile:1.1.0]
                at java.util.concurrent.FutureTask$Sync.innerRun(Unknown 
Source) [na:1.7.0_17]
                at java.util.concurrent.FutureTask.run(Unknown Source) 
[na:1.7.0_17]
                at 
org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88) 
~[bundlefile:1.1.0]
                at 
org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:245)
 ~[bundlefile:1.1.0]
                at 
org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:183)
 ~[bundlefile:1.1.0]
                at 
org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:668)
 [bundlefile:1.1.0]
                at 
org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:370)
 [bundlefile:1.1.0]
                at 
org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:261)
 [bundlefile:1.1.0]
                at java.util.concurrent.Executors$RunnableAdapter.call(Unknown 
Source) [na:1.7.0_17]
                at java.util.concurrent.FutureTask$Sync.innerRun(Unknown 
Source) [na:1.7.0_17]
                at java.util.concurrent.FutureTask.run(Unknown Source) 
[na:1.7.0_17]
                at 
org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106)
 [bundlefile:1.1.0]
                at 
org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)
 [bundlefile:1.1.0]
                at java.util.concurrent.Executors$RunnableAdapter.call(Unknown 
Source) [na:1.7.0_17]
                at java.util.concurrent.FutureTask$Sync.innerRun(Unknown 
Source) [na:1.7.0_17]
                at java.util.concurrent.FutureTask.run(Unknown Source) 
[na:1.7.0_17]
                at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown
 Source) [na:1.7.0_17]
                at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown
 Source) [na:1.7.0_17]
                at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown 
Source) [na:1.7.0_17]
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown 
Source) [na:1.7.0_17]
                at java.lang.Thread.run(Unknown Source) [na:1.7.0_17]
Caused by: org.osgi.service.blueprint.container.ComponentDefinitionException: 
The service implementation does not implement the required interfaces: 
[com.foo.aries.issue.FooService]
                at 
org.apache.aries.blueprint.container.ServiceRecipe.validateClasses(ServiceRecipe.java:340)
 ~[bundlefile:1.1.0]
                at 
org.apache.aries.blueprint.container.ServiceRecipe.createService(ServiceRecipe.java:289)
 ~[bundlefile:1.1.0]
                ... 24 common frames omitted

What's wrong here? Is this not supposed to work and works only accidentally 
with aries blueprint 0.3.1? How can I set up a ServiceFactory with aries 
blueprint 1.1.0? Does anybody here have a clue about this?

Best regards
Stephan


Reply via email to