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

Introduce observable CDI events representing container state. #543

Merged
merged 1 commit into from Oct 19, 2021

Conversation

manovotn
Copy link
Contributor

Fixes #496

@manovotn manovotn requested a review from Ladicek October 14, 2021 13:22
@Ladicek
Copy link
Contributor

Ladicek commented Oct 14, 2021

Maybe move the event types to jakarta.enterprise.event?

@manovotn
Copy link
Contributor Author

Maybe move the event types to jakarta.enterprise.event?

Hmm, I thought about that location as well. Didn't have a strong preference to be fair, so yea, we can do that.

@manovotn manovotn force-pushed the issue496 branch 2 times, most recently from a0abfd0 to 1b66775 Compare October 15, 2021 11:20
@manovotn
Copy link
Contributor Author

As usual, thanks for your review @Ladicek. PR is now updated; all comments should be addressed and I have also moved the classes from util to event package.

@manovotn manovotn requested a review from Ladicek October 15, 2021 11:21
@manovotn
Copy link
Contributor Author

Also CC @mkouba as an FYI because you had some comments in the original issue (#496) and we discussed this recently.

@Ladicek
Copy link
Contributor

Ladicek commented Oct 15, 2021

Otherwise LGTM.

@Ladicek
Copy link
Contributor

Ladicek commented Oct 16, 2021

Actually I just realized one thing: we should add a section about this to CDI Full where we specify the relationship of these events to container lifecycle events (that may only be declared on Portable Extensions), notably AfterDeploymentValidation vs Startup and BeforeShutdown vs. Shutdown.

Now I'm not sure what's the relationship between @Initialized(ApplicationScoped.class) and AfterDeploymentValidation, but I think Startup should probably be after AfterDeploymentValidation. Similarly, I'm not sure what's the relationship between @BeforeDestroyed(ApplicationScoped.class) and BeforeShutdown, but I think that Shutdown should be before BeforeShutdown. But that's a naive interpretation and probably needs more thinking.

@manovotn
Copy link
Contributor Author

From specification on BeforeShutdown event:

The container must fire a final event after it has finished processing requests and destroyed all contexts.

In other words, this is a very late event where you cannot do anything with contexts and beans anymore. This itself IMO implies the ordering.

Similarly, there is following text for AfterDeploymentValidation:

The container must fire an event after it has validated that there are no deployment problems and before creating contexts or processing requests.

This is a very early event where you lack contexts, so even before @Initialized event for app context. Again, this IMO defined ordering sufficiently.

@Ladicek does the above make sense?

@Ladicek
Copy link
Contributor

Ladicek commented Oct 18, 2021

Ah ah very nice, so the existing specification already implies the ordering that I described. Great!

@manovotn
Copy link
Contributor Author

Ah ah very nice, so the existing specification already implies the ordering that I described. Great!

Meaning we can merge this? :-)

@@ -596,4 +596,33 @@ As specified in <<builtin_contexts>>, contexts associated with built-in normal s
* Otherwise, if the observer method is any other kind of transactional observer method, it is called in an unspecified transaction context, but with the same lifecycle contexts as the transaction that just completed.
* Otherwise, the observer method is called in the same transaction context and lifecycle contexts as the invocation of `Event.fire()` or `BeanManager.getEvent()`.

[[observable_container_lifecycle_events]]

=== Observable container lifecycle events
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since "Container lifecycle events" belong to Portable Extensions, should we call these differently? Maybe "Application lifecycle events"? The Packaging and Deployment chapter has sections "Application initialization lifecycle" and "Application shutdown lifecycle", which is a nice match. (These sections don't have to refer to these new event types, as you described.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I deliberately chose this name because it is under Events section and it actually describes container lifecycle because ATM we cannot guarantee the whole app lifecycle which IMO makes "Application initialization lifecycle" a bad choice.

If you really dislike current naming then how about Observable container state events?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough.

@Ladicek
Copy link
Contributor

Ladicek commented Oct 18, 2021

I thought we wanted @mkouba to also take a look? :-)

@manovotn
Copy link
Contributor Author

I am going to merge this. @mkouba if you have any comments, please feel free to drop them here even after merge.

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.

add a portable event corresponding to application startup
2 participants