You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2009/05/28 06:10:25 UTC
svn commit: r779422 - in /myfaces/core/branches/2_0_0: ./ api/
api/src/main/java/javax/faces/application/
api/src/main/java/javax/faces/component/
api/src/main/java/javax/faces/webapp/
api/src/test/java/javax/faces/application/ impl/ impl/src/main/java...
Author: lu4242
Date: Thu May 28 04:10:24 2009
New Revision: 779422
URL: http://svn.apache.org/viewvc?rev=779422&view=rev
Log:
Merge revisions from 1.2 trunk 752295-779418 (MYFACES-2161, MYFACES-2214, MYFACES-1902, MYFACES-1761, MYFACES-2232, MYFACES-2233, MYFACES-1982, MYFACES-2177, MYFACES-1879, MYFACES-2007, MYFACES-1975, MYFACES-2156)
Added:
myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/annotation/LifecycleProvider2.java
- copied unchanged from r779418, myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/config/annotation/LifecycleProvider2.java
myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/config/annotation/AnnotatedManagedBean2.java
- copied unchanged from r779418, myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/config/annotation/AnnotatedManagedBean2.java
myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/config/annotation/Myfaces1761TestCase.java
- copied unchanged from r779418, myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/config/annotation/Myfaces1761TestCase.java
myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/config/annotation/TestLifecycleProvider2.java
- copied unchanged from r779418, myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/config/annotation/TestLifecycleProvider2.java
Modified:
myfaces/core/branches/2_0_0/ (props changed)
myfaces/core/branches/2_0_0/api/pom.xml
myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/application/Application.java
myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/UIInput.java
myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/webapp/FacesServlet.java
myfaces/core/branches/2_0_0/api/src/test/java/javax/faces/application/ApplicationTest.java
myfaces/core/branches/2_0_0/impl/pom.xml
myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/application/ApplicationFactoryImpl.java
myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/application/jsp/JspStateManagerImpl.java
myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/ManagedBeanBuilder.java
myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultLifecycleProviderFactory.java
myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/annotation/NoAnnotationLifecyleProvider.java
myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/annotation/NoInjectionAnnotationLifecycleProvider.java
myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/annotation/TomcatAnnotationLifecycleProvider.java
myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/servlet/FacesContextImpl.java
myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlRenderKitImpl.java
myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java
myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/taglib/core/LoadBundleTag.java
myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/webapp/AbstractFacesInitializer.java
myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/webapp/Jsp20FacesInitializer.java
myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/webapp/Jsp21FacesInitializer.java
myfaces/core/branches/2_0_0/impl/src/main/resources/META-INF/myfaces_core12.vm
myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/application/ApplicationImplTest.java
myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/config/annotation/AnnotationProcessorTestCase.java
myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextRendererTest.java
myfaces/core/branches/2_0_0/pom.xml
Propchange: myfaces/core/branches/2_0_0/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu May 28 04:10:24 2009
@@ -1 +1 @@
-/myfaces/core/trunk_1.2.x:691297-695050,698037-743106
+/myfaces/core/trunk_1.2.x:691297-695050,698037-743106,752296-779418
Modified: myfaces/core/branches/2_0_0/api/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/pom.xml?rev=779422&r1=779421&r2=779422&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/pom.xml (original)
+++ myfaces/core/branches/2_0_0/api/pom.xml Thu May 28 04:10:24 2009
@@ -171,7 +171,7 @@
<plugin>
<groupId>org.apache.myfaces.buildtools</groupId>
<artifactId>myfaces-builder-plugin</artifactId>
- <version>1.0.2</version>
+ <version>1.0.3</version>
<executions>
<execution>
<goals>
@@ -289,7 +289,7 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>jstl</groupId>
+ <groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<!-- version defined in parent -->
<scope>provided</scope>
@@ -308,7 +308,7 @@
<dependency>
<groupId>org.apache.myfaces.buildtools</groupId>
<artifactId>myfaces-builder-annotations</artifactId>
- <version>1.0.2</version>
+ <version>1.0.3</version>
<scope>provided</scope>
</dependency>
<dependency>
Modified: myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/application/Application.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/application/Application.java?rev=779422&r1=779421&r2=779422&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/application/Application.java (original)
+++ myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/application/Application.java Thu May 28 04:10:24 2009
@@ -33,6 +33,7 @@
import javax.faces.component.ActionSource;
import javax.faces.component.ActionSource2;
import javax.faces.component.UIComponent;
+import javax.faces.context.ExternalContext;
import javax.faces.component.UIViewRoot;
import javax.faces.component.behavior.Behavior;
import javax.faces.context.FacesContext;
@@ -81,6 +82,43 @@
@SuppressWarnings("deprecation")
public abstract class Application
{
+
+ /**
+ * Retrieve the current Myfaces Application Instance, lookup
+ * on the application map. All methods introduced on jsf 1.2
+ * for Application interface should thrown by default
+ * UnsupportedOperationException, but the ri scan and find the
+ * original Application impl, and redirect the call to that
+ * method instead throwing it, allowing application implementations
+ * created before jsf 1.2 continue working.
+ */
+ private Application getMyfacesApplicationInstance()
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ if (facesContext != null)
+ {
+ ExternalContext externalContext = facesContext.getExternalContext();
+ if (externalContext != null)
+ {
+ return (Application) externalContext.getApplicationMap().get("org.apache.myfaces.application.ApplicationImpl");
+ }
+ }
+ return null;
+ }
+
+ private Application getMyfacesApplicationInstance(FacesContext facesContext)
+ {
+ if (facesContext != null)
+ {
+ ExternalContext externalContext = facesContext.getExternalContext();
+ if (externalContext != null)
+ {
+ return (Application) externalContext.getApplicationMap().get("org.apache.myfaces.application.ApplicationImpl");
+ }
+ }
+ return null;
+ }
+
// The concrete methods throwing UnsupportedOperationExceptiom were added for JSF 1.2.
// They supply default to allows old Application implementations to still work.
@@ -167,6 +205,12 @@
*/
public void addELContextListener(ELContextListener listener)
{
+ Application application = getMyfacesApplicationInstance();
+ if (application != null)
+ {
+ application.addELContextListener(listener);
+ return;
+ }
throw new UnsupportedOperationException();
}
@@ -197,6 +241,15 @@
*/
public void addELResolver(ELResolver resolver)
{
+ // The following concrete methods were added for JSF 1.2. They supply default
+ // implementations that throw UnsupportedOperationException.
+ // This allows old Application implementations to still work.
+ Application application = getMyfacesApplicationInstance();
+ if (application != null)
+ {
+ application.addELResolver(resolver);
+ return;
+ }
throw new UnsupportedOperationException();
}
@@ -235,6 +288,11 @@
public UIComponent createComponent(FacesContext context, Resource componentResource)
{
// TODO: IMPLEMENT IMPL JSF 2.0 #60
+ Application application = getMyfacesApplicationInstance(context);
+ if (application != null)
+ {
+ return application.createComponent(context, componentResource);
+ }
throw new UnsupportedOperationException();
}
@@ -249,6 +307,11 @@
*/
public UIComponent createComponent(FacesContext context, String componentType, String rendererType)
{
+ Application application = getMyfacesApplicationInstance(context);
+ if (application != null)
+ {
+ return application.createComponent(context, componentType, rendererType);
+ }
throw new UnsupportedOperationException();
}
@@ -312,9 +375,14 @@
*
* @since 1.2
*/
- public UIComponent createComponent(ValueExpression componentExpression, FacesContext contexte, String componentType)
+ public UIComponent createComponent(ValueExpression componentExpression, FacesContext context, String componentType)
throws FacesException
{
+ Application application = getMyfacesApplicationInstance(context);
+ if (application != null)
+ {
+ return application.createComponent(componentExpression, context, componentType);
+ }
throw new UnsupportedOperationException();
}
@@ -331,6 +399,12 @@
public UIComponent createComponent(ValueExpression componentExpression, FacesContext context, String componentType,
String rendererType)
{
+ Application application = getMyfacesApplicationInstance(context);
+ if (application != null)
+ {
+ return application.createComponent(componentExpression, context,
+ componentType, rendererType);
+ }
throw new UnsupportedOperationException();
}
@@ -442,6 +516,11 @@
public <T> T evaluateExpressionGet(FacesContext context, String expression, Class<? extends T> expectedType)
throws ELException
{
+ Application application = getMyfacesApplicationInstance(context);
+ if (application != null)
+ {
+ return application.evaluateExpressionGet(context, expression, expectedType);
+ }
throw new UnsupportedOperationException();
}
Modified: myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/UIInput.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/UIInput.java?rev=779422&r1=779421&r2=779422&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/UIInput.java (original)
+++ myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/UIInput.java Thu May 28 04:10:24 2009
@@ -117,6 +117,20 @@
setLocalValueSet(true);
super.setValue(value);
}
+
+ /**
+ * Return the current value of this component.
+ * <p>
+ * If a submitted value has been converted but not yet pushed into the
+ * model, then return that locally-cached value (see isLocalValueSet).
+ * <p>
+ * Otherwise, evaluate an EL expression to fetch a value from the model.
+ */
+ public Object getValue()
+ {
+ if (isLocalValueSet()) return super.getLocalValue();
+ return super.getValue();
+ }
/**
* Set the "submitted value" of this component from the relevant data in the current servlet request object.
Modified: myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/webapp/FacesServlet.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/webapp/FacesServlet.java?rev=779422&r1=779421&r2=779422&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/webapp/FacesServlet.java (original)
+++ myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/webapp/FacesServlet.java Thu May 28 04:10:24 2009
@@ -234,10 +234,8 @@
Object errorHandler = clazz.newInstance();
- Method m =
- clazz.getMethod("handleExceptionList", new Class[] { FacesContext.class,
- Exception.class });
- m.invoke(errorHandler, new Object[] { facesContext, li });
+ Method m = clazz.getMethod("handleExceptionList", new Class[]{FacesContext.class,List.class});
+ m.invoke(errorHandler, new Object[]{facesContext, li});
}
catch (ClassNotFoundException ex)
{
Modified: myfaces/core/branches/2_0_0/api/src/test/java/javax/faces/application/ApplicationTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/test/java/javax/faces/application/ApplicationTest.java?rev=779422&r1=779421&r2=779422&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/test/java/javax/faces/application/ApplicationTest.java (original)
+++ myfaces/core/branches/2_0_0/api/src/test/java/javax/faces/application/ApplicationTest.java Thu May 28 04:10:24 2009
@@ -47,6 +47,7 @@
/**
* Test method for {@link javax.faces.application.Application#addELResolver(javax.el.ELResolver)}.
*/
+ /*
public void testAddELResolver()
{
assertException(UnsupportedOperationException.class, new TestRunner()
@@ -56,11 +57,12 @@
app.addELResolver(null);
}
});
- }
+ }*/
/**
* Test method for {@link javax.faces.application.Application#getELResolver()}.
*/
+ /*
public void testGetELResolver()
{
assertException(UnsupportedOperationException.class, new TestRunner()
@@ -70,12 +72,13 @@
app.getELResolver();
}
});
- }
+ }*/
/**
* Test method for
* {@link javax.faces.application.Application#getResourceBundle(javax.faces.context.FacesContext, java.lang.String)}.
*/
+ /*
public void testGetResourceBundle()
{
assertException(UnsupportedOperationException.class, new TestRunner()
@@ -85,12 +88,13 @@
app.getResourceBundle(null, null);
}
});
- }
+ }*/
/**
* Test method for
* {@link javax.faces.application.Application#createComponent(javax.el.ValueExpression, javax.faces.context.FacesContext, java.lang.String)}.
*/
+ /*
public void testCreateComponentValueExpressionFacesContextString()
{
assertException(UnsupportedOperationException.class, new TestRunner()
@@ -100,11 +104,12 @@
app.createComponent((ValueExpression) null, null, null);
}
});
- }
+ }*/
/**
* Test method for {@link javax.faces.application.Application#getExpressionFactory()}.
*/
+ /*
public void testGetExpressionFactory()
{
assertException(UnsupportedOperationException.class, new TestRunner()
@@ -114,11 +119,12 @@
app.getExpressionFactory();
}
});
- }
+ }*/
/**
* Test method for {@link javax.faces.application.Application#addELContextListener(javax.el.ELContextListener)}.
*/
+ /*
public void testAddELContextListener()
{
assertException(UnsupportedOperationException.class, new TestRunner()
@@ -128,11 +134,12 @@
app.addELContextListener(null);
}
});
- }
+ }*/
/**
* Test method for {@link javax.faces.application.Application#removeELContextListener(javax.el.ELContextListener)}.
*/
+ /*
public void testRemoveELContextListener()
{
assertException(UnsupportedOperationException.class, new TestRunner()
@@ -142,11 +149,12 @@
app.removeELContextListener(null);
}
});
- }
+ }*/
/**
* Test method for {@link javax.faces.application.Application#getELContextListeners()}.
*/
+ /*
public void testGetELContextListeners()
{
assertException(UnsupportedOperationException.class, new TestRunner()
@@ -156,12 +164,13 @@
app.getELContextListeners();
}
});
- }
+ }*/
/**
* Test method for
* {@link javax.faces.application.Application#evaluateExpressionGet(javax.faces.context.FacesContext, java.lang.String, java.lang.Class)}.
*/
+ /*
public void testEvaluateExpressionGet()
{
assertException(UnsupportedOperationException.class, new TestRunner()
@@ -171,5 +180,5 @@
app.evaluateExpressionGet(null, null, null);
}
});
- }
+ }*/
}
Modified: myfaces/core/branches/2_0_0/impl/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/pom.xml?rev=779422&r1=779421&r2=779422&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/pom.xml (original)
+++ myfaces/core/branches/2_0_0/impl/pom.xml Thu May 28 04:10:24 2009
@@ -34,17 +34,10 @@
<plugin>
<groupId>org.apache.myfaces.buildtools</groupId>
<artifactId>myfaces-builder-plugin</artifactId>
- <version>1.0.2</version>
+ <version>1.0.3</version>
<executions>
<execution>
<id>makemyfacesmetadata</id>
- <configuration>
- <!-- Qdox 1.6.3 does not parse inner enums on classes
- so we have to exclude some files temporally.
- Added linux case (paths start with /) to filter temporally too-->
- <includes>/**/*.java,**/*.java</includes>
- <excludes>/**/FacesCompositeELResolver.java,**/FacesCompositeELResolver.java</excludes>
- </configuration>
<goals>
<goal>build-metadata</goal>
</goals>
@@ -378,7 +371,7 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>jstl</groupId>
+ <groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<!-- version defined in parent -->
<scope>provided</scope>
@@ -459,7 +452,7 @@
<dependency>
<groupId>org.apache.myfaces.buildtools</groupId>
<artifactId>myfaces-builder-annotations</artifactId>
- <version>1.0.2</version>
+ <version>1.0.3</version>
<scope>provided</scope>
</dependency>
@@ -591,6 +584,6 @@
</repositories>
<properties>
- <myfaces-shared.version>3.0.5</myfaces-shared.version>
+ <myfaces-shared.version>3.0.6-SNAPSHOT</myfaces-shared.version>
</properties>
</project>
Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/application/ApplicationFactoryImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/application/ApplicationFactoryImpl.java?rev=779422&r1=779421&r2=779422&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/application/ApplicationFactoryImpl.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/application/ApplicationFactoryImpl.java Thu May 28 04:10:24 2009
@@ -18,11 +18,13 @@
*/
package org.apache.myfaces.application;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import javax.faces.application.Application;
import javax.faces.application.ApplicationFactory;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* @author Manfred Geiler (latest modification by $Author$)
@@ -39,6 +41,8 @@
* Since each webapp has it's own ClassLoader, each webapp will have it's own private factory instances.
*/
private Application _application;
+
+ private boolean _myfacesInstanceAddedToApplicationMap = false;
public ApplicationFactoryImpl()
{
@@ -48,8 +52,8 @@
private void createAndLogNewApplication()
{
_application = new ApplicationImpl();
- if (log.isTraceEnabled())
- log.trace("New ApplicationFactory instance created");
+ putApplicationOnMap();
+ if (log.isTraceEnabled()) log.trace("New ApplicationFactory instance created");
}
public void purgeApplication()
@@ -60,6 +64,14 @@
@Override
public Application getApplication()
{
+ //Put it on ApplicationMap, so javax.faces.application.Application
+ //class can find it. This allows wrapped jsf 1.1 application instances
+ //to work correctly in jsf 1.2 as ri does.
+ if (_application != null && !_myfacesInstanceAddedToApplicationMap)
+ {
+ putApplicationOnMap();
+ }
+
return _application;
}
@@ -71,6 +83,22 @@
throw new NullPointerException("Cannot set a null application in the ApplicationFactory");
}
_application = application;
+ putApplicationOnMap();
+ }
+
+ private void putApplicationOnMap()
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ if (facesContext != null)
+ {
+ ExternalContext externalContext = facesContext.getExternalContext();
+ if (externalContext != null)
+ {
+ externalContext.
+ getApplicationMap().put("org.apache.myfaces.application.ApplicationImpl", _application);
+ _myfacesInstanceAddedToApplicationMap = true;
+ }
+ }
}
}
Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java?rev=779422&r1=779421&r2=779422&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java Thu May 28 04:10:24 2009
@@ -329,7 +329,7 @@
private ClassLoader getClassLoader()
{
- return Thread.currentThread().getContextClassLoader();
+ return ClassUtils.getContextClassLoader();
}
String getBundleName(final FacesContext facesContext, final String name)
@@ -1226,13 +1226,6 @@
// Locate a Converter registered for the target class itself.
String converterClassName = _converterClassNameToClassMap.get(targetClass);
- // Get EnumConverter for enum classes with no special converter, check
- // here as recursive call with java.lang.Enum will not work
- if (converterClassName == null && targetClass.isEnum())
- {
- converterClassName = _converterClassNameToClassMap.get(Enum.class);
- }
-
// Locate a Converter registered for interfaces that are
// implemented by the target class (directly or indirectly).
if (converterClassName == null)
@@ -1253,6 +1246,12 @@
}
}
+ // Get EnumConverter for enum classes with no special converter, check
+ // here as recursive call with java.lang.Enum will not work
+ if (converterClassName == null && targetClass.isEnum()) {
+ converterClassName = _converterClassNameToClassMap.get(Enum.class);
+ }
+
if (converterClassName != null)
{
try
Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/application/jsp/JspStateManagerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/application/jsp/JspStateManagerImpl.java?rev=779422&r1=779421&r2=779422&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/application/jsp/JspStateManagerImpl.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/application/jsp/JspStateManagerImpl.java Thu May 28 04:10:24 2009
@@ -28,6 +28,7 @@
import org.apache.myfaces.shared_impl.renderkit.RendererUtils;
import org.apache.myfaces.shared_impl.util.MyFacesObjectInputStream;
+import javax.faces.FacesException;
import javax.faces.FactoryFinder;
import javax.faces.component.NamingContainer;
import javax.faces.component.UIComponent;
@@ -39,6 +40,9 @@
import javax.faces.render.ResponseStateManager;
import java.io.*;
import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.util.*;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
@@ -766,9 +770,41 @@
{
is = new GZIPInputStream(is);
}
- ObjectInputStream in = new MyFacesObjectInputStream(
- is);
- return new Object[] {in.readObject(), in.readObject()};
+ ObjectInputStream ois = null;
+ try
+ {
+ final ObjectInputStream in = new MyFacesObjectInputStream(is);
+ ois = in;
+ Object object = null;
+ if (System.getSecurityManager() != null)
+ {
+ object = AccessController.doPrivileged(new PrivilegedExceptionAction<Object []>()
+ {
+ public Object[] run() throws PrivilegedActionException, IOException, ClassNotFoundException
+ {
+ return new Object[] {in.readObject(), in.readObject()};
+ }
+ });
+ }
+ else
+ {
+ object = new Object[] {in.readObject(), in.readObject()};
+ }
+ return object;
+ }
+ finally
+ {
+ if (ois != null)
+ {
+ ois.close();
+ ois = null;
+ }
+ }
+ }
+ catch (PrivilegedActionException e)
+ {
+ log.error("Exiting deserializeView - Could not deserialize state: " + e.getMessage(), e);
+ return null;
}
catch (IOException e)
{
Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java?rev=779422&r1=779421&r2=779422&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java Thu May 28 04:10:24 2009
@@ -19,12 +19,14 @@
package org.apache.myfaces.config;
import java.io.BufferedReader;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.net.JarURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
@@ -236,12 +238,12 @@
private long getResourceLastModified(String resource)
{
- try
+ try
{
- URL url = _externalContext.getResource(resource);
+ URL url = _externalContext.getResource(resource);
if (url != null)
{
- return url.openConnection().getLastModified();
+ return getResourceLastModified(url);
}
}
catch (IOException e)
@@ -251,6 +253,66 @@
return 0;
}
+ //Taken from trinidad URLUtils
+ private long getResourceLastModified(URL url) throws IOException
+ {
+ if ("file".equals(url.getProtocol()))
+ {
+ String externalForm = url.toExternalForm();
+ // Remove the "file:"
+ File file = new File(externalForm.substring(5));
+
+ return file.lastModified();
+ }
+ else
+ {
+ return getResourceLastModified(url.openConnection());
+ }
+ }
+
+ //Taken from trinidad URLUtils
+ private long getResourceLastModified(URLConnection connection) throws IOException
+ {
+ long modified;
+ if (connection instanceof JarURLConnection)
+ {
+ // The following hack is required to work-around a JDK bug.
+ // getLastModified() on a JAR entry URL delegates to the actual JAR file
+ // rather than the JAR entry.
+ // This opens internally, and does not close, an input stream to the JAR
+ // file.
+ // In turn, you cannot close it by yourself, because it's internal.
+ // The work-around is to get the modification date of the JAR file
+ // manually,
+ // and then close that connection again.
+
+ URL jarFileUrl = ((JarURLConnection) connection).getJarFileURL();
+ URLConnection jarFileConnection = jarFileUrl.openConnection();
+
+ try
+ {
+ modified = jarFileConnection.getLastModified();
+ }
+ finally
+ {
+ try
+ {
+ jarFileConnection.getInputStream().close();
+ }
+ catch (Exception exception)
+ {
+ // Ignored
+ }
+ }
+ }
+ else
+ {
+ modified = connection.getLastModified();
+ }
+
+ return modified;
+ }
+
private long getLastModifiedTime()
{
long lastModified = 0;
Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/ManagedBeanBuilder.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/ManagedBeanBuilder.java?rev=779422&r1=779421&r2=779422&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/ManagedBeanBuilder.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/ManagedBeanBuilder.java Thu May 28 04:10:24 2009
@@ -42,6 +42,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.myfaces.config.annotation.LifecycleProvider;
+import org.apache.myfaces.config.annotation.LifecycleProvider2;
import org.apache.myfaces.config.annotation.LifecycleProviderFactory;
import org.apache.myfaces.config.element.ListEntries;
import org.apache.myfaces.config.element.ListEntry;
@@ -135,6 +136,14 @@
+ bean.getClass().getName() + " for managed bean "
+ beanConfiguration.getManagedBeanName() + '.');
}
+
+ // MYFACES-1761 if implements LifecycleProvider,
+ //PostConstruct was already called, but if implements
+ //LifecycleProvider2, call it now.
+ if (lifecycleProvider instanceof LifecycleProvider2)
+ {
+ ((LifecycleProvider2)lifecycleProvider).postConstruct(bean);
+ }
return bean;
}
catch (IllegalAccessException e)
Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultLifecycleProviderFactory.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultLifecycleProviderFactory.java?rev=779422&r1=779421&r2=779422&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultLifecycleProviderFactory.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultLifecycleProviderFactory.java Thu May 28 04:10:24 2009
@@ -115,7 +115,7 @@
private boolean resolveLifecycleProviderFromService(ExternalContext externalContext) {
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ ClassLoader classLoader = ClassUtils.getContextClassLoader();
ClassLoaders loaders = new ClassLoaders();
loaders.put(classLoader);
DiscoverServiceNames dsn = new DiscoverServiceNames(loaders);
Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/annotation/NoAnnotationLifecyleProvider.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/annotation/NoAnnotationLifecyleProvider.java?rev=779422&r1=779421&r2=779422&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/annotation/NoAnnotationLifecyleProvider.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/annotation/NoAnnotationLifecyleProvider.java Thu May 28 04:10:24 2009
@@ -22,7 +22,7 @@
import java.lang.reflect.InvocationTargetException;
-public class NoAnnotationLifecyleProvider implements LifecycleProvider
+public class NoAnnotationLifecyleProvider implements LifecycleProvider2
{
@@ -35,4 +35,10 @@
{
return ClassUtils.classForName(className).newInstance();
}
+ public void postConstruct(Object o) throws IllegalAccessException,
+ InvocationTargetException
+ {
+ // No op
+ }
+
}
Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/annotation/NoInjectionAnnotationLifecycleProvider.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/annotation/NoInjectionAnnotationLifecycleProvider.java?rev=779422&r1=779421&r2=779422&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/annotation/NoInjectionAnnotationLifecycleProvider.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/annotation/NoInjectionAnnotationLifecycleProvider.java Thu May 28 04:10:24 2009
@@ -18,14 +18,15 @@
*/
package org.apache.myfaces.config.annotation;
-import org.apache.myfaces.shared_impl.util.ClassUtils;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.naming.NamingException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
+
+import org.apache.myfaces.shared_impl.util.ClassUtils;
/**
* See SRV.14.5 Servlet Specification Version 2.5 JSR 154 and Common Annotations for the Java Platform JSR 250
@@ -40,14 +41,15 @@
Class<?> clazz = ClassUtils.classForName(className);
Object object = clazz.newInstance();
processAnnotations(object);
- postConstruct(object);
+ //postConstruct(object);
return object;
}
/**
* Call postConstruct method on the specified instance.
*/
- private void postConstruct(Object instance) throws IllegalAccessException, InvocationTargetException
+ public void postConstruct(Object instance)
+ throws IllegalAccessException, InvocationTargetException
{
// TODO the servlet spec is not clear about searching in superclass??
Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/annotation/TomcatAnnotationLifecycleProvider.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/annotation/TomcatAnnotationLifecycleProvider.java?rev=779422&r1=779421&r2=779422&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/annotation/TomcatAnnotationLifecycleProvider.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/annotation/TomcatAnnotationLifecycleProvider.java Thu May 28 04:10:24 2009
@@ -27,7 +27,8 @@
import javax.servlet.ServletContext;
import java.lang.reflect.InvocationTargetException;
-public class TomcatAnnotationLifecycleProvider implements DiscoverableLifecycleProvider
+public class TomcatAnnotationLifecycleProvider implements
+ DiscoverableLifecycleProvider, LifecycleProvider2
{
private static Log log = LogFactory.getLog(TomcatAnnotationLifecycleProvider.class);
@@ -46,7 +47,7 @@
log.info("Creating instance of " + className);
Object object = clazz.newInstance();
annotationProcessor.processAnnotations(object);
- annotationProcessor.postConstruct(object);
+ //annotationProcessor.postConstruct(object);
return object;
}
@@ -70,4 +71,11 @@
return false;
}
+
+ public void postConstruct(Object o) throws IllegalAccessException,
+ InvocationTargetException
+ {
+ annotationProcessor.postConstruct(o);
+ }
+
}
Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/servlet/FacesContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/servlet/FacesContextImpl.java?rev=779422&r1=779421&r2=779422&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/servlet/FacesContextImpl.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/servlet/FacesContextImpl.java Thu May 28 04:10:24 2009
@@ -105,11 +105,11 @@
private void init(final ReleaseableExternalContext externalContext)
{
- _application = ((ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY))
+ _externalContext = externalContext;
+ FacesContext.setCurrentInstance(this); //protected method, therefore must be called from here
+ _application = ((ApplicationFactory)FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY))
.getApplication();
_renderKitFactory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
- _externalContext = externalContext;
- FacesContext.setCurrentInstance(this); // protected method, therefore must be called from here
}
// ~ Methods ------------------------------------------------------------------------------------
Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlRenderKitImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlRenderKitImpl.java?rev=779422&r1=779421&r2=779422&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlRenderKitImpl.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlRenderKitImpl.java Thu May 28 04:10:24 2009
@@ -28,6 +28,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import javax.faces.context.ResponseStream;
import javax.faces.context.ResponseWriter;
@@ -36,6 +37,7 @@
import javax.faces.render.Renderer;
import javax.faces.render.ResponseStateManager;
+import org.apache.commons.collections.map.Flat3Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderKit;
@@ -53,7 +55,7 @@
// ~ Instance fields ----------------------------------------------------------------------------
- private Map<String, Renderer> _renderers;
+ private Map<String, Map<String, Renderer>> _renderers;
private ResponseStateManager _responseStateManager;
private Map<String,Set<String>> _families;
private Map<String, ClientBehaviorRenderer> _clientBehaviorRenderers;
@@ -62,7 +64,7 @@
public HtmlRenderKitImpl()
{
- _renderers = new HashMap<String, Renderer>();
+ _renderers = new ConcurrentHashMap<String, Map<String, Renderer>>(64, 0.75f, 1);
_responseStateManager = new HtmlResponseStateManager();
_families = new HashMap<String, Set<String> >();
_clientBehaviorRenderers = new HashMap<String, ClientBehaviorRenderer>();
@@ -70,11 +72,6 @@
// ~ Methods ------------------------------------------------------------------------------------
- private String key(String componentFamily, String rendererType)
- {
- return componentFamily + "." + rendererType;
- }
-
@Override
public void addClientBehaviorRenderer(String type, ClientBehaviorRenderer renderer)
{
@@ -118,7 +115,12 @@
{
throw new NullPointerException("renderer type must not be null.");
}
- Renderer renderer = _renderers.get(key(componentFamily, rendererType));
+ Map <String,Renderer> familyRendererMap = _renderers.get(componentFamily);
+ Renderer renderer = null;
+ if (familyRendererMap != null)
+ {
+ renderer = familyRendererMap.get(rendererType);
+ }
if (renderer == null)
{
log.warn("Unsupported component-family/renderer-type: " + componentFamily + "/" + rendererType);
@@ -144,33 +146,41 @@
log.error("addRenderer: renderer = null is not allowed");
throw new NullPointerException("renderer must not be null.");
}
+
+ _put(componentFamily, rendererType, renderer);
- String rendererKey = key(componentFamily, rendererType);
- if (_renderers.get(rendererKey) != null)
- {
- // this is not necessarily an error, but users do need to be
- // very careful about jar processing order when overriding
- // some component's renderer with an alternate renderer.
- log.debug("Overwriting renderer with family = " + componentFamily + " rendererType = " + rendererType
+ if (log.isTraceEnabled())
+ log.trace("add Renderer family = " + componentFamily + " rendererType = " + rendererType
+ " renderer class = " + renderer.getClass().getName());
- }
-
- if (_families.get(componentFamily) == null)
+ }
+
+ /**
+ * Put the renderer on the double map
+ *
+ * @param componentFamily
+ * @param rendererType
+ * @param renderer
+ */
+ synchronized private void _put(String componentFamily, String rendererType, Renderer renderer)
+ {
+ Map <String,Renderer> familyRendererMap = _renderers.get(componentFamily);
+ if (familyRendererMap == null)
{
- Set<String> rendererTypes = new HashSet<String>();
- rendererTypes.add(rendererType);
- _families.put(componentFamily, rendererTypes);
+ familyRendererMap = (Map<String,Renderer>) new Flat3Map();
+ _renderers.put(componentFamily, familyRendererMap);
}
else
{
- _families.get(componentFamily).add(rendererType);
+ if (familyRendererMap.get(rendererType) != null) {
+ // this is not necessarily an error, but users do need to be
+ // very careful about jar processing order when overriding
+ // some component's renderer with an alternate renderer.
+ log.debug("Overwriting renderer with family = " + componentFamily +
+ " rendererType = " + rendererType +
+ " renderer class = " + renderer.getClass().getName());
+ }
}
-
- _renderers.put(rendererKey, renderer);
-
- if (log.isTraceEnabled())
- log.trace("add Renderer family = " + componentFamily + " rendererType = " + rendererType
- + " renderer class = " + renderer.getClass().getName());
+ familyRendererMap.put(rendererType, renderer);
}
@Override
Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java?rev=779422&r1=779421&r2=779422&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java Thu May 28 04:10:24 2009
@@ -196,12 +196,11 @@
*
* @return the reconstructed state, or <code>null</code> if there was no saved state
*/
- private Object[] getSavedState(FacesContext facesContext)
- {
- Object encodedState =
- facesContext.getExternalContext().getRequestParameterMap().get(STANDARD_STATE_SAVING_PARAM);
- if (encodedState == null)
- {
+ private Object[] getSavedState(FacesContext facesContext) {
+ Object encodedState =
+ facesContext.getExternalContext().
+ getRequestParameterMap().get(STANDARD_STATE_SAVING_PARAM);
+ if(encodedState==null || (((String) encodedState).length() == 0)) {
return null;
}
Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/taglib/core/LoadBundleTag.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/taglib/core/LoadBundleTag.java?rev=779422&r1=779421&r2=779422&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/taglib/core/LoadBundleTag.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/taglib/core/LoadBundleTag.java Thu May 28 04:10:24 2009
@@ -38,6 +38,7 @@
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFJspAttribute;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFJspTag;
+import org.apache.myfaces.shared_impl.util.ClassUtils;
/**
* Loads a resource bundle and saves it as a variable in the request scope.
@@ -126,7 +127,9 @@
final ResourceBundle bundle;
try
{
- bundle = ResourceBundle.getBundle(basename, locale, Thread.currentThread().getContextClassLoader());
+ bundle = ResourceBundle.getBundle(basename,
+ locale,
+ ClassUtils.getContextClassLoader());
}
catch (MissingResourceException e)
{
Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/webapp/AbstractFacesInitializer.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/webapp/AbstractFacesInitializer.java?rev=779422&r1=779421&r2=779422&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/webapp/AbstractFacesInitializer.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/webapp/AbstractFacesInitializer.java Thu May 28 04:10:24 2009
@@ -44,6 +44,11 @@
* The logger instance for this class.
*/
private static final Log log = LogFactory.getLog(AbstractFacesInitializer.class);
+
+ /**
+ * This parameter specifies the ExpressionFactory implementation to use.
+ */
+ protected static final String EXPRESSION_FACTORY = "org.apache.myfaces.EXPRESSION_FACTORY";
/**
* Performs all necessary initialization tasks like configuring this JSF
@@ -147,6 +152,56 @@
}
}
}
+
+ /**
+ * Try to load user-definied ExpressionFactory. Returns <code>null</code>,
+ * if no custom ExpressionFactory was specified.
+ *
+ * @param externalContext the current ExternalContext
+ *
+ * @return User-specified ExpressionFactory, or
+ * <code>null</code>, if no no custom implementation was specified
+ *
+ */
+ protected static ExpressionFactory getUserDefinedExpressionFactory(ExternalContext externalContext)
+ {
+ String expressionFactoryClassName = externalContext.getInitParameter(EXPRESSION_FACTORY);
+ if (expressionFactoryClassName != null
+ && expressionFactoryClassName.trim().length() > 0) {
+ if (log.isDebugEnabled()) {
+ log.debug("Attempting to load the ExpressionFactory implementation "
+ + "you've specified: '" + expressionFactoryClassName + "'.");
+ }
+
+ return loadExpressionFactory(expressionFactoryClassName);
+ }
+
+ return null;
+ }
+
+ /**
+ * Loads and instantiates the given ExpressionFactory implementation.
+ *
+ * @param expressionFactoryClassName
+ * the class name of the ExpressionFactory implementation
+ *
+ * @return the newly created ExpressionFactory implementation, or
+ * <code>null</code>, if an error occurred
+ */
+ protected static ExpressionFactory loadExpressionFactory(String expressionFactoryClassName)
+ {
+ try {
+ Class<?> expressionFactoryClass = Class.forName(expressionFactoryClassName);
+ return (ExpressionFactory) expressionFactoryClass.newInstance();
+ } catch (Exception ex) {
+ if (log.isDebugEnabled()) {
+ log.debug("An error occured while instantiating a new ExpressionFactory. "
+ + "Attempted to load class '" + expressionFactoryClassName + "'.", ex);
+ }
+ }
+
+ return null;
+ }
/**
* Performs initialization tasks depending on the current environment.
Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/webapp/Jsp20FacesInitializer.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/webapp/Jsp20FacesInitializer.java?rev=779422&r1=779421&r2=779422&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/webapp/Jsp20FacesInitializer.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/webapp/Jsp20FacesInitializer.java Thu May 28 04:10:24 2009
@@ -41,11 +41,6 @@
private static final Log log = LogFactory.getLog(Jsp20FacesInitializer.class);
/**
- * This parameter specifies the ExpressionFactory implementation to use.
- */
- private static final String EXPRESSION_FACTORY = "org.apache.myfaces.EXPRESSION_FACTORY";
-
- /**
* The ExpressionFactory implementation of the EL-RI.
*/
private static final String EL_RI_EXPRESSION_FACTORY_IMPL = "com.sun.facelets.el.ExpressionFactoryImpl";
@@ -75,25 +70,11 @@
// there is no known ExpressionFactory available (i.e. if neither
// "com.sun.facelets.el.ExpressionFactoryImpl" nor "org.apache.el.ExpressionFactoryImpl"
// are available).
- ExpressionFactory expressionFactory = null;
-
- String expressionFactoryClassName = externalContext.getInitParameter(EXPRESSION_FACTORY);
- if (expressionFactoryClassName != null && expressionFactoryClassName.trim().length() > 0)
- {
- if (log.isDebugEnabled())
- {
- log.debug("Attempting to load the ExpressionFactory implementation " + "you've specified: '"
- + expressionFactoryClassName + "'.");
- }
+ ExpressionFactory expressionFactory = getUserDefinedExpressionFactory(externalContext);
- expressionFactory = loadExpressionFactory(expressionFactoryClassName);
- }
-
- if (expressionFactory == null)
- {
- if (log.isInfoEnabled())
- {
- log.info("Either you haven't specified the ExpressionFactory implementation, or an "
+ if (expressionFactory == null) {
+ if (log.isInfoEnabled()) {
+ log.info("Either you haven't specified the ExpressionFactory implementation, or an "
+ "error occured while instantiating the implementation you've specified. "
+ "However, attempting to load a known implementation.");
}
@@ -121,33 +102,6 @@
}
/**
- * Loads and instantiates the given ExpressionFactory implementation.
- *
- * @param expressionFactoryClassName
- * the class name of the ExpressionFactory implementation
- *
- * @return the newly created ExpressionFactory implementation, or <code>null</code>, if an error occurred
- */
- private static ExpressionFactory loadExpressionFactory(String expressionFactoryClassName)
- {
- try
- {
- Class<?> expressionFactoryClass = Class.forName(expressionFactoryClassName);
- return (ExpressionFactory)expressionFactoryClass.newInstance();
- }
- catch (Exception ex)
- {
- if (log.isDebugEnabled())
- {
- log.debug("An error occured while instantiating a new ExpressionFactory. "
- + "Attempted to load class '" + expressionFactoryClassName + "'.", ex);
- }
- }
-
- return null;
- }
-
- /**
* Attempts to find a valid ExpressionFactory implementation. Each of the given
* "ExpressionFactory implementation candidates" will be tried to instantiate. If an attempt succeeded, the
* ExpressionFactory implementation will be returned (i.e. the first valid ExpressionFactory implementation will be
Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/webapp/Jsp21FacesInitializer.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/webapp/Jsp21FacesInitializer.java?rev=779422&r1=779421&r2=779422&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/webapp/Jsp21FacesInitializer.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/webapp/Jsp21FacesInitializer.java Thu May 28 04:10:24 2009
@@ -20,6 +20,7 @@
import java.util.Iterator;
+import javax.el.ExpressionFactory;
import javax.faces.FactoryFinder;
import javax.faces.context.ExternalContext;
import javax.faces.event.PhaseListener;
@@ -61,8 +62,15 @@
getJspFactory().getJspApplicationContext(servletContext);
appCtx.addELContextListener(new FacesELContextListener());
- RuntimeConfig runtimeConfig =
- buildConfiguration(servletContext, externalContext, appCtx.getExpressionFactory());
+ // check for user-specified ExpressionFactory
+ ExpressionFactory expressionFactory = getUserDefinedExpressionFactory(externalContext);
+ if (expressionFactory == null)
+ {
+ expressionFactory = appCtx.getExpressionFactory();
+ }
+
+ RuntimeConfig runtimeConfig =
+ buildConfiguration(servletContext, externalContext, expressionFactory);
// configure the el resolver for jsp
configureResolverForJSP(appCtx, runtimeConfig);
Modified: myfaces/core/branches/2_0_0/impl/src/main/resources/META-INF/myfaces_core12.vm
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/resources/META-INF/myfaces_core12.vm?rev=779422&r1=779421&r2=779422&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/resources/META-INF/myfaces_core12.vm (original)
+++ myfaces/core/branches/2_0_0/impl/src/main/resources/META-INF/myfaces_core12.vm Thu May 28 04:10:24 2009
@@ -140,6 +140,10 @@
<deferred-value>
<type>java.lang.Object</type>
</deferred-value>
+#elseif ($property.className == "java.util.TimeZone" && $component.name == "f:convertDateTime")
+ <deferred-value>
+ <type>java.lang.Object</type>
+ </deferred-value>
#else
<deferred-value>
<type>$property.className</type>
Modified: myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/application/ApplicationImplTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/application/ApplicationImplTest.java?rev=779422&r1=779421&r2=779422&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/application/ApplicationImplTest.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/application/ApplicationImplTest.java Thu May 28 04:10:24 2009
@@ -19,8 +19,12 @@
package org.apache.myfaces.application;
import static org.apache.myfaces.test.AssertThrowables.assertThrowable;
-import static org.easymock.EasyMock.*;
-import static org.easymock.classextension.EasyMock.*;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.isNull;
+import static org.easymock.classextension.EasyMock.createMock;
+import static org.easymock.classextension.EasyMock.replay;
import java.util.ListResourceBundle;
import java.util.Locale;
@@ -31,10 +35,12 @@
import javax.el.ValueExpression;
import javax.faces.FacesException;
import javax.faces.application.Application;
+import javax.faces.component.UIComponent;
import javax.faces.component.UIOutput;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
import javax.faces.convert.EnumConverter;
import javax.faces.el.ReferenceSyntaxException;
import javax.faces.el.VariableResolver;
@@ -243,4 +249,50 @@
assertNotNull(converter);
assertEquals(converter.getClass(), EnumConverter.class);
}
+
+
+ private interface EnumCoded { public int getCode(); }
+ private enum AnotherEnum implements EnumCoded {
+ VALUE1, VALUE2;
+ public int getCode() {return 0;}
+ };
+
+ public static class EnumCodedTestConverter implements Converter
+ {
+
+ public EnumCodedTestConverter()
+ {
+ }
+
+ public Object getAsObject(FacesContext context, UIComponent component,
+ String value) throws ConverterException
+ {
+ return null;
+ }
+
+ public String getAsString(FacesContext context, UIComponent component,
+ Object value) throws ConverterException
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Test method for
+ * {@link javax.faces.application.Application#createConverter(java.lang.Class)}.
+ * <p>
+ * Tests the situation when a object is both, an enum and an implementor of an
+ * interface for which we have a specific converter registered.
+ * The interface should take precedence over the fact that our object is also
+ * an enum.
+ */
+ public void testCreateConverterForInterface() throws Exception
+ {
+ app.addConverter(Enum.class, EnumConverter.class.getName());
+ app.addConverter(EnumCoded.class, EnumCodedTestConverter.class.getName());
+
+ Converter converter = app.createConverter(AnotherEnum.class);
+ assertNotNull(converter);
+ assertEquals(converter.getClass(), EnumCodedTestConverter.class);
+ }
}
Modified: myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/config/annotation/AnnotationProcessorTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/config/annotation/AnnotationProcessorTestCase.java?rev=779422&r1=779421&r2=779422&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/config/annotation/AnnotationProcessorTestCase.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/config/annotation/AnnotationProcessorTestCase.java Thu May 28 04:10:24 2009
@@ -25,7 +25,7 @@
public class AnnotationProcessorTestCase extends AbstractJsfTestCase
{
- protected LifecycleProvider lifecycleProvider;
+ protected LifecycleProvider2 lifecycleProvider;
protected AnnotatedManagedBean managedBean;
@@ -43,6 +43,7 @@
public void testPostConstruct() throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException, ClassNotFoundException
{
AnnotatedManagedBean managedBean = (AnnotatedManagedBean) lifecycleProvider.newInstance(AnnotatedManagedBean.class.getName());
+ lifecycleProvider.postConstruct(managedBean);
assertTrue(managedBean.isPostConstructCalled());
assertFalse(managedBean.isPreDestroyCalled());
}
@@ -50,6 +51,7 @@
public void testPreDestroy() throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException, ClassNotFoundException
{
AnnotatedManagedBean managedBean = (AnnotatedManagedBean) lifecycleProvider.newInstance(AnnotatedManagedBean.class.getName());
+ lifecycleProvider.postConstruct(managedBean);
lifecycleProvider.destroyInstance(managedBean);
assertTrue(managedBean.isPostConstructCalled());
assertTrue(managedBean.isPreDestroyCalled());
Modified: myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextRendererTest.java?rev=779422&r1=779421&r2=779422&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextRendererTest.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextRendererTest.java Thu May 28 04:10:24 2009
@@ -21,8 +21,15 @@
import java.io.IOException;
import java.io.StringWriter;
+import javax.el.ValueExpression;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+import javax.faces.component.UIViewRoot;
import javax.faces.component.html.HtmlInputText;
import javax.faces.component.html.HtmlOutputText;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -30,6 +37,7 @@
import org.apache.myfaces.test.utils.HtmlCheckAttributesUtil;
import org.apache.myfaces.test.utils.HtmlRenderedAttr;
import org.apache.shale.test.base.AbstractJsfTestCase;
+import org.apache.shale.test.el.MockValueExpression;
import org.apache.shale.test.mock.MockRenderKitFactory;
import org.apache.shale.test.mock.MockResponseWriter;
@@ -108,4 +116,65 @@
fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
}
}
+
+ public void testWhenSubmittedValueIsNullDefaultShouldDissapearFromRendering() {
+ //See MYFACES-2161 and MYFACES-1549 for details
+ UIViewRoot root = new UIViewRoot();
+ UIForm form = new UIForm();
+ form.setId("formId");
+
+ form.getChildren().add(inputText);
+ root.getChildren().add(form);
+
+ Converter converter = new Converter()
+ {
+ public Object getAsObject(FacesContext context,
+ UIComponent component, String value)
+ throws ConverterException
+ {
+ if (value == null || "".equals(value))
+ return null;
+ else
+ return value;
+ }
+
+ public String getAsString(FacesContext context,
+ UIComponent component, Object value)
+ throws ConverterException
+ {
+ if (value == null)
+ return "";
+ else
+ return value.toString();
+ }
+ };
+
+ inputText.setConverter(converter);
+
+ ValueExpression expression = new MockValueExpression("#{requestScope.someDefaultValueOnBean}",String.class);
+ expression.setValue(facesContext.getELContext(), "defaultValue");
+ inputText.setValueExpression("value", expression);
+
+ // 1) user enters an empty string in an input-component: ""
+ //Call to setSubmittedValue on HtmlRendererUtils.decodeUIInput(facesContext, component),
+ //that is called from renderer decode()
+ facesContext.getExternalContext().getRequestParameterMap().put(inputText.getClientId(facesContext), "");
+
+ inputText.decode(facesContext);
+
+ // 2) conversion and validation phase: "" --> setValue(null);
+ // isLocalValueSet = true; setSubmittedValue(null);
+ inputText.validate(facesContext);
+
+ // 3) validation fails in some component on the page --> update model
+ // phase is skipped
+ // No OP
+
+ // 4) renderer calls getValue(); --> getValue() evaluates the
+ // value-binding, as the local-value is 'null', and I get the
+ // default-value of the bean shown again
+ assertNotSame(expression.getValue(facesContext.getELContext()), inputText.getValue());
+ assertNull(inputText.getValue());
+ }
+
}
Modified: myfaces/core/branches/2_0_0/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/pom.xml?rev=779422&r1=779421&r2=779422&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/pom.xml (original)
+++ myfaces/core/branches/2_0_0/pom.xml Thu May 28 04:10:24 2009
@@ -28,7 +28,7 @@
<url>http://svn.apache.org/repos/asf/myfaces/branches/2_0__x</url>
</scm>
<modules>
- <module>build</module>
+ <!-- module>build</module -->
<module>api</module>
<module>impl</module>
</modules>
@@ -154,7 +154,7 @@
<version>2.1</version>
</dependency>
<dependency>
- <groupId>jstl</groupId>
+ <groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<exclusions>