-
Notifications
You must be signed in to change notification settings - Fork 81
add @AutoClose
#915
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
base: main
Are you sure you want to change the base?
add @AutoClose
#915
Conversation
|
This is a draft because it also includes the I'd especially welcome review of the changes to the Portable Extensions API, because I'm not familiar with those. |
This annotation may be put on `@ApplicationScoped` beans to trigger eager initialization. This occurs at the same time as the `Startup` event. Putting the annotation on a bean of any other scope leads to definition error. This may be relaxed in the future, if we find suitable meaning. For example, eagerly initializing `@RequestScoped` beans typically only makes sense for _some_ beans, depending on the nature of the request (such as the URL in case of an HTTP request). My personal opinion is that such conditions are best expressed in code, which is already possible, because all beans can declare observer methods, which may include arbitrary code. `@Eager` is a shortcut for such observer in the most common scenario. It also serves as a direct replacement of EJB `@Startup`, which also only makes sense in case of application-wide beans (EJB `@Singleton`).
This annotation marks _auto-closeable_ beans. If the class of an instance of auto-closeable bean implements `AutoCloseable`, the `close()` method is called during bean destruction (after `@PreDestroy` callbacks or disposer method invocation, but before destroying dependent instances).
|
Just to check I have this right:
I'm having trouble working out the order of operations for auto-closable synthetic beans. I originally had this:
However, |
Correct.
Correct.
This is a bit more involved, but essentially correct. Note that "destroying an instance of a bean" is what happens during
The following is wrong. I covered synthetic beans above, but I'll cover the issues here as well:
No. There are no
No. There are no disposer methods for synthetic beans, synthetic beans are not producer methods. Instead, we call the disposer callback as configured through the Portable Extensions configurator API / through the Build Compatible Extensions API. If the user provided a custom
Hard NO!
Right, as mentioned above.
Right.
Right.
I think I covered this above. The main misconception comes from the nature of |
Aha, this was the bit that I was confused by, having previously had to do a custom It seemed odd to have an |
Fixes #876