You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by jl...@apache.org on 2013/11/04 16:54:03 UTC
svn commit: r1538652 -
/openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationListener.java
Author: jlmonteiro
Date: Mon Nov 4 15:54:03 2013
New Revision: 1538652
URL: http://svn.apache.org/r1538652
Log:
Fixing bad formatting to match OWB rules
Modified:
openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationListener.java
Modified: openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationListener.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationListener.java?rev=1538652&r1=1538651&r2=1538652&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationListener.java (original)
+++ openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationListener.java Mon Nov 4 15:54:03 2013
@@ -43,24 +43,21 @@ import java.util.logging.Logger;
/**
* Initializing the beans container for using in an web application
* environment.
- * <p/>
+ *
* This is the main entry point for starting the CDI container
* for a servlet.
- * <p/>
- * <p/>
+ *
+ *
* If you have a container with < Servlet-2.5 then use
* {@link WebBeansConfigurationFilter} and {@link WebBeansConfigurationHttpSessionListener}
* instead.
*/
-public class WebBeansConfigurationListener implements ServletContextListener, ServletRequestListener, HttpSessionListener {
- /**
- * Logger instance
- */
+public class WebBeansConfigurationListener implements ServletContextListener, ServletRequestListener, HttpSessionListener
+{
+ /**Logger instance*/
private static final Logger logger = WebBeansLoggerFacade.getLogger(WebBeansConfigurationListener.class);
- /**
- * Manages the container lifecycle
- */
+ /**Manages the container lifecycle*/
protected ContainerLifecycle lifeCycle = null;
protected FailOverService failoverService = null;
@@ -69,7 +66,8 @@ public class WebBeansConfigurationListen
/**
* Default constructor
*/
- public WebBeansConfigurationListener() {
+ public WebBeansConfigurationListener()
+ {
webBeansContext = WebBeansContext.getInstance();
failoverService = webBeansContext.getService(FailOverService.class);
}
@@ -78,17 +76,21 @@ public class WebBeansConfigurationListen
* {@inheritDoc}
*/
@Override
- public void contextInitialized(ServletContextEvent event) {
+ public void contextInitialized(ServletContextEvent event)
+ {
this.lifeCycle = webBeansContext.getService(ContainerLifecycle.class);
- try {
- this.lifeCycle.startApplication(event);
- } catch (Exception e) {
- logger.log(Level.SEVERE,
- WebBeansLoggerFacade.constructMessage(
- OWBLogConst.ERROR_0018,
- ServletCompatibilityUtil.getServletInfo(event.getServletContext())));
- WebBeansUtil.throwRuntimeExceptions(e);
+ try
+ {
+ this.lifeCycle.startApplication(event);
+ }
+ catch (Exception e)
+ {
+ logger.log(Level.SEVERE,
+ WebBeansLoggerFacade.constructMessage(
+ OWBLogConst.ERROR_0018,
+ ServletCompatibilityUtil.getServletInfo(event.getServletContext())));
+ WebBeansUtil.throwRuntimeExceptions(e);
}
}
@@ -97,7 +99,8 @@ public class WebBeansConfigurationListen
* {@inheritDoc}
*/
@Override
- public void contextDestroyed(ServletContextEvent event) {
+ public void contextDestroyed(ServletContextEvent event)
+ {
this.lifeCycle.stopApplication(event);
this.lifeCycle = null;
@@ -109,14 +112,17 @@ public class WebBeansConfigurationListen
* {@inheritDoc}
*/
@Override
- public void requestDestroyed(ServletRequestEvent event) {
- if (logger.isLoggable(Level.FINE)) {
+ public void requestDestroyed(ServletRequestEvent event)
+ {
+ if (logger.isLoggable(Level.FINE))
+ {
logger.log(Level.FINE, "Destroying a request : [{0}]", event == null ? "null" : event.getServletRequest().getRemoteAddr());
}
// clean up the EL caches after each request
ELContextStore elStore = ELContextStore.getInstance(false);
- if (elStore != null) {
+ if (elStore != null)
+ {
elStore.destroyELContextStore();
}
@@ -129,7 +135,8 @@ public class WebBeansConfigurationListen
* Ensures that all ThreadLocals, which could have been set in this
* requests Thread, are removed in order to prevent memory leaks.
*/
- private void cleanupRequestThreadLocals() {
+ private void cleanupRequestThreadLocals()
+ {
WebContextsService.removeThreadLocals();
}
@@ -137,9 +144,12 @@ public class WebBeansConfigurationListen
* {@inheritDoc}
*/
@Override
- public void requestInitialized(ServletRequestEvent event) {
- try {
- if (logger.isLoggable(Level.FINE)) {
+ public void requestInitialized(ServletRequestEvent event)
+ {
+ try
+ {
+ if (logger.isLoggable(Level.FINE))
+ {
logger.log(Level.FINE, "Starting a new request : [{0}]", event == null ? "null" : event.getServletRequest().getRemoteAddr());
}
@@ -147,7 +157,9 @@ public class WebBeansConfigurationListen
// we don't initialise the Session here but do it lazily if it gets requested
// the first time. See OWB-457
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
logger.log(Level.SEVERE,
WebBeansLoggerFacade.constructMessage(OWBLogConst.ERROR_0019, event == null ? "null" : event.getServletRequest()));
WebBeansUtil.throwRuntimeExceptions(e);
@@ -158,13 +170,18 @@ public class WebBeansConfigurationListen
* {@inheritDoc}
*/
@Override
- public void sessionCreated(HttpSessionEvent event) {
- try {
- if (logger.isLoggable(Level.FINE)) {
+ public void sessionCreated(HttpSessionEvent event)
+ {
+ try
+ {
+ if (logger.isLoggable(Level.FINE))
+ {
logger.log(Level.FINE, "Starting a session with session id : [{0}]", event.getSession().getId());
}
this.lifeCycle.getContextService().startContext(SessionScoped.class, event.getSession());
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
logger.log(Level.SEVERE,
WebBeansLoggerFacade.constructMessage(OWBLogConst.ERROR_0020, event.getSession()));
WebBeansUtil.throwRuntimeExceptions(e);
@@ -175,8 +192,10 @@ public class WebBeansConfigurationListen
* {@inheritDoc}
*/
@Override
- public void sessionDestroyed(HttpSessionEvent event) {
- if (logger.isLoggable(Level.FINE)) {
+ public void sessionDestroyed(HttpSessionEvent event)
+ {
+ if (logger.isLoggable(Level.FINE))
+ {
logger.log(Level.FINE, "Destroying a session with session id : [{0}]", event.getSession().getId());
}
boolean mustDestroy = ensureRequestScope();
@@ -184,13 +203,16 @@ public class WebBeansConfigurationListen
this.lifeCycle.getContextService().endContext(SessionScoped.class, event.getSession());
this.lifeCycle.getContextService().endContext(ConversationScoped.class, event.getSession());
- if (mustDestroy) {
+ if (mustDestroy)
+ {
requestDestroyed(null);
}
}
- private boolean ensureRequestScope() {
- if (!this.lifeCycle.getContextService().getCurrentContext(RequestScoped.class).isActive()) {
+ private boolean ensureRequestScope()
+ {
+ if (!this.lifeCycle.getContextService().getCurrentContext(RequestScoped.class).isActive())
+ {
requestInitialized(null);
return true;
}