Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
created non-static version of bean container
- Loading branch information
1 parent
7aeeb6f
commit 79f9766
Showing
8 changed files
with
143 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...urce/springintegration/servletsupport/ApplicationContextFinderServletContextListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,30 @@ | |||
package org.cdisource.springintegration.servletsupport; | |||
|
|||
import javax.servlet.ServletContextEvent; | |||
import javax.servlet.ServletContextListener; | |||
import javax.servlet.annotation.WebListener; | |||
|
|||
import org.cdisource.springintegration.springsupport.ApplicationContextLocator; | |||
import org.cdisource.springintegration.springsupport.ApplicationContextLocatorImpl; | |||
import org.cdisource.springintegration.springsupport.ApplicationContextLocatorManager; | |||
import org.springframework.web.context.WebApplicationContext; | |||
import org.springframework.web.context.support.WebApplicationContextUtils; | |||
|
|||
@WebListener | |||
public class ApplicationContextFinderServletContextListener implements ServletContextListener { | |||
|
|||
|
|||
@Override | |||
public void contextInitialized(ServletContextEvent sce) { | |||
WebApplicationContext requiredWebApplicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(sce.getServletContext()); | |||
ApplicationContextLocatorImpl.putContext(requiredWebApplicationContext); | |||
ApplicationContextLocator applicationContextLocator = ApplicationContextLocatorManager.getInstance(); | |||
sce.getServletContext().setAttribute(ApplicationContextLocator.class.getName(), applicationContextLocator); | |||
} | |||
|
|||
@Override | |||
public void contextDestroyed(ServletContextEvent sce) { | |||
sce.getServletContext().setAttribute(ApplicationContextLocator.class.getName(), null); | |||
} | |||
|
|||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,17 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
|
|||
<web-fragment version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd"> | |||
|
|||
<name>Spring CDI Bridge</name> | |||
|
|||
<ordering><after><others/></after></ordering> | |||
|
|||
<listener> | |||
<display-name></display-name> | |||
|
|||
<listener-class>org.cdisource.springintegration.servletsupport.ApplicationContextFinderServletContextListener</listener-class> | |||
|
|||
</listener> | |||
|
|||
|
|||
</web-fragment> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
web/src/main/java/org/cdisource/web/CDIServletContextListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,23 @@ | |||
package org.cdisource.web; | |||
|
|||
import javax.servlet.ServletContextEvent; | |||
import javax.servlet.ServletContextListener; | |||
import javax.servlet.annotation.WebListener; | |||
|
|||
import org.cdisource.beancontainer.BeanContainer; | |||
import org.cdisource.beancontainer.BeanContainerManager; | |||
|
|||
@WebListener | |||
public class CDIServletContextListener implements ServletContextListener { | |||
|
|||
@Override | |||
public void contextInitialized(ServletContextEvent sce) { | |||
sce.getServletContext().setAttribute(BeanContainer.class.getName(), BeanContainerManager.getInstance()); | |||
} | |||
|
|||
@Override | |||
public void contextDestroyed(ServletContextEvent sce) { | |||
sce.getServletContext().setAttribute(BeanContainer.class.getName(), null); | |||
} | |||
|
|||
} |