myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject [myfaces] branch master updated: JSF3.0: added ExternalContext#release (https://github.com/eclipse-ee4j/mojarra/issues/4622)
Date Thu, 15 Aug 2019 11:52:47 GMT
This is an automated email from the ASF dual-hosted git repository.

tandraschko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces.git


The following commit(s) were added to refs/heads/master by this push:
     new 02632b0  JSF3.0: added ExternalContext#release (https://github.com/eclipse-ee4j/mojarra/issues/4622)
02632b0 is described below

commit 02632b043881dac9de46a48ebd8319c1f3255df9
Author: Thomas Andraschko <tandraschko@apache.org>
AuthorDate: Thu Aug 15 13:52:39 2019 +0200

    JSF3.0: added ExternalContext#release (https://github.com/eclipse-ee4j/mojarra/issues/4622)
---
 .../java/javax/faces/context/ExternalContext.java  |  4 +++
 .../myfaces/cdi/view/ViewScopeBeanHolder.java      |  5 ++--
 .../myfaces/context/FacesContextFactoryImpl.java   | 23 ++-------------
 .../myfaces/context/ReleasableExternalContext.java | 34 ----------------------
 .../myfaces/context/servlet/FacesContextImpl.java  |  5 ++--
 .../context/servlet/FacesContextImplBase.java      |  7 ++---
 .../servlet/ServletExternalContextImplBase.java    |  2 --
 .../context/servlet/StartupFacesContextImpl.java   |  4 +--
 .../myfaces/flow/cdi/FlowScopeBeanHolder.java      |  5 ++--
 .../myfaces/webapp/AbstractFacesInitializer.java   |  3 +-
 .../myfaces/webapp/MyFacesHttpSessionListener.java |  4 +--
 .../myfaces/context/flash/FlashImplTest.java       |  5 ++++
 .../myfaces/test/mock/MockExternalContext.java     |  6 ++++
 13 files changed, 29 insertions(+), 78 deletions(-)

diff --git a/api/src/main/java/javax/faces/context/ExternalContext.java b/api/src/main/java/javax/faces/context/ExternalContext.java
index 32ae2f5..f812e30 100755
--- a/api/src/main/java/javax/faces/context/ExternalContext.java
+++ b/api/src/main/java/javax/faces/context/ExternalContext.java
@@ -805,4 +805,8 @@ public abstract class ExternalContext
      */
     public abstract String encodeWebsocketURL(String url);
 
+    /**
+     * @since 3.0
+     */
+    public abstract void release(); 
 }
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeBeanHolder.java b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeBeanHolder.java
index 5aa67fa..d548a4b 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeBeanHolder.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeBeanHolder.java
@@ -35,7 +35,6 @@ import javax.servlet.ServletContext;
 import org.apache.myfaces.context.servlet.StartupFacesContextImpl;
 import org.apache.myfaces.context.servlet.StartupServletExternalContextImpl;
 import org.apache.myfaces.context.ExceptionHandlerImpl;
