Hello Mark,
On Oct 20, 2012, at 23:34 PM, Mark van Cuijk <[email protected]> wrote:
> I've been playing a bit with aspect services using the DependencyManager and
> I've found some behavior that doesn't match my expectations. So either my
> expectations are wrong or I stumbled upon a bug...
>
> Given an empty interface example.ExampleService, an empty implementation
> class example.ExampleServiceImpl and the Activator included below, would
> expect the aspect with ranking 20 to have property=aspect, but it actually
> has property=original, as shown in the Gogo Shell output included below the
> Activator source.
>
> What is the intended behavior in this situation?
The intended behavior is that aspects inherit the service properties of the
original service they are an aspect of.
Your example has an original service and two aspects on top of that, one with
ranking 10, another with ranking 20.
The one with ranking 10 adds (or rather overwrites) a property called
"property", giving it the value "aspect". So that value will overwrite the
original value of "original".
The one with ranking 20 does not add any properties, and therefore it will
inherit the ones from the original service. This probably was not what you
expected, judging from your question. You expected it to inherit the properties
of the aspect with ranking 10.
Out of curiosity, did you want to exploit the behavior you expected? In other
words, do you have a use case for it?
> public class Activator extends DependencyActivatorBase {
>
> @Override
> public void init(BundleContext context, DependencyManager manager) throws
> Exception {
> manager.add(createComponent()
> .setInterface(ExampleService.class.getName(), new Properties() {{
> put("property", "original");
> }})
> .setImplementation(ExampleServiceImpl.class));
>
> manager.add(createAspectService(ExampleService.class, null, 10)
> .setServiceProperties(new Properties() {{
> put("property", "aspect");
> }})
> .setImplementation(ExampleServiceImpl.class));
>
> manager.add(createAspectService(ExampleService.class, null, 20)
> .setImplementation(ExampleServiceImpl.class));
> }
>
> @Override
> public void destroy(BundleContext context, DependencyManager manager) throws
> Exception {
> }
>
> }
>
> [8] AspectExample
> example.ExampleService(property=original) registered
> org.apache.felix.dm.impl.AspectServiceImpl$AspectImpl@6087e704 registered
> example.ExampleService (!(org.apache.felix.dependencymanager.aspect=*))
> service optional available
>
> example.ExampleService(service.ranking=10,property=aspect,org.apache.felix.dependencymanager.aspect=19)
> registered
> example.ExampleService
> (&(|(!(service.ranking=*))(service.ranking<=9))(|(service.id=19)(org.apache.felix.dependencymanager.aspect=19)))
> service required available
> org.apache.felix.dm.impl.AspectServiceImpl$AspectImpl@7a4fe91e registered
> example.ExampleService (!(org.apache.felix.dependencymanager.aspect=*))
> service optional available
>
> example.ExampleService(service.ranking=20,property=original,org.apache.felix.dependencymanager.aspect=19)
> registered
> example.ExampleService
> (&(|(!(service.ranking=*))(service.ranking<=19))(|(service.id=19)(org.apache.felix.dependencymanager.aspect=19)))
> service required available
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]