Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 343098 - [Xtend] dependency injection support for BindingAnnotations and Named
Summary: [Xtend] dependency injection support for BindingAnnotations and Named
Status: CLOSED WONTFIX
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.0.0   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-18 04:04 EDT by Sven Efftinge CLA
Modified: 2011-05-15 10:29 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sven Efftinge CLA 2011-04-18 04:04:45 EDT
The following part from the language reference needs yet to be implemented:


Guice Keys
Xtend uses Guice as the dependency injection container, which in turn uses types as keys. Those types can be generified, which is why you can write the following in Xtend.

@Inject HashMap<String,MyType> myCache;

Also Guice allows to use annotations to further distinct between different implementations of the same type. This is usually done by using the com.google.inject.name.Named annotation or a custom annotation which is itself annotated with com.google.inject.BindingAnnotation .

Xtend supports these two variants:

@Inject @CustomAnnotation my.Service customService; 
@Inject @"NamedThingy" my.Service namedService;

Providers are declared like in plain Guice. That is you wrap your type into com.google.inject.Provider . Example:

@Inject @CustomAnnotation Provider<Service> customServiceProvider;
Comment 1 Sven Efftinge CLA 2011-05-15 10:29:44 EDT
We have changed the language spec and decided to fully support Java Annotations, which makes this superfluous.