-import org.apache.myfaces.context.ReleasableExternalContext;
 
 /**
  *
@@ -145,7 +144,7 @@ public class ViewScopeBeanHolder implements Serializable
                         ExternalContext externalContext = new StartupServletExternalContextImpl(servletContext,
false);
                         ExceptionHandler exceptionHandler = new ExceptionHandlerImpl();
                         facesContext = new StartupFacesContextImpl(externalContext, 
-                                (ReleasableExternalContext) externalContext, exceptionHandler,
false);
+                                externalContext, exceptionHandler, false);
                         ViewScopeContextImpl.destroyAllActive(contextualStorage, facesContext);
                     }
                     finally
@@ -191,7 +190,7 @@ public class ViewScopeBeanHolder implements Serializable
                     ExternalContext externalContext = new StartupServletExternalContextImpl(servletContext,
false);
                     ExceptionHandler exceptionHandler = new ExceptionHandlerImpl();
                     facesContext = new StartupFacesContextImpl(externalContext, 
-                            (ReleasableExternalContext) externalContext, exceptionHandler,
false);
+                            externalContext, exceptionHandler, false);
                     for (ViewScopeContextualStorage contextualStorage : oldContextStorages.values())
                     {
                         ViewScopeContextImpl.destroyAllActive(contextualStorage, facesContext);
diff --git a/impl/src/main/java/org/apache/myfaces/context/FacesContextFactoryImpl.java b/impl/src/main/java/org/apache/myfaces/context/FacesContextFactoryImpl.java
index 9f812f8..76ba436 100755
--- a/impl/src/main/java/org/apache/myfaces/context/FacesContextFactoryImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/context/FacesContextFactoryImpl.java
@@ -153,27 +153,8 @@ public class FacesContextFactoryImpl extends FacesContextFactory implements
Rele
             }
         }
 
-        FacesContext facesContext;
-        if (externalContext instanceof ReleasableExternalContext)
-        {
-            facesContext = new FacesContextImpl(externalContext, (ReleasableExternalContext)
externalContext,
-                                                this, _applicationFactory, _renderKitFactory,

-                                                _partialViewContextFactory);
-        }
-        else if (defaultExternalContext != null && defaultExternalContext instanceof
ReleasableExternalContext)
-        {
-            facesContext = new FacesContextImpl(externalContext,
-                                                (ReleasableExternalContext) defaultExternalContext,
this,
-                                                _applicationFactory, _renderKitFactory, 
-                                                _partialViewContextFactory);
-        }
-        else
-        {
-            facesContext = new FacesContextImpl(externalContext, null, this,
-                                                _applicationFactory, _renderKitFactory, 
-                                                _partialViewContextFactory);
-        }
-
+        FacesContext facesContext = new FacesContextImpl(externalContext, defaultExternalContext,
this,
+            _applicationFactory, _renderKitFactory, _partialViewContextFactory);
         facesContext.setExceptionHandler(_exceptionHandlerFactory.getExceptionHandler());
 
         return facesContext;
diff --git a/impl/src/main/java/org/apache/myfaces/context/ReleasableExternalContext.java
b/impl/src/main/java/org/apache/myfaces/context/ReleasableExternalContext.java
deleted file mode 100644
index a1992f4..0000000
--- a/impl/src/main/java/org/apache/myfaces/context/ReleasableExternalContext.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.context;
-
-/**
- * Allows the FacesContextImpl to refer to the external context
- * polymorphically.
- *
- * @author  Stan Silvert (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-public interface ReleasableExternalContext
-{
-    /**
-     * Release resources that the ExternalContext is holding onto.
-     */
-    public void release();
-}
diff --git a/impl/src/main/java/org/apache/myfaces/context/servlet/FacesContextImpl.java b/impl/src/main/java/org/apache/myfaces/context/servlet/FacesContextImpl.java
index 468d4a8..e88891c 100755
--- a/impl/src/main/java/org/apache/myfaces/context/servlet/FacesContextImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/context/servlet/FacesContextImpl.java
@@ -44,7 +44,6 @@ import org.apache.myfaces.cdi.FacesScopeProvider;
 
 import org.apache.myfaces.util.ExternalSpecifications;
 import org.apache.myfaces.context.ReleasableFacesContextFactory;
