Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for named attribute injection #30

Closed
wants to merge 2 commits into
base: master
from

Conversation

Projects
None yet
2 participants
@McFoggy
Copy link

McFoggy commented Sep 17, 2014

Hi Adam,

find attached a small contribution that adds support for named attribute injection.

It allows to inject directly default system properties which key use a dot naming (ex: user.home) and thus cannot be used as an attribute name in a Java class.

I found it usefull for example to write things like:

@Inject
@Named("line.separator")
private String ls;

@Inject
@Named("user.dir")
private String workingDir;

Regards

Matthieu Brouillard

@McFoggy

This comment has been minimized.

Copy link
Author

McFoggy commented Oct 27, 2014

Adam,

is there something more I can do for the PR, something missing?

Regards,

Matthieu

@AdamBien

This comment has been minimized.

Copy link
Owner

AdamBien commented Oct 28, 2014

Hi McFoggy,

no thanks. I'm just thinking about using all good contributions in afterburner. I would like to afterburner as lean as only possible. So far I didn't had any requirements for @nAmed injection. In fact using @nAmed for injection is considered in CDI as a "bad practice".

I'm just waiting, whether other afterburner users miss the Named injection as well.

thanks for your great contribution!,

cheers,

adam

@McFoggy

This comment has been minimized.

Copy link
Author

McFoggy commented Oct 28, 2014

Hi Adam,

I understand your concerns to keep Afterburner lean.

On the other hand, using this annotation was a simple way to inject those non compatible (with java field names) system properties or also program arguments.

Another way to do it could be also to use again some other convention (replacement of char in attribute name?):

@Inject
String line_separator;

Not sure it is cleaner.
In the end, perhaps you'll just decide to explicitly document that such properties are not injectable ; which is also perfectly acceptable.

Matthieu

@McFoggy

This comment has been minimized.

Copy link
Author

McFoggy commented Oct 28, 2014

In fact using @nAmed for injection is considered in CDI as a "bad practice".

I agree, but Afterburner is javax.inject compliant, not CDI compliant. We cannot use as it is today a qualifier let say as: @SystemProperty("line.separator").
That's exactly why I used first @nAmed annotation that is part of javax.inject.

@AdamBien

This comment has been minimized.

Copy link
Owner

AdamBien commented Nov 21, 2014

Merged into the "topgun" branch. Artifact is going to be published soon unter:

com.airhacks
afterburner-topgun.fx

@AdamBien AdamBien closed this Nov 21, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.