openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1083867 - in /openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf: ConversationAwareViewHandler.java JSFUtil.java OwbApplicationFactory.java WebBeansPhaseListener.java
Date Mon, 21 Mar 2011 16:51:15 GMT
Author: struberg
Date: Mon Mar 21 16:51:14 2011
New Revision: 1083867

URL: http://svn.apache.org/viewvc?rev=1083867&view=rev
Log:
OWB-532 use BeanManagerImpl#inUse() instead of manual property

Modified:
    openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/ConversationAwareViewHandler.java
    openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/JSFUtil.java
    openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/OwbApplicationFactory.java
    openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/WebBeansPhaseListener.java

Modified: openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/ConversationAwareViewHandler.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/ConversationAwareViewHandler.java?rev=1083867&r1=1083866&r2=1083867&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/ConversationAwareViewHandler.java
(original)
+++ openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/ConversationAwareViewHandler.java
Mon Mar 21 16:51:14 2011
@@ -33,6 +33,8 @@ public class ConversationAwareViewHandle
 {
     private final ViewHandler delegate;
 
+    private Boolean owbApplication = null;
+
     public ConversationAwareViewHandler(ViewHandler delegate)
     {
         this.delegate = delegate;
@@ -44,7 +46,7 @@ public class ConversationAwareViewHandle
     @Override
     public String getActionURL(FacesContext context, String viewId)
     {
-        if(!JSFUtil.isOwbApplication())
+        if(!isOwbApplication())
         {
             return delegate.getActionURL(context, viewId);
         }
@@ -61,6 +63,16 @@ public class ConversationAwareViewHandle
         return url;
     }
 
+    private boolean isOwbApplication()
+    {
+        if (owbApplication == null)
+        {
+            owbApplication = Boolean.valueOf(WebBeansContext.getInstance().getBeanManagerImpl().isInUse());
+        }
+
+        return owbApplication.booleanValue();
+    }
+
     /**
      * {@inheritDoc}
      */
@@ -69,7 +81,7 @@ public class ConversationAwareViewHandle
             Map<String, List<String>> parameters, boolean includeViewParams)
     {
         
-        if(!JSFUtil.isOwbApplication())
+        if(!isOwbApplication())
         {
             return delegate.getRedirectURL(context, viewId, parameters, includeViewParams);
         }

Modified: openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/JSFUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/JSFUtil.java?rev=1083867&r1=1083866&r2=1083867&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/JSFUtil.java (original)
+++ openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/JSFUtil.java Mon
Mar 21 16:51:14 2011
@@ -18,16 +18,11 @@
  */
 package org.apache.webbeans.jsf;
 
-import javax.faces.application.Application;
-import javax.faces.application.FacesMessage;
-import javax.faces.application.ViewHandler;
 import javax.faces.component.UIViewRoot;
 import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
-import javax.servlet.ServletContext;
 import javax.servlet.http.HttpSession;
 
-import org.apache.webbeans.config.OpenWebBeansConfiguration;
 import org.apache.webbeans.util.Asserts;
 
 
@@ -67,46 +62,6 @@ public final class JSFUtil
         return null; 
     }
 
-    public static boolean isPostBack()
-    {
-        return getCurrentFacesContext().getRenderKit().getResponseStateManager().isPostback(getCurrentFacesContext());
-    }
-
-    /**
-     * @return the viewId of the viewRoot, e.g. '/user/menu.xhtml'
-     */
-    public static String getViewId()
-    {
-        UIViewRoot viewRoot = getCurrentFacesContext().getViewRoot();
-        if (viewRoot == null)
-        {
-            return null;
-        }
-        return viewRoot.getViewId();
-    }
-
-    public static ViewHandler getViewHandler()
-    {
-        return getCurrentFacesContext().getApplication().getViewHandler();
-    }
-
-    public static Application getApplication()
-    {
-        FacesContext context = getCurrentFacesContext();
-        if(context != null)
-        {
-            return context.getApplication();
-        }
-        
-        return null;
-    }
-    
-    public static void addInfoMessage(String message)
-    {
-        FacesMessage fm = new FacesMessage(FacesMessage.SEVERITY_INFO,message,"");
-        getCurrentFacesContext().addMessage(null, fm);
-    }
-
     public static String getRedirectViewIdWithCid(String redirectId, String cid)
     {
         Asserts.assertNotNull(redirectId, "redirectId parameter can not be null");      
 
@@ -188,25 +143,4 @@ public final class JSFUtil
         return cid;
     }
 
-    /** use {@link org.apache.webbeans.container.BeanManagerImpl#isInUse()} instead */
-    @Deprecated
-    public static boolean isOwbApplication()
-    {
-        ServletContext context = null;
-        if(getExternalContext() != null)
-        {
-            context = (ServletContext) getExternalContext().getContext();
-        }
-        
-        if(context != null)
-        {
-            Object value = context.getAttribute(OpenWebBeansConfiguration.PROPERTY_OWB_APPLICATION);
-            if(value != null)
-            {
-                return Boolean.valueOf(value.toString());
-            }            
-        }
-        
-        return false;
-    }
 }

Modified: openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/OwbApplicationFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/OwbApplicationFactory.java?rev=1083867&r1=1083866&r2=1083867&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/OwbApplicationFactory.java
(original)
+++ openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/OwbApplicationFactory.java
Mon Mar 21 16:51:14 2011
@@ -18,6 +18,8 @@
  */
 package org.apache.webbeans.jsf;
 
+import org.apache.webbeans.config.WebBeansContext;
+
 import javax.faces.application.Application;
 import javax.faces.application.ApplicationFactory;
 
@@ -35,7 +37,7 @@ public class OwbApplicationFactory exten
     @Override
     public Application getApplication()
     {
-        if(!JSFUtil.isOwbApplication())
+        if(!WebBeansContext.getInstance().getBeanManagerImpl().isInUse())
         {
             return wrapped.getApplication();
         }

Modified: openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/WebBeansPhaseListener.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/WebBeansPhaseListener.java?rev=1083867&r1=1083866&r2=1083867&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/WebBeansPhaseListener.java
(original)
+++ openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/WebBeansPhaseListener.java
Mon Mar 21 16:51:14 2011
@@ -44,7 +44,9 @@ public class WebBeansPhaseListener imple
 
     /**Logger instance*/
     private final WebBeansLogger logger = WebBeansLogger.getLogger(WebBeansPhaseListener.class);
-    
+
+    private Boolean owbApplication = null;
+
     /**
      * {@inheritDoc}
      */
@@ -53,7 +55,7 @@ public class WebBeansPhaseListener imple
         if (phaseEvent.getPhaseId().equals(PhaseId.RENDER_RESPONSE) ||
                 phaseEvent.getFacesContext().getResponseComplete())
         {
-            if(!JSFUtil.isOwbApplication())
+            if(!isOwbApplication())
             {
                 return;
             }
@@ -87,7 +89,7 @@ public class WebBeansPhaseListener imple
      */
     public void beforePhase(PhaseEvent phaseEvent)
     {
-        if (phaseEvent.getPhaseId().equals(PhaseId.RESTORE_VIEW) && JSFUtil.isOwbApplication())
+        if (phaseEvent.getPhaseId().equals(PhaseId.RESTORE_VIEW) && isOwbApplication())
         {
             //It looks for cid parameter in the JSF request.
             //If request contains cid, then it must restore conversation
@@ -140,4 +142,15 @@ public class WebBeansPhaseListener imple
     {
         return PhaseId.ANY_PHASE;
     }
+
+    private boolean isOwbApplication()
+    {
+        if (owbApplication == null)
+        {
+            owbApplication = Boolean.valueOf(WebBeansContext.getInstance().getBeanManagerImpl().isInUse());
+        }
+
+        return owbApplication.booleanValue();
+    }
+
 }



Mime
View raw message