You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ss...@apache.org on 2006/05/29 05:59:49 UTC
svn commit: r410018 [4/4] - in /myfaces/core/trunk:
api/src/main/java/javax/faces/application/
api/src/main/java/javax/faces/component/
api/src/main/java/javax/faces/context/
api/src/main/java/javax/faces/convert/ api/src/main/java/javax/faces/el/
api/...
Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/CookieImplicitObject.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/CookieImplicitObject.java?rev=410018&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/CookieImplicitObject.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/CookieImplicitObject.java Sun May 28 20:59:46 2006
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.el.unified.resolver.implicitobject;
+
+import java.beans.FeatureDescriptor;
+import java.util.Map;
+import javax.el.ELContext;
+
+/**
+ * Encapsulates information needed by the ImplicitObjectResolver
+ *
+ * @author Stan Silvert
+ */
+public class CookieImplicitObject extends ImplicitObject {
+
+ private static final String NAME = "cookie".intern();
+
+ /** Creates a new instance of CookieImplicitObject */
+ public CookieImplicitObject() {
+ }
+
+ public Object getValue(ELContext context) {
+ return externalContext(context).getRequestCookieMap();
+ }
+
+ public String getName() {
+ return NAME;
+ }
+
+ public Class getType() {
+ return null;
+ }
+
+ public FeatureDescriptor getDescriptor() {
+ return makeDescriptor(NAME,
+ "Map whose keys are a set of cookie names in the current request",
+ Map.class);
+ }
+
+}
Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/FacesContextImplicitObject.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/FacesContextImplicitObject.java?rev=410018&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/FacesContextImplicitObject.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/FacesContextImplicitObject.java Sun May 28 20:59:46 2006
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.el.unified.resolver.implicitobject;
+
+import java.beans.FeatureDescriptor;
+import javax.el.ELContext;
+import javax.faces.context.FacesContext;
+
+/**
+ * Encapsulates information needed by the ImplicitObjectResolver
+ *
+ * @author Stan Silvert
+ */
+public class FacesContextImplicitObject extends ImplicitObject {
+
+ private static final String NAME = "facesContext".intern();
+
+ /** Creates a new instance of FacesContextImplicitObject */
+ public FacesContextImplicitObject() {
+ }
+
+ public String getName() {
+ return NAME;
+ }
+
+ public Object getValue(ELContext context) {
+ return facesContext(context);
+ }
+
+ public Class getType() {
+ return null;
+ }
+
+ public FeatureDescriptor getDescriptor() {
+ return makeDescriptor(NAME,
+ "Per-request information for a JSF request",
+ FacesContext.class);
+ }
+
+}
Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/HeaderImplicitObject.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/HeaderImplicitObject.java?rev=410018&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/HeaderImplicitObject.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/HeaderImplicitObject.java Sun May 28 20:59:46 2006
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.el.unified.resolver.implicitobject;
+
+import java.beans.FeatureDescriptor;
+import java.util.Map;
+import javax.el.ELContext;
+
+/**
+ * Encapsulates information needed by the ImplicitObjectResolver
+ *
+ * @author Stan Silvert
+ */
+public class HeaderImplicitObject extends ImplicitObject {
+
+ private static final String NAME = "header".intern();
+
+ /** Creates a new instance of HeaderImplicitObject */
+ public HeaderImplicitObject() {
+ }
+
+ public Object getValue(ELContext context) {
+ return externalContext(context).getRequestHeaderMap();
+ }
+
+ public String getName() {
+ return NAME;
+ }
+
+ public Class getType() {
+ return null;
+ }
+
+ public FeatureDescriptor getDescriptor() {
+ return makeDescriptor(NAME,
+ "Map whose keys are a set of request header names in the current request",
+ Map.class);
+ }
+
+}
Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/HeaderValuesImplicitObject.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/HeaderValuesImplicitObject.java?rev=410018&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/HeaderValuesImplicitObject.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/HeaderValuesImplicitObject.java Sun May 28 20:59:46 2006
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.el.unified.resolver.implicitobject;
+
+import java.beans.FeatureDescriptor;
+import java.util.Map;
+import javax.el.ELContext;
+
+/**
+ * Encapsulates information needed by the ImplicitObjectResolver
+ *
+ * @author Stan Silvert
+ */
+public class HeaderValuesImplicitObject extends ImplicitObject {
+
+ private static final String NAME = "headerValues".intern();
+
+ /** Creates a new instance of HeaderValuesImplicitObject */
+ public HeaderValuesImplicitObject() {
+ }
+
+ public Object getValue(ELContext context) {
+ return externalContext(context).getRequestHeaderValuesMap();
+ }
+
+ public String getName() {
+ return NAME;
+ }
+
+ public Class getType() {
+ return null;
+ }
+
+ public FeatureDescriptor getDescriptor() {
+ return makeDescriptor(NAME,
+ "Map whose keys are a set of request header names and whose values are all of the values (of type String[]) for each header name.",
+ Map.class);
+ }
+
+}
Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/ImplicitObject.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/ImplicitObject.java?rev=410018&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/ImplicitObject.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/ImplicitObject.java Sun May 28 20:59:46 2006
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.el.unified.resolver.implicitobject;
+
+import java.beans.FeatureDescriptor;
+import javax.el.ELContext;
+import javax.el.ELResolver;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+
+/**
+ * Implementors of this class encapsulate the information needed to resolve
+ * the implicit object.
+ *
+ * @author Stan Silvert
+ */
+public abstract class ImplicitObject {
+
+ public abstract Object getValue(ELContext context);
+
+ public abstract FeatureDescriptor getDescriptor();
+
+ /**
+ * Returns an interned String representing the name of the
+ * implicit object.
+ */
+ public abstract String getName();
+
+ /**
+ * Returns the most general type allowed for a future call to setValue()
+ */
+ public abstract Class getType();
+
+ protected FeatureDescriptor makeDescriptor(String name,
+ String description,
+ Class elResolverType) {
+ FeatureDescriptor fd = new FeatureDescriptor();
+ fd.setValue(ELResolver.RESOLVABLE_AT_DESIGN_TIME, Boolean.TRUE);
+ fd.setValue(ELResolver.TYPE, elResolverType);
+ fd.setName(name);
+ fd.setDisplayName(name);
+ fd.setShortDescription(description);
+ fd.setExpert(false);
+ fd.setHidden(false);
+ fd.setPreferred(true);
+ return fd;
+ }
+
+ // get the FacesContext from the ELContext
+ protected FacesContext facesContext(ELContext context) {
+ return (FacesContext)context.getContext(FacesContext.class);
+ }
+
+ protected ExternalContext externalContext(ELContext context) {
+ return facesContext(context).getExternalContext();
+ }
+
+}
Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/ImplicitObjectResolver.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/ImplicitObjectResolver.java?rev=410018&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/ImplicitObjectResolver.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/ImplicitObjectResolver.java Sun May 28 20:59:46 2006
@@ -0,0 +1,182 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.el.unified.resolver.implicitobject;
+
+import java.beans.FeatureDescriptor;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.ELResolver;
+import javax.el.PropertyNotFoundException;
+import javax.el.PropertyNotWritableException;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+
+/**
+ * See JSF 1.2 spec sections 5.6.1.1 and 5.6.2.1
+ *
+ * @author Stan Silvert
+ */
+public class ImplicitObjectResolver extends ELResolver {
+
+ private List<ImplicitObject> implicitObjects;
+
+ /**
+ * Static factory for an ELResolver for resolving implicit objects in JSPs.
+ * See JSF 1.2 spec section 5.6.1.1
+ */
+ public static ELResolver makeResolverForJSP() {
+ List<ImplicitObject> forJSPList = new ArrayList<ImplicitObject>(2);
+ forJSPList.add(new FacesContextImplicitObject());
+ forJSPList.add(new ViewImplicitObject());
+ return new ImplicitObjectResolver(forJSPList);
+ }
+
+ /**
+ * Static factory for an ELResolver for resolving implicit objects in all of Faces.
+ * See JSF 1.2 spec section 5.6.1.2
+ */
+ public static ELResolver makeResolverForFaces() {
+ List<ImplicitObject> forFacesList = new ArrayList<ImplicitObject>(14);
+ forFacesList.add(new ApplicationImplicitObject());
+ forFacesList.add(new ApplicationScopeImplicitObject());
+ forFacesList.add(new CookieImplicitObject());
+ forFacesList.add(new FacesContextImplicitObject());
+ forFacesList.add(new HeaderImplicitObject());
+ forFacesList.add(new HeaderValuesImplicitObject());
+ forFacesList.add(new InitParamImplicitObject());
+ forFacesList.add(new ParamImplicitObject());
+ forFacesList.add(new ParamValuesImplicitObject());
+ forFacesList.add(new RequestImplicitObject());
+ forFacesList.add(new RequestScopeImplicitObject());
+ forFacesList.add(new SessionImplicitObject());
+ forFacesList.add(new SessionScopeImplicitObject());
+ forFacesList.add(new ViewImplicitObject());
+ return new ImplicitObjectResolver(forFacesList);
+ }
+
+
+ private ImplicitObjectResolver() {
+ super();
+ this.implicitObjects = new ArrayList();
+ }
+
+ /** Creates a new instance of ImplicitObjectResolverForJSP */
+ private ImplicitObjectResolver(List<ImplicitObject> implicitObjects) {
+ this();
+ this.implicitObjects = implicitObjects;
+ }
+
+ public void setValue(ELContext context, Object base, Object property, Object value)
+ throws NullPointerException, PropertyNotFoundException, PropertyNotWritableException, ELException {
+
+ if (base != null) return;
+ if (property == null) throw new PropertyNotFoundException();
+ if (!(property instanceof String)) return;
+
+ String strProperty = castAndIntern(property);
+
+ for (ImplicitObject obj: implicitObjects) {
+ if (strProperty == obj.getName()) {
+ throw new PropertyNotWritableException();
+ }
+ }
+ }
+
+ public boolean isReadOnly(ELContext context, Object base, Object property)
+ throws NullPointerException, PropertyNotFoundException, ELException {
+
+ if (base != null) return false;
+ if (property == null) throw new PropertyNotFoundException();
+ if (!(property instanceof String)) return false;
+
+ String strProperty = castAndIntern(property);
+
+ for (ImplicitObject obj: implicitObjects) {
+ if (strProperty == obj.getName()) {
+ context.setPropertyResolved(true);
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public Object getValue(ELContext context, Object base, Object property)
+ throws NullPointerException, PropertyNotFoundException, ELException {
+
+ if (base != null) return null;
+ if (property == null) throw new PropertyNotFoundException();
+ if (!(property instanceof String)) return null;
+
+ String strProperty = castAndIntern(property);
+
+ for (ImplicitObject obj : implicitObjects) {
+ if (strProperty == obj.getName()) {
+ context.setPropertyResolved(true);
+ return obj.getValue(context);
+ }
+ }
+
+ return null;
+ }
+
+ public Class<?> getType(ELContext context, Object base, Object property)
+ throws NullPointerException, PropertyNotFoundException, ELException {
+
+ if (base != null) return null;
+ if (property == null) throw new PropertyNotFoundException();
+ if (!(property instanceof String)) return null;
+
+ String strProperty = castAndIntern(property);
+
+ for (ImplicitObject obj: implicitObjects) {
+ if (strProperty == obj.getName()) {
+ context.setPropertyResolved(true);
+ return obj.getType();
+ }
+ }
+
+ return null;
+ }
+
+ public Iterator getFeatureDescriptors(ELContext context, Object base) {
+ if (base != null) return null;
+
+ ArrayList<FeatureDescriptor> descriptors = new ArrayList<FeatureDescriptor>(implicitObjects.size());
+
+ for (ImplicitObject obj: implicitObjects) {
+ descriptors.add(obj.getDescriptor());
+ }
+
+ return descriptors.iterator();
+ }
+
+ public Class<?> getCommonPropertyType(ELContext context, Object base) {
+ if (base != null) return null;
+
+ return String.class;
+ }
+
+ protected String castAndIntern(Object o) {
+ String s = (String)o;
+ return s.intern();
+ }
+
+}
\ No newline at end of file
Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/InitParamImplicitObject.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/InitParamImplicitObject.java?rev=410018&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/InitParamImplicitObject.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/InitParamImplicitObject.java Sun May 28 20:59:46 2006
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.el.unified.resolver.implicitobject;
+
+import java.beans.FeatureDescriptor;
+import java.util.Map;
+import javax.el.ELContext;
+
+/**
+ * Encapsulates information needed by the ImplicitObjectResolver
+ *
+ * @author Stan Silvert
+ */
+public class InitParamImplicitObject extends ImplicitObject {
+
+ private static final String NAME = "initParam".intern();
+
+ /** Creates a new instance of InitParamImplicitObject */
+ public InitParamImplicitObject() {
+ }
+
+ public Object getValue(ELContext context) {
+ return externalContext(context).getInitParameterMap();
+ }
+
+ public String getName() {
+ return NAME;
+ }
+
+ public Class getType() {
+ return null;
+ }
+
+ public FeatureDescriptor getDescriptor() {
+ return makeDescriptor(NAME,
+ "Map whose keys are a set of application initialization param names and whose values are the corresponding values",
+ Map.class);
+ }
+
+}
Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/ParamImplicitObject.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/ParamImplicitObject.java?rev=410018&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/ParamImplicitObject.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/ParamImplicitObject.java Sun May 28 20:59:46 2006
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.el.unified.resolver.implicitobject;
+
+import java.beans.FeatureDescriptor;
+import java.util.Map;
+import javax.el.ELContext;
+
+/**
+ * Encapsulates information needed by the ImplicitObjectResolver
+ *
+ * @author Stan Silvert
+ */
+public class ParamImplicitObject extends ImplicitObject {
+
+ private static final String NAME = "param".intern();
+
+ /** Creates a new instance of InitParamImplicitObject */
+ public ParamImplicitObject() {
+ }
+
+ public Object getValue(ELContext context) {
+ return externalContext(context).getRequestParameterMap();
+ }
+
+ public String getName() {
+ return NAME;
+ }
+
+ public Class getType() {
+ return null;
+ }
+
+ public FeatureDescriptor getDescriptor() {
+ return makeDescriptor(NAME,
+ "Map whose keys are a set of request param names and whose values are the first (or only) values for each name in the request",
+ Map.class);
+ }
+
+}
Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/ParamValuesImplicitObject.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/ParamValuesImplicitObject.java?rev=410018&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/ParamValuesImplicitObject.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/ParamValuesImplicitObject.java Sun May 28 20:59:46 2006
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.el.unified.resolver.implicitobject;
+
+import java.beans.FeatureDescriptor;
+import java.util.Map;
+import javax.el.ELContext;
+
+/**
+ * Encapsulates information needed by the ImplicitObjectResolver
+ *
+ * @author Stan Silvert
+ */
+public class ParamValuesImplicitObject extends ImplicitObject {
+
+ private static final String NAME = "paramValues".intern();
+
+ /** Creates a new instance of ParamValuesImplicitObject */
+ public ParamValuesImplicitObject() {
+ }
+
+ public Object getValue(ELContext context) {
+ return externalContext(context).getRequestParameterValuesMap();
+ }
+
+ public String getName() {
+ return NAME;
+ }
+
+ public Class getType() {
+ return null;
+ }
+
+ public FeatureDescriptor getDescriptor() {
+ return makeDescriptor(NAME,
+ "Map whose keys are a set of request param names and whose values (type String[]) are all values for each name in the request",
+ Map.class);
+ }
+
+}
Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/RequestImplicitObject.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/RequestImplicitObject.java?rev=410018&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/RequestImplicitObject.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/RequestImplicitObject.java Sun May 28 20:59:46 2006
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.el.unified.resolver.implicitobject;
+
+import java.beans.FeatureDescriptor;
+import javax.el.ELContext;
+
+/**
+ * Encapsulates information needed by the ImplicitObjectResolver
+ *
+ * @author Stan Silvert
+ */
+public class RequestImplicitObject extends ImplicitObject {
+
+ private static final String NAME = "request".intern();
+
+ /** Creates a new instance of ParamValueRequestImplicitObject */
+ public RequestImplicitObject() {
+ }
+
+ public Object getValue(ELContext context) {
+ return externalContext(context).getRequest();
+ }
+
+ public String getName() {
+ return NAME;
+ }
+
+ public Class getType() {
+ return null;
+ }
+
+ public FeatureDescriptor getDescriptor() {
+ return makeDescriptor(NAME,
+ "Environment-specific object instance for the current request",
+ Object.class);
+ }
+
+}
Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/RequestScopeImplicitObject.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/RequestScopeImplicitObject.java?rev=410018&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/RequestScopeImplicitObject.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/RequestScopeImplicitObject.java Sun May 28 20:59:46 2006
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.el.unified.resolver.implicitobject;
+
+import java.beans.FeatureDescriptor;
+import java.util.Map;
+import javax.el.ELContext;
+
+/**
+ * Encapsulates information needed by the ImplicitObjectResolver
+ *
+ * @author Stan Silvert
+ */
+public class RequestScopeImplicitObject extends ImplicitObject {
+
+ private static final String NAME = "requestScope".intern();
+
+ /** Creates a new instance of RequestScopeImplicitObject */
+ public RequestScopeImplicitObject() {
+ }
+
+ public Object getValue(ELContext context) {
+ return externalContext(context).getRequestMap();
+ }
+
+ public String getName() {
+ return NAME;
+ }
+
+ public Class getType() {
+ return Object.class;
+ }
+
+ public FeatureDescriptor getDescriptor() {
+ return makeDescriptor(NAME,
+ "Request scope attributes",
+ Map.class);
+ }
+
+}
Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/SessionImplicitObject.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/SessionImplicitObject.java?rev=410018&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/SessionImplicitObject.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/SessionImplicitObject.java Sun May 28 20:59:46 2006
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.el.unified.resolver.implicitobject;
+
+import java.beans.FeatureDescriptor;
+import javax.el.ELContext;
+
+/**
+ * Encapsulates information needed by the ImplicitObjectResolver
+ *
+ * @author Stan Silvert
+ */
+public class SessionImplicitObject extends ImplicitObject {
+
+ private static final String NAME = "session".intern();
+
+ /** Creates a new instance of SessionImplicitObject */
+ public SessionImplicitObject() {
+ }
+
+ public Object getValue(ELContext context) {
+ return externalContext(context).getSession(false);
+ }
+
+ public String getName() {
+ return NAME;
+ }
+
+ public Class getType() {
+ return null;
+ }
+
+ public FeatureDescriptor getDescriptor() {
+ return makeDescriptor(NAME,
+ "Session instance for the current request or null if no session exists",
+ Object.class);
+ }
+
+}
Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/SessionScopeImplicitObject.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/SessionScopeImplicitObject.java?rev=410018&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/SessionScopeImplicitObject.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/SessionScopeImplicitObject.java Sun May 28 20:59:46 2006
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.el.unified.resolver.implicitobject;
+
+import java.beans.FeatureDescriptor;
+import java.util.Map;
+import javax.el.ELContext;
+
+/**
+ * Encapsulates information needed by the ImplicitObjectResolver
+ *
+ * @author Stan Silvert
+ */
+public class SessionScopeImplicitObject extends ImplicitObject {
+
+ private static final String NAME = "sessionScope".intern();
+
+ /** Creates a new instance of SessionScopeImplicitObject */
+ public SessionScopeImplicitObject() {
+ }
+
+ public Object getValue(ELContext context) {
+ return externalContext(context).getSessionMap();
+ }
+
+ public String getName() {
+ return NAME;
+ }
+
+ public Class getType() {
+ return Object.class;
+ }
+
+ public FeatureDescriptor getDescriptor() {
+ return makeDescriptor(NAME,
+ "Session scope attributes",
+ Map.class);
+ }
+
+}
Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/ViewImplicitObject.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/ViewImplicitObject.java?rev=410018&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/ViewImplicitObject.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/implicitobject/ViewImplicitObject.java Sun May 28 20:59:46 2006
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.el.unified.resolver.implicitobject;
+
+import java.beans.FeatureDescriptor;
+import javax.el.ELContext;
+import javax.faces.component.UIViewRoot;
+
+/**
+ * Encapsulates information needed by the ImplicitObjectResolver
+ *
+ * @author Stan Silvert
+ */
+public class ViewImplicitObject extends ImplicitObject {
+
+ private static final String NAME = "view".intern();
+
+ /** Creates a new instance of ViewImplicitObject */
+ public ViewImplicitObject() {
+ }
+
+ public Object getValue(ELContext context) {
+ return facesContext(context).getViewRoot();
+ }
+
+ public String getName() {
+ return NAME;
+ }
+
+ public Class getType() {
+ return null;
+ }
+
+ public FeatureDescriptor getDescriptor() {
+ return makeDescriptor(NAME,
+ "The root object of a JSF component tree",
+ UIViewRoot.class);
+ }
+
+}
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/PhaseListenerManager.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/PhaseListenerManager.java?rev=410018&r1=410017&r2=410018&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/PhaseListenerManager.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/PhaseListenerManager.java Sun May 28 20:59:46 2006
@@ -18,6 +18,7 @@
import java.util.HashMap;
import java.util.Map;
+import javax.el.MethodExpression;
import javax.faces.context.FacesContext;
import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
@@ -40,14 +41,20 @@
private Lifecycle lifecycle;
private FacesContext facesContext;
private PhaseListener[] phaseListeners;
+ private MethodExpression uiViewRootBeforeListener;
+ private MethodExpression uiViewRootAfterListener;
// Tracks success in the beforePhase. Listeners that throw an exception
// in beforePhase or were never called because a previous listener threw
// an exception should not have its afterPhase called
- private Map listenerSuccessMap = new HashMap();
+ private Map<PhaseId, boolean[]> listenerSuccessMap = new HashMap<PhaseId, boolean[]>();
+
+ private Map<PhaseId, Boolean> uiViewRootListenerSuccessMap = new HashMap<PhaseId, Boolean>();
/** Creates a new instance of PhaseListenerManager */
- PhaseListenerManager(Lifecycle lifecycle, FacesContext facesContext, PhaseListener[] phaseListeners) {
+ PhaseListenerManager(Lifecycle lifecycle,
+ FacesContext facesContext,
+ PhaseListener[] phaseListeners) {
this.lifecycle = lifecycle;
this.facesContext = facesContext;
this.phaseListeners = phaseListeners;
@@ -59,15 +66,29 @@
listenerPhaseId == phaseId.getOrdinal());
}
+ private boolean isListenerForThisPhase(MethodExpression phaseListener, PhaseId phaseId) {
+ return (phaseListener != null) && (phaseId != PhaseId.RESTORE_VIEW);
+ }
+
+ // these variables can't be set until the Apply Request Values phase
+ private void setUIViewRootListeners(PhaseId phaseId) {
+ if (phaseId != PhaseId.APPLY_REQUEST_VALUES) return;
+
+ this.uiViewRootBeforeListener = facesContext.getViewRoot().getBeforePhaseListener();
+ this.uiViewRootAfterListener = facesContext.getViewRoot().getAfterPhaseListener();
+ }
+
void informPhaseListenersBefore(PhaseId phaseId) {
+ setUIViewRootListeners(phaseId);
boolean[] beforePhaseSuccess = new boolean[phaseListeners.length];
listenerSuccessMap.put(phaseId, beforePhaseSuccess);
+ PhaseEvent phaseEvent = new PhaseEvent(facesContext, phaseId, lifecycle);
for (int i = 0; i < phaseListeners.length; i++) {
PhaseListener phaseListener = phaseListeners[i];
if (isListenerForThisPhase(phaseListener, phaseId)) {
try {
- phaseListener.beforePhase(new PhaseEvent(facesContext, phaseId, lifecycle));
+ phaseListener.beforePhase(phaseEvent);
beforePhaseSuccess[i] = true;
} catch (Exception e) {
beforePhaseSuccess[i] = false; // redundant - for clarity
@@ -76,22 +97,47 @@
}
}
}
+
+ uiViewRootListenerSuccessMap.put(phaseId, Boolean.FALSE);
+ if (isListenerForThisPhase(this.uiViewRootBeforeListener, phaseId)) {
+ try {
+ invokeMethodExpression(this.uiViewRootBeforeListener, phaseEvent);
+ uiViewRootListenerSuccessMap.put(phaseId, Boolean.TRUE);
+ } catch (Exception e) {
+ log.error("Exception in UIViewRoot BeforePhaseListener " + phaseId.toString() + " beforePhase.", e);
+ return;
+ }
+ }
+ }
+
+ void invokeMethodExpression(MethodExpression methodExpression, PhaseEvent event) throws Exception {
+ methodExpression.invoke(facesContext.getELContext(), new Object[]{event});
}
void informPhaseListenersAfter(PhaseId phaseId) {
- boolean[] beforePhaseSuccess = (boolean[])listenerSuccessMap.get(phaseId);
+ boolean[] beforePhaseSuccess = listenerSuccessMap.get(phaseId);
+ PhaseEvent phaseEvent = new PhaseEvent(facesContext, phaseId, lifecycle);
for (int i = phaseListeners.length - 1; i >= 0; i--) {
PhaseListener phaseListener = phaseListeners[i];
if (isListenerForThisPhase(phaseListener, phaseId)
&& beforePhaseSuccess[i]) {
try {
- phaseListener.afterPhase(new PhaseEvent(facesContext, phaseId, lifecycle));
+ phaseListener.afterPhase(phaseEvent);
} catch (Exception e) {
log.error("Exception in PhaseListener " + phaseId.toString() + " afterPhase", e);
}
}
}
+ if (isListenerForThisPhase(this.uiViewRootAfterListener, phaseId) &&
+ uiViewRootListenerSuccessMap.get(phaseId).booleanValue()) {
+ try {
+ invokeMethodExpression(this.uiViewRootAfterListener, phaseEvent);
+ } catch (Exception e) {
+ log.error("Exception in UIViewRoot AfterPhaseListener " + phaseId.toString() + " afterPhase.", e);
+ return;
+ }
+ }
}
}
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/MyFacesGenericPortlet.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/MyFacesGenericPortlet.java?rev=410018&r1=410017&r2=410018&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/MyFacesGenericPortlet.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/MyFacesGenericPortlet.java Sun May 28 20:59:46 2006
@@ -181,7 +181,9 @@
ExternalContext externalContext = new PortletExternalContextImpl(portletContext, null, null);
//And configure everything
- new FacesConfigurator(externalContext).configure();
+
+ // TODO: FIX PORTLET STUFF FOR JSF 1.2
+ // new FacesConfigurator(externalContext).configure();
// parse web.xml - not sure if this is needed for portlet
WebXml.init(externalContext);
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java?rev=410018&r1=410017&r2=410018&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java Sun May 28 20:59:46 2006
@@ -44,6 +44,12 @@
private static final String BASE64_STATE_PARAM = "jsf_state_64";
private static final String ZIP_CHARSET = "ISO-8859-1";
+ public void writeState(FacesContext facesContext, Object state)
+ throws IOException {
+ //TODO: implement
+ throw new UnsupportedOperationException("Not Implemented yet");
+ }
+
public void writeState(FacesContext facescontext,
StateManager.SerializedView serializedview) throws IOException
{
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/webapp/StartupServletContextListener.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/webapp/StartupServletContextListener.java?rev=410018&r1=410017&r2=410018&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/webapp/StartupServletContextListener.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/webapp/StartupServletContextListener.java Sun May 28 20:59:46 2006
@@ -15,27 +15,28 @@
*/
package org.apache.myfaces.webapp;
-import java.util.Iterator;
-import java.util.List;
-
+import javax.el.ELResolver;
import javax.faces.FactoryFinder;
+import javax.faces.application.Application;
+import javax.faces.application.ApplicationFactory;
import javax.faces.context.ExternalContext;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
+import javax.servlet.jsp.JspFactory;
+import org.apache.myfaces.application.ApplicationImpl;
-import org.apache.myfaces.config.FacesConfigValidator;
import org.apache.myfaces.config.FacesConfigurator;
import org.apache.myfaces.context.servlet.ServletExternalContextImpl;
-import org.apache.myfaces.shared_impl.util.ClassUtils;
+import org.apache.myfaces.el.unified.resolver.ResolverForJSP;
import org.apache.myfaces.shared_impl.util.StateUtils;
-import org.apache.myfaces.shared_impl.util.serial.DefaultSerialFactory;
-import org.apache.myfaces.shared_impl.util.serial.SerialFactory;
import org.apache.myfaces.shared_impl.webapp.webxml.WebXml;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
+ * TODO: Add listener to myfaces-core.tld instead of web.xml
+ *
* @author Manfred Geiler (latest modification by $Author$)
* @version $Revision$ $Date$
*/
@@ -66,21 +67,8 @@
ExternalContext externalContext = new ServletExternalContextImpl(servletContext, null, null);
//And configure everything
- new FacesConfigurator(externalContext).configure();
-
- if ("true".equals(servletContext
- .getInitParameter(FacesConfigValidator.VALIDATE_CONTEXT_PARAM)))
- {
- List list = FacesConfigValidator.validate(externalContext,
- servletContext.getRealPath("/"));
-
- Iterator iterator = list.iterator();
+ new FacesConfigurator(externalContext).configure(servletContext);
- while (iterator.hasNext())
- log.warn(iterator.next());
-
- }
-
// parse web.xml
WebXml.init(externalContext);
@@ -100,45 +88,6 @@
if(servletContext.getInitParameter(StateUtils.INIT_SECRET) != null)
StateUtils.initSecret(servletContext);
-
- handleSerialFactory(servletContext);
- }
-
- private static void handleSerialFactory(ServletContext servletContext){
-
- String serialProvider = servletContext.getInitParameter(StateUtils.SERIAL_FACTORY);
- SerialFactory serialFactory = null;
-
- if(serialProvider == null)
- {
- serialFactory = new DefaultSerialFactory();
- }
- else
- {
- try
- {
- serialFactory = (SerialFactory) ClassUtils.newInstance(serialProvider);
-
- }catch(ClassCastException e){
- log.error("Make sure '" + serialProvider +
- "' implements the correct interface", e);
- }
- catch(Exception e){
- log.error(e);
- }
- finally
- {
- if(serialFactory == null)
- {
- serialFactory = new DefaultSerialFactory();
- log.error("Using default serialization provider");
- }
- }
-
- }
-
- log.info("Serialization provider : " + serialFactory.getClass());
- servletContext.setAttribute(StateUtils.SERIAL_FACTORY, serialFactory);
}