You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Clement Escoffier (JIRA)" <ji...@apache.org> on 2014/08/25 11:08:58 UTC

[jira] [Commented] (FELIX-4611) Strategy "INSTANCE" does not seem to work with @Bind annotation

    [ https://issues.apache.org/jira/browse/FELIX-4611?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14108917#comment-14108917 ] 

Clement Escoffier commented on FELIX-4611:
------------------------------------------

Hi,

I'm not able to reproduce the bug.

I've a configuration with a provider and two consumer instances:

The provider is the following:

{code}
    @Component
    @Provides(strategy = "INSTANCE")
    @Instantiate
    public class ProviderComponent implements Service {

        @Override
        public String name() {
            return this.toString();
        }
    }
{code}

The consumer class is:

{code}
    @Component(immediate=true)
    public class ConsumerComponent {

        @Bind
        public void bindService(Service service) {
            System.out.println(service.name());
        }
    }
{code}

And a configuration creating the two consumers:

{code}
    @Configuration
    public class MyConfiguration {

        Instance cons1 = instance().of(ConsumerComponent.class);
        Instance cons2 = instance().of(ConsumerComponent.class);

    }
{code}

And on the console, I get the expected result:

{code}
    test.ProviderComponent@380cb77b
    test.ProviderComponent@64a620a6
{code}

So, I get two different objects as expected.

If I use the "SINGLETON" policy then I get the same object:

{code}
    test.ProviderComponent@477a985
    test.ProviderComponent@477a985
{code}

> Strategy "INSTANCE" does not seem to work with @Bind annotation
> ---------------------------------------------------------------
>
>                 Key: FELIX-4611
>                 URL: https://issues.apache.org/jira/browse/FELIX-4611
>             Project: Felix
>          Issue Type: Bug
>          Components: iPOJO
>            Reporter: Vladimir Dzalbo
>
> I am seeing some problems with strategy="instance"
> First, I created a new component 
> {code:java}
> @Component(propagation = true)
> @Provides(strategy="INSTANCE")
> {code}
> If I am trying to inject it with @Bind annotation, iPojo does not seem to inject it...
> {code:java}
> 	@Bind(aggregate = true, optional = true, proxy = false)
> 	public void bindScreen(Screen screen) {
> 		log.info("Binding Screen: " + screen.getClass().getName());
> 	}
> {code}
> However @Requires annotation works like a charm..
> {code:java}
> 	@Requires(optional = true)
> 	Screen[] screensArray;
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)