You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ta...@apache.org on 2021/10/25 14:59:12 UTC

[myfaces] branch master updated: MYFACES-4394

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 b6fc668  MYFACES-4394
b6fc668 is described below

commit b6fc66814e50b6210b08d5987da278d1f4198b4a
Author: Thomas Andraschko <ta...@apache.org>
AuthorDate: Mon Oct 25 16:59:04 2021 +0200

    MYFACES-4394
---
 .../apache/myfaces/cdi/FacesArtifactProducer.java  | 41 ++++++++++++----------
 .../implicitobject/ImplicitObjectResolver.java     |  6 ++++
 2 files changed, 29 insertions(+), 18 deletions(-)

diff --git a/impl/src/main/java/org/apache/myfaces/cdi/FacesArtifactProducer.java b/impl/src/main/java/org/apache/myfaces/cdi/FacesArtifactProducer.java
index bbfeffb..5702f63 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/FacesArtifactProducer.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/FacesArtifactProducer.java
@@ -92,14 +92,6 @@ public class FacesArtifactProducer
     {
        return FacesContext.getCurrentInstance();
     }
-    
-    @Produces
-    @Named("request")
-    @FacesScoped 
-    public Object getRequest()
-    {
-       return FacesContext.getCurrentInstance().getExternalContext().getRequest();
-    }
 
     @Produces
     @Named("externalContext")
@@ -188,17 +180,8 @@ public class FacesArtifactProducer
         return FacesContext.getCurrentInstance().getViewRoot();
     }
 
-    @Produces
-    @Named("session")
-    @FacesScoped
-    public Object getSession()
-    {
-        return FacesContext.getCurrentInstance().getExternalContext().getSession(false);
-    }
-
-   
     /*
-    The spec actually forces us the use producers for "cc" and "component but it leads to a bad performance.
+    The spec actually forces us the use producers for "cc" and "component" but it leads to a bad performance.
     Also @Inject UIComponent doesn't make sense and wouldn't work correctly if we don't create a own "ComponentScoped"
     or something.
     We will still use ELResolvers for this - see ImplicitObjectResolver#makeResolverForFacesCDI().
@@ -252,4 +235,26 @@ public class FacesArtifactProducer
         String channel = push.channel().isEmpty() ? ip.getMember().getName() : push.channel();
         return new PushContextImpl(channel);
     }
+
+    /*
+    The spec actually forces us the use producers for "session" and "request" but this conflicts with CDI spec actually,
+    because CDI is responsible for producing HttpServletRequest and HttpSession
+    We will still use ELResolvers for this - see ImplicitObjectResolver#makeResolverForFacesCDI().
+    /*
+    @Produces
+    @Named("session")
+    @FacesScoped
+    public Object getSession()
+    {
+        return FacesContext.getCurrentInstance().getExternalContext().getSession(false);
+    }
+
+    @Produces
+    @Named("request")
+    @FacesScoped 
+    public Object getRequest()
+    {
+       return FacesContext.getCurrentInstance().getExternalContext().getRequest();
+    }
+    /*
 }
diff --git a/impl/src/main/java/org/apache/myfaces/el/resolver/implicitobject/ImplicitObjectResolver.java b/impl/src/main/java/org/apache/myfaces/el/resolver/implicitobject/ImplicitObjectResolver.java
index cc6f005..777a315 100644
--- a/impl/src/main/java/org/apache/myfaces/el/resolver/implicitobject/ImplicitObjectResolver.java
+++ b/impl/src/main/java/org/apache/myfaces/el/resolver/implicitobject/ImplicitObjectResolver.java
@@ -96,6 +96,12 @@ public class ImplicitObjectResolver extends ELResolver
         io = new CompositeComponentImplicitObject();
         forFacesCDIList.put(io.getName(), io);
         
+        io = new RequestImplicitObject();
+        forFacesCDIList.put(io.getName(), io);
+ 
+        io = new SessionImplicitObject();
+        forFacesCDIList.put(io.getName(), io);
+
         return new ImplicitObjectResolver(forFacesCDIList);
     }