Repository navigation
Update conversion doc - #268
Conversation
Make clear that JSR250 annotations are not required, if user is ok to use Sisu provided ones instead, that has same semantics. Also, some cleanup done as well.
HannesWell
left a comment
There was a problem hiding this comment.
The example to replace Disposable without lifecycle annotations is very helpful.
But I wonder if the List injected into MyLifecycleParticipant is updated if new MyDispoosable instances are created later.
As far as I understand it Sisu is in general lazy.
Co-authored-by: Hannes Wellmann <wellmann.hannes1@gmx.net>
Co-authored-by: Hannes Wellmann <wellmann.hannes1@gmx.net>
Co-authored-by: Hannes Wellmann <wellmann.hannes1@gmx.net>
Yes, sisu is lazy, and injected collections ( If properly scoping (not unload then dispose), it should work. |
| } | ||
| ``` | ||
|
|
||
| Alternately, users can define their own lifecycle interface, and use that by injecting those into some component that has access to lifecycle |
There was a problem hiding this comment.
I would rather suggest reusing AutoCloseable in order to allow usage of try with resources.
There was a problem hiding this comment.
Maybe also mention https://docs.oracle.com/javase//9/docs/api/java/lang/ref/Cleaner.html as an alternative.
There was a problem hiding this comment.
I would never do something like this in any of app I author:
@Inject
private List<AutoCloseable> closeable;as this interface is not "dedicated" to app, but is free for all, and you don't know who used it for what. If we talk about some "set of libraries", take Resolver SPI is for example. Best (and safest) is always to introduce specific and dedicated type for use case. If you want to cooperate, than introduce some sort of SPI or shared APIs and use that. But Java built in types being injected is a no-no for me.
There was a problem hiding this comment.
Re Cleaner, the doco merely shows the idea, strategy, and how it is implemented by users is totally different thing IMO.
There was a problem hiding this comment.
I would never do something like this in any of app I author:
@Inject private List<AutoCloseable> closeable;as this interface is not "dedicated" to app, but is free for all, and you don't know who used it for what. If we talk about some "set of libraries", take Resolver SPI is for example. Best (and safest) is always to introduce specific and dedicated type for use case. If you want to cooperate, than introduce some sort of SPI or shared APIs and use that. But Java built in types being injected is a no-no for me.
Right, maybe then just suggest extending it. Does Sisu always register all (transitive) interfaces or just direct ones?
There was a problem hiding this comment.
Sisu injects any discovered bean (from index or discovered by any other means, as configured) that are type-wise applicable. Extending it is okay, point is to create dedicated type to avoid any possible problems.
Co-authored-by: Konrad Windszus <konrad_w@gmx.de>
|



Make clear that JSR250 annotations are not required, if user is ok to use Sisu provided ones instead, that has same semantics. Also, some cleanup done as well.