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

Fix Issue #362 - Improved Spring Boot Support #375

Closed
wants to merge 1 commit into from

Conversation

lincolnthree
Copy link
Member

This is a re-opened PR continued from #368 which was targeted at the now defunct develop branch.

@lincolnthree lincolnthree changed the title Fix Issue 362 - Improved Spring Boot Support Fix Issue #362 - Improved Spring Boot Support Oct 4, 2023
@lincolnthree
Copy link
Member Author

Link with #362

@Override
public void requestDestroyed(ServletRequestEvent event)
{
removeContext(event.getServletContext());
Copy link
Contributor

Choose a reason for hiding this comment

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

This would also remove the servlet context registered by contextInitialized, wouldn't it?

@larsgrefer
Copy link
Contributor

I think the RequestListener part is not necessary.

Spring already has an org.springframework.web.context.request.RequestContextListener and org.springframework.web.filter.RequestContextFilter which both catch the current request in a ThreadLocal which can be accessed as follows:

HttpServletRequest request = (HttpServletRequest) RequestContextHolder.currentRequestAttributes().resolveReference("request");

From there you could simply use this to get the ApplicationContext:

RequestContextUtils.findWebApplicationContext(request);

@lincolnthree
Copy link
Member Author

Merged into all relevant branches! Thanks everyone for your patience.

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