-import org.apache.myfaces.context.ReleasableExternalContext;
 import org.apache.myfaces.util.lang.Assert;
 
 /**
@@ -101,7 +100,7 @@ public class FacesContextImpl extends FacesContextImplBase
      * @param facesContextFactory
      */
     public FacesContextImpl(final ExternalContext externalContext,
-            final ReleasableExternalContext defaultExternalContext , 
+            final ExternalContext defaultExternalContext , 
             final ReleasableFacesContextFactory facesContextFactory)
     {
         // setCurrentInstance is called in constructor of super class
@@ -111,7 +110,7 @@ public class FacesContextImpl extends FacesContextImplBase
     }
     
     public FacesContextImpl(final ExternalContext externalContext,
-            final ReleasableExternalContext defaultExternalContext , 
+            final ExternalContext defaultExternalContext , 
             final ReleasableFacesContextFactory facesContextFactory,
             final ApplicationFactory applicationFactory,
             final RenderKitFactory renderKitFactory,
diff --git a/impl/src/main/java/org/apache/myfaces/context/servlet/FacesContextImplBase.java
b/impl/src/main/java/org/apache/myfaces/context/servlet/FacesContextImplBase.java
index 6118f35..2da4b22 100644
--- a/impl/src/main/java/org/apache/myfaces/context/servlet/FacesContextImplBase.java
+++ b/impl/src/main/java/org/apache/myfaces/context/servlet/FacesContextImplBase.java
@@ -39,7 +39,6 @@ import javax.faces.render.RenderKit;
 import javax.faces.render.RenderKitFactory;
 
 import org.apache.myfaces.el.FacesELContext;
-import org.apache.myfaces.context.ReleasableExternalContext;
 import org.apache.myfaces.util.lang.Assert;
 import org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage; 
 
@@ -54,7 +53,7 @@ public abstract class FacesContextImplBase extends FacesContext
 {
     private Application _application;
     private ExternalContext _externalContext;
-    private ReleasableExternalContext _defaultExternalContext;
+    private ExternalContext _defaultExternalContext;
     private UIViewRoot _viewRoot;
     private RenderKitFactory _renderKitFactory;
     private ELContext _elContext;
@@ -79,7 +78,7 @@ public abstract class FacesContextImplBase extends FacesContext
      * Calls FacesContext.setCurrentInstance(this);
      */
     public FacesContextImplBase(final ExternalContext externalContext,
-            final ReleasableExternalContext defaultExternalContext)
+            final ExternalContext defaultExternalContext)
     {
         _externalContext = externalContext;
         _defaultExternalContext = defaultExternalContext;
@@ -90,7 +89,7 @@ public abstract class FacesContextImplBase extends FacesContext
     }
     
     public FacesContextImplBase(final ExternalContext externalContext,
-            final ReleasableExternalContext defaultExternalContext,
+            final ExternalContext defaultExternalContext,
             final ApplicationFactory applicationFactory,
             final RenderKitFactory renderKitFactory)
     {
diff --git a/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImplBase.java
b/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImplBase.java
index cbbbe62..b0ee9f0 100644
--- a/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImplBase.java
+++ b/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImplBase.java
@@ -28,7 +28,6 @@ import javax.faces.context.ExternalContext;
 import javax.faces.lifecycle.ClientWindow;
 import javax.servlet.ServletContext;
 
-import org.apache.myfaces.context.ReleasableExternalContext;
 import org.apache.myfaces.util.lang.Assert;
 
 /**
@@ -40,7 +39,6 @@ import org.apache.myfaces.util.lang.Assert;
  * @version $Revision$ $Date$
  */
 public abstract class ServletExternalContextImplBase extends ExternalContext
-        implements ReleasableExternalContext
 {
     
     private static final String INIT_PARAMETER_MAP_ATTRIBUTE = InitParameterMap.class.getName();
diff --git a/impl/src/main/java/org/apache/myfaces/context/servlet/StartupFacesContextImpl.java
b/impl/src/main/java/org/apache/myfaces/context/servlet/StartupFacesContextImpl.java
index feb61b8..49ea131 100644
--- a/impl/src/main/java/org/apache/myfaces/context/servlet/StartupFacesContextImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/context/servlet/StartupFacesContextImpl.java
@@ -29,8 +29,6 @@ import javax.faces.context.ResponseStream;
 import javax.faces.context.ResponseWriter;
 import javax.faces.event.PhaseId;
 
-import org.apache.myfaces.context.ReleasableExternalContext;
-
 /**
  * A FacesContext implementation which will be set as the current instance
  * during container startup and shutdown and which provides a basic set of
@@ -48,7 +46,7 @@ public class StartupFacesContextImpl extends FacesContextImplBase
     
     public StartupFacesContextImpl(
             ExternalContext externalContext, 
-            ReleasableExternalContext defaultExternalContext,
+            ExternalContext defaultExternalContext,
             ExceptionHandler exceptionHandler,
             boolean startup)
     {
diff --git a/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeBeanHolder.java b/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeBeanHolder.java
index cf3f764..1cfa439 100644
--- a/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeBeanHolder.java
+++ b/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeBeanHolder.java
@@ -47,7 +47,6 @@ import org.apache.myfaces.context.servlet.StartupServletExternalContextImpl;
 import org.apache.myfaces.flow.FlowUtils;
 import org.apache.myfaces.config.MyfacesConfig;
 import org.apache.myfaces.context.ExceptionHandlerImpl;
-import org.apache.myfaces.context.ReleasableExternalContext;
 
 
 /**
@@ -218,8 +217,8 @@ public class FlowScopeBeanHolder implements Serializable
                 {
                     ExternalContext externalContext = new StartupServletExternalContextImpl(servletContext,
false);
                     ExceptionHandler exceptionHandler = new ExceptionHandlerImpl();
-                    facesContext = new StartupFacesContextImpl(externalContext, 
-                            (ReleasableExternalContext) externalContext, exceptionHandler,
false);
+                    facesContext = new StartupFacesContextImpl(externalContext, externalContext,
exceptionHandler,
+                            false);
                     for (ContextualStorage contextualStorage : oldContextStorages.values())
                     {
                         FlowScopedContextImpl.destroyAllActive(contextualStorage);
diff --git a/impl/src/main/java/org/apache/myfaces/webapp/AbstractFacesInitializer.java b/impl/src/main/java/org/apache/myfaces/webapp/AbstractFacesInitializer.java
index 2177117..4a6ffb6 100644
--- a/impl/src/main/java/org/apache/myfaces/webapp/AbstractFacesInitializer.java
+++ b/impl/src/main/java/org/apache/myfaces/webapp/AbstractFacesInitializer.java
@@ -72,7 +72,6 @@ import org.apache.myfaces.spi.FacesFlowProviderFactory;
 import org.apache.myfaces.spi.ServiceProviderFinder;
 import org.apache.myfaces.spi.ServiceProviderFinderFactory;
 import org.apache.myfaces.view.facelets.ViewPoolProcessor;
-import org.apache.myfaces.context.ReleasableExternalContext;
 import org.apache.myfaces.util.lang.StringUtils;
 
 /**
@@ -502,7 +501,7 @@ public abstract class AbstractFacesInitializer implements FacesInitializer
         ExternalContext externalContext = new StartupServletExternalContextImpl(servletContext,
startup);
         ExceptionHandler exceptionHandler = new ExceptionHandlerImpl();
         FacesContext facesContext = new StartupFacesContextImpl(externalContext, 
-                (ReleasableExternalContext) externalContext, exceptionHandler, startup);
+                externalContext, exceptionHandler, startup);
         
         // If getViewRoot() is called during application startup or shutdown, 
         // it should return a new UIViewRoot with its locale set to Locale.getDefault().
diff --git a/impl/src/main/java/org/apache/myfaces/webapp/MyFacesHttpSessionListener.java
b/impl/src/main/java/org/apache/myfaces/webapp/MyFacesHttpSessionListener.java
index 68cd145..90f2d68 100644
--- a/impl/src/main/java/org/apache/myfaces/webapp/MyFacesHttpSessionListener.java
+++ b/impl/src/main/java/org/apache/myfaces/webapp/MyFacesHttpSessionListener.java
@@ -29,7 +29,6 @@ import org.apache.myfaces.context.servlet.StartupFacesContextImpl;
 import org.apache.myfaces.context.servlet.StartupServletExternalContextImpl;
 import org.apache.myfaces.spi.FacesFlowProvider;
 import org.apache.myfaces.spi.ViewScopeProvider;
-import org.apache.myfaces.context.ReleasableExternalContext;
 
 public class MyFacesHttpSessionListener implements HttpSessionListener
 {
@@ -84,8 +83,7 @@ public class MyFacesHttpSessionListener implements HttpSessionListener
                 ServletContext servletContext = event.getSession().getServletContext();
                 ExternalContext externalContext = new StartupServletExternalContextImpl(servletContext,
false);
                 ExceptionHandler exceptionHandler = new ExceptionHandlerImpl();
-                facesContext = new StartupFacesContextImpl(externalContext, 
-                        (ReleasableExternalContext) externalContext, exceptionHandler, false);
+                facesContext = new StartupFacesContextImpl(externalContext, externalContext,
exceptionHandler, false);
 
                 if (viewScopeProvider != null)
                 {
diff --git a/impl/src/test/java/org/apache/myfaces/context/flash/FlashImplTest.java b/impl/src/test/java/org/apache/myfaces/context/flash/FlashImplTest.java
index 692986e..31413ef 100644
--- a/impl/src/test/java/org/apache/myfaces/context/flash/FlashImplTest.java
+++ b/impl/src/test/java/org/apache/myfaces/context/flash/FlashImplTest.java
@@ -1108,6 +1108,11 @@ public class FlashImplTest extends AbstractJsfTestCase
         {
             this.secure = secure;
         }
+
+        @Override
+        public void release() {
+            
+        }
     }
 
 }
diff --git a/test/src/main/java/org/apache/myfaces/test/mock/MockExternalContext.java b/test/src/main/java/org/apache/myfaces/test/mock/MockExternalContext.java
index fc44799..34a2c41 100644
--- a/test/src/main/java/org/apache/myfaces/test/mock/MockExternalContext.java
+++ b/test/src/main/java/org/apache/myfaces/test/mock/MockExternalContext.java
@@ -105,5 +105,11 @@ public class MockExternalContext extends MockExternalContext20
     }
 
     // ------------------------------------------------- ExternalContext Methods
+
+    @Override
+    public void release()
+    {
+        
+    }
     
 }


Mime
View raw message