Skip to content

Conversation

@McFoggy
Copy link

@McFoggy 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
Copy link
Author

McFoggy commented Oct 27, 2014

Adam,

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

Regards,

Matthieu

@AdamBien
Copy link
Owner

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
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
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
Copy link
Owner

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants