Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sisu-dev] Custom Annos

Thanks.  Just realized I asked almost the same question a year ago.  ;)


On 10/08/2014 04:24 PM, Stuart McCulloch wrote:
Hi Jonathan,

If those annotations are themselves annotated with @Qualifier then both SisuIndex and the sisu-maven-plugin's (http://eclipse.org/sisu/docs/api/org.eclipse.sisu.mojos/) index goals will pick them up.

There’s also the Java6 annotation processor which automatically kicks in when Sisu is on the compile path, use "-Aqualifiers=all” to get it to check all annotations for @Qualifier instead of simply looking for @Named:

      <plugin>

        <groupId>org.apache.maven.plugins</groupId>

        <artifactId>maven-compiler-plugin</artifactId>

        <configuration>

          <compilerArgs>

            <arg>-Aqualifiers=all</arg>

          </compilerArgs>

        </configuration>

      </plugin>


We have an open feature request to support indexing of annotations that don’t have @Qualifier in the backlog (https://bugs.eclipse.org/bugs/show_bug.cgi?id=410820) which should be straightforward to implement.

Once your classes are in the index if you want to control how they get translated into bindings then you can pass your own scanning strategy into SpaceModule, that’s how the Plexus adapter works:


Note that if you use full class path scanning instead of indexed then there’s no need to add your classes to the index, you only need to use your custom strategy (but full scanning is slower by definition)

You can use a similar approach to decide what to do with types annotated with those export annotations.

-- 
Cheers, Stuart

On Wednesday, 8 October 2014 at 00:23, Jonathan Doklovic wrote:

Hey Stuart,

I'm working on making a compatibility layer for existing bundles we have
that are using custom annotations for DI.
For instance, we have @JiraComponent and @ConfluenceComponent which
essentially tell the system to add them to the injector only if we're
running in that specific product.
This is to facilitate having a single bundle that can run in multiple
products.

I'm wondering how I can add these custom annotations to the sisu indexer
and then customize the injector to do the product check.

Once I get that going, we also have 2 other annotations that I'll need
to deal with: @ExportAsService and @ExportAsDevService
In our own non-sisu/spring code, we used these to write out sisu-like
index files to be used to determine what should be exported as an OSGi
service at runtime. The second one only exports the annotated component
if the product is running in dev mode. Again, I need to know how this
translates to the sisu world, and if it doesn't I assume I'll just need
to use a custom extender + peaberry to do my bidding?

Thanks,

- Jonathan
_______________________________________________
sisu-dev mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit



_______________________________________________
sisu-dev mailing list
sisu-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/sisu-dev


Back to the top