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

Clement Escoffier commented on FELIX-1940:
------------------------------------------

Hi,

I've finally 'revert' my solution. The previous mentioned solution introduced a 
lot of annotations and the resulting user-code was quite messy (so support all 
the type of possible configurations). 
So, I've decided a fairly more simple solution. I propose to use one annotation 
: @Instantiate. On a @Component annotated class it will create one instance 
automatically. The instance is created without configuration.
 
@Instantiate
@Component
public class MyComponent {
   
   ...

}



For more complexes use cases (application/configuration description), I 
encourage to use this annotation on a component implementation using the iPOJO 
API to create the instances and compositions. So, it is possible to use the 
complete range of iPOJO features that way:

@Instantiate
@Component
public class MyApplicationConfiguration {
      @Requires(filter="(factory.name=my.factory)")
      private Factory myFactory;


      @Requires(filter="(factory.name=my.factory.2)")
      private Factory mySecondFactory;

     ComponentInstance instance1, instance2;

   @Validate
   public void configure() {
     instance1 = myFactory.createComponentInstance(null);
     instance2 = mySecondFactory.createComponentInstance(null);
  }

 @Invalidate
  public void shutdown() {
      instance1.dispose();
      instance2.dispose();
 }
}


> Add @Instance annotation to declare instances without metadata.xml
> ------------------------------------------------------------------
>
>                 Key: FELIX-1940
>                 URL: https://issues.apache.org/jira/browse/FELIX-1940
>             Project: Felix
>          Issue Type: Wish
>          Components: iPOJO
>    Affects Versions: iPOJO-1.4.0
>            Reporter: Allen Hackley
>            Priority: Minor
>
> Currently, instances cannot be declared using annotations.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to