You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by jk...@apache.org on 2007/04/21 22:30:24 UTC

svn commit: r531103 - in /tapestry/tapestry4/trunk: tapestry-examples/TimeTracker/src/context/ tapestry-examples/TimeTracker/src/context/WEB-INF/ tapestry-framework/src/java/org/apache/tapestry/binding/ tapestry-framework/src/java/org/apache/tapestry/c...

Author: jkuhnert
Date: Sat Apr 21 13:30:23 2007
New Revision: 531103

URL: http://svn.apache.org/viewvc?view=rev&rev=531103
Log:
Spent the day with yourkit profiler again in an attempt to track down why the LocaleList page in the demo was taking so long to render on demo box. (somewhere around 500ms) 

-) Added a new pooled OgnlContext helper class that pools OgnlContext object creation as there is no need to just randomly create a bunch of context objects since OgnlContext.clear() works perfectly well for this purpose. 

-) Slight tweeks made to DirectService / Any / ComponentEventConnectionWorker where it was clear that they were doing certain bad things to cause unneccessary overhead. 

-) Started doing more logic in ExpressionBinding to handle the different stages of compilation (ie when expression can't be fully evaluated because of a null thus preventing compilation ). Added a compilation step (with backing off strategy) for expressions where only a setter is implemented.

Added:
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/PoolableOgnlContextFactory.java
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/util/io/SerializableAdaptorTest.java
Modified:
    tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/LocaleList.html
    tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/WEB-INF/log4j.properties
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/ExpressionBinding.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/Any.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/Any.jwc
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/DirectService.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ComponentEventConnectionWorker.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ExpressionEvaluatorImpl.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/HiveMindExpressionCompiler.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/RegexpMatcher.java
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestExpressionBinding.java
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/components/TestAny.java
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/DirectServiceTest.java
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/TestExpressionEvaluator.java

Modified: tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/LocaleList.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/LocaleList.html?view=diff&rev=531103&r1=531102&r2=531103
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/LocaleList.html (original)
+++ tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/LocaleList.html Sat Apr 21 13:30:23 2007
@@ -111,7 +111,7 @@
     </div>
     <p>
     <a jwcid="localeLink@DirectLink" listener="listener:selectLocale" parameters="ognl:{currLocale.language, currLocale.country, currLocale.variant}"
-       updateComponents="ognl:{'localeDetail',page.components.localeList.clientId}">
+       updateComponents="ognl:{'localeDetail',page.components.localeList.clientId}" stateful="ognl:false">
         <span jwcid="@Insert" value="ognl:currLocale.toString()" />
     </a>
     </p>

Modified: tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/WEB-INF/log4j.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/WEB-INF/log4j.properties?view=diff&rev=531103&r1=531102&r2=531103
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/WEB-INF/log4j.properties (original)
+++ tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/WEB-INF/log4j.properties Sat Apr 21 13:30:23 2007
@@ -32,6 +32,7 @@
 log4j.logger.org.apache.tapestry.form=DEBUG
 log4j.logger.org.apache.tapestry.form.FormSupportImpl=DEBUG
 
+#log4j.logger.org.apache.tapestry.services.impl.HiveMindExpressionCompiler=DEBUG
 #log4j.logger.tapestry.services.Asset=DEBUG
 #log4j.logger.tapestry.globals.ResponseBuilder=DEBUG
 #log4j.logger.org.apache.tapestry.services.impl.DojoAjaxResponseBuilder=DEBUG

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/ExpressionBinding.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/ExpressionBinding.java?view=diff&rev=531103&r1=531102&r2=531103
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/ExpressionBinding.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/ExpressionBinding.java Sat Apr 21 13:30:23 2007
@@ -81,6 +81,8 @@
 
     private ExpressionCache _cache;
 
+    private boolean _writeFailed;
+
     /**
      * Creates a {@link ExpressionBinding}from the root object and an OGNL expression.
      */
@@ -115,7 +117,7 @@
     {
         try
         {
-            if (_accessor == null) {
+            if (_accessor == null && !_writeFailed) {
                 
                 _parsedExpression = (Node)_cache.getCompiledExpression(_root, _expression);
                 
@@ -185,10 +187,26 @@
         
         try
         {
-            if (_accessor == null) {
+            if (_accessor == null && !_writeFailed) {
                 
                 _evaluator.writeCompiled(_root, _parsedExpression, value);
-            } else 
+
+                // re-parse expression as compilation may be possible now that it potentially has a value
+                try {
+                    _parsedExpression = (Node)_cache.getCompiledExpression(_root, _expression);
+
+                    _accessor = _parsedExpression.getAccessor();
+                } catch (Throwable t) {
+                    
+                    // ignore re-read failures as they aren't supposed to be happening now anyways
+                    // and a more user friendly version will be available if someone actually calls
+                    // getObject
+
+                    // if writing fails then we're probably screwed...so don't do it again
+                    if (value != null)
+                        _writeFailed = true;
+                }
+            } else
                 _evaluator.write(_root, _accessor, value);
         }
         catch (Throwable ex)

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/Any.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/Any.java?view=diff&rev=531103&r1=531102&r2=531103
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/Any.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/Any.java Sat Apr 21 13:30:23 2007
@@ -14,7 +14,6 @@
 
 package org.apache.tapestry.components;
 
-import org.apache.hivemind.ApplicationRuntimeException;
 import org.apache.tapestry.AbstractComponent;
 import org.apache.tapestry.IMarkupWriter;
 import org.apache.tapestry.IRequestCycle;
@@ -23,18 +22,13 @@
  * A component that can substitute for any HTML element. [<a
  * href="../../../../../ComponentReference/Any.html">Component Reference</a>]
  * 
- * @author Howard Lewis Ship
  */
 
 public abstract class Any extends AbstractComponent
 {
     protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
     {
-        String element = getElement();
-        
-        if (element == null)
-            throw new ApplicationRuntimeException(ComponentMessages.anyElementNotDefined(), this,
-                    null, null);
+        String element = isParameterBound("element") ? getElement() : getTemplateTagName();
         
         boolean rewinding = cycle.isRewinding();
         

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/Any.jwc
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/Any.jwc?view=diff&rev=531103&r1=531102&r2=531103
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/Any.jwc (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/Any.jwc Sat Apr 21 13:30:23 2007
@@ -25,7 +25,7 @@
   informal parameters).
   </description>
   
-  <parameter name="element" default-value="ognl:templateTagName" >
+  <parameter name="element" >
   	<description>
   	The element to emulate.
   	</description>

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/DirectService.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/DirectService.java?view=diff&rev=531103&r1=531102&r2=531103
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/DirectService.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/DirectService.java Sat Apr 21 13:30:23 2007
@@ -14,18 +14,9 @@
 
 package org.apache.tapestry.engine;
 
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
 import org.apache.hivemind.ApplicationRuntimeException;
 import org.apache.hivemind.util.Defense;
-import org.apache.tapestry.IComponent;
-import org.apache.tapestry.IDirect;
-import org.apache.tapestry.IPage;
-import org.apache.tapestry.IRequestCycle;
-import org.apache.tapestry.StaleSessionException;
-import org.apache.tapestry.Tapestry;
+import org.apache.tapestry.*;
 import org.apache.tapestry.event.BrowserEvent;
 import org.apache.tapestry.services.LinkFactory;
 import org.apache.tapestry.services.ResponseRenderer;
@@ -33,6 +24,10 @@
 import org.apache.tapestry.web.WebRequest;
 import org.apache.tapestry.web.WebSession;
 
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * Implementation of the direct service, which encodes the page and component id in the service
  * context, and passes application-defined parameters as well.
@@ -62,6 +57,7 @@
         DirectServiceParameter dsp = (DirectServiceParameter) parameter;
 
         IComponent component = dsp.getDirect();
+        IDirect direct = dsp.getDirect();
 
         // New since 1.0.1, we use the component to determine
         // the page, not the cycle. Through the use of tricky
@@ -75,7 +71,7 @@
         IPage componentPage = component.getPage();
         
         Map parameters = new HashMap();
-        
+
         boolean stateful = _request.getSession(false) != null;
         
         parameters.put(ServiceConstants.PAGE, activePage.getPageName());
@@ -98,7 +94,7 @@
         
         parameters.put(ServiceConstants.PARAMETER, dsp.getServiceParameters());
         
-        return _linkFactory.constructLink(this, post, parameters, true);
+        return _linkFactory.constructLink(this, post, parameters, direct.isStateful());
     }
 
     public void service(IRequestCycle cycle) throws IOException

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ComponentEventConnectionWorker.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ComponentEventConnectionWorker.java?view=diff&rev=531103&r1=531102&r2=531103
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ComponentEventConnectionWorker.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ComponentEventConnectionWorker.java Sat Apr 21 13:30:23 2007
@@ -133,7 +133,7 @@
     ComponentEventProperty[] getComponentEvents(IComponent comp)
     {
         List listeners = _invoker.getEventListeners(comp.getId());
-        if (listeners == null)
+        if (listeners == null || listeners.size() < 1)
             return null;
 
         if (IFormComponent.class.isInstance(comp)) {

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ExpressionEvaluatorImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ExpressionEvaluatorImpl.java?view=diff&rev=531103&r1=531102&r2=531103
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ExpressionEvaluatorImpl.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ExpressionEvaluatorImpl.java Sat Apr 21 13:30:23 2007
@@ -16,6 +16,8 @@
 
 import ognl.*;
 import ognl.enhance.ExpressionAccessor;
+import org.apache.commons.pool.impl.GenericKeyedObjectPool;
+import org.apache.commons.pool.impl.GenericObjectPool;
 import org.apache.hivemind.ApplicationRuntimeException;
 import org.apache.hivemind.service.ClassFactory;
 import org.apache.tapestry.Tapestry;
@@ -28,11 +30,16 @@
 import java.util.Map;
 
 /**
- * @author Howard M. Lewis Ship
  * @since 4.0
  */
 public class ExpressionEvaluatorImpl implements ExpressionEvaluator
 {
+    private static final int POOL_MAX_ACTIVE = 200;
+
+    private static final long POOL_MIN_IDLE_TIME = 1000 * 60 * 2;
+
+    private static final long POOL_SLEEP_TIME = 1000 * 60 * 4;
+
     // Uses Thread's context class loader
 
     private final ClassResolver _ognlResolver = new OgnlClassResolver();
@@ -53,7 +60,9 @@
     private Map _defaultContext;
     
     private ClassFactory _classFactory;
-    
+
+    private GenericObjectPool _contextPool;
+
     public void setApplicationSpecification(IApplicationSpecification applicationSpecification)
     {
         _applicationSpecification = applicationSpecification;
@@ -62,8 +71,7 @@
     public void initializeService()
     {
         if (_applicationSpecification.checkExtension(Tapestry.OGNL_TYPE_CONVERTER))
-            _typeConverter = (TypeConverter) _applicationSpecification.getExtension(
-                    Tapestry.OGNL_TYPE_CONVERTER,
+            _typeConverter = (TypeConverter) _applicationSpecification.getExtension(Tapestry.OGNL_TYPE_CONVERTER,
                     TypeConverter.class);
 
         Iterator i = _contributions.iterator();
@@ -82,11 +90,16 @@
             NullHandlerContribution h = (NullHandlerContribution) j.next();
             
             OgnlRuntime.setNullHandler(h.getSubjectClass(), h.getHandler());
-        }        
+        }
         
         _defaultContext = Ognl.createDefaultContext(null, _ognlResolver, _typeConverter);
         
         OgnlRuntime.setCompiler(new HiveMindExpressionCompiler(_classFactory));
+        
+        _contextPool = new GenericObjectPool(new PoolableOgnlContextFactory(_ognlResolver, _typeConverter), POOL_MAX_ACTIVE, GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW, -1);
+        _contextPool.setMaxIdle(POOL_MAX_ACTIVE / 2);
+        _contextPool.setMinEvictableIdleTimeMillis(POOL_MIN_IDLE_TIME);
+        _contextPool.setTimeBetweenEvictionRunsMillis(POOL_SLEEP_TIME);
     }
 
     public Object read(Object target, String expression)
@@ -101,9 +114,11 @@
 
     public Object readCompiled(Object target, Object expression)
     {
+        OgnlContext context = null;
         try
         {
-            Map context = createContext(target);
+            context = (OgnlContext)_contextPool.borrowObject();
+            context.setRoot(target);
 
             return Ognl.getValue(expression, context, target);
         }
@@ -111,14 +126,17 @@
         {
             throw new ApplicationRuntimeException(ImplMessages.unableToReadExpression(ImplMessages
                     .parsedExpression(), target, ex), target, null, ex);
+        } finally {
+            try { if (context != null) _contextPool.returnObject(context); } catch (Exception e) {}
         }
     }
     
     public Object read(Object target, ExpressionAccessor expression)
     {
+        OgnlContext context = null;
         try
         {
-            OgnlContext context = createContext(target);
+            context = (OgnlContext)_contextPool.borrowObject();
             
             return expression.get(context, target);
         }
@@ -126,6 +144,8 @@
         {
             throw new ApplicationRuntimeException(ImplMessages.unableToReadExpression(ImplMessages
                     .parsedExpression(), target, ex), target, null, ex);
+        } finally {
+            try { if (context != null) _contextPool.returnObject(context); } catch (Exception e) {}
         }
     }
     
@@ -146,9 +166,10 @@
 
     public void write(Object target, ExpressionAccessor expression, Object value)
     {
+        OgnlContext context = null;
         try
         {
-            OgnlContext context = createContext(target);
+            context = (OgnlContext)_contextPool.borrowObject();
             
             expression.set(context, target, value);
         }
@@ -156,15 +177,17 @@
         {
             throw new ApplicationRuntimeException(ImplMessages.unableToWriteExpression(ImplMessages
                     .parsedExpression(), target, value, ex), target, null, ex);
+        } finally {
+            try { if (context != null) _contextPool.returnObject(context); } catch (Exception e) {}
         }
-
     }
     
     public void writeCompiled(Object target, Object expression, Object value)
     {
+        OgnlContext context = null;
         try
         {
-            Map context = createContext(target);
+            context = (OgnlContext)_contextPool.borrowObject();
 
             Ognl.setValue(expression, context, target, value);
         }
@@ -172,8 +195,9 @@
         {
             throw new ApplicationRuntimeException(ImplMessages.unableToWriteExpression(ImplMessages
                     .parsedExpression(), target, value, ex), target, null, ex);
+        } finally {
+            try { if (context != null) _contextPool.returnObject(context); } catch (Exception e) {}
         }
-
     }
     
     public boolean isConstant(Object target, String expression)

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/HiveMindExpressionCompiler.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/HiveMindExpressionCompiler.java?view=diff&rev=531103&r1=531102&r2=531103
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/HiveMindExpressionCompiler.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/HiveMindExpressionCompiler.java Sat Apr 21 13:30:23 2007
@@ -151,7 +151,7 @@
 
             } catch (UnsupportedCompilationException uc) {
 
-                uc.printStackTrace();
+                // uc.printStackTrace();
                 // The target object may not fully resolve yet because of a partial tree with a null somewhere, we
                 // don't want to bail out forever because it might be enhancable on another pass eventually
                 return;

Added: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/PoolableOgnlContextFactory.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/PoolableOgnlContextFactory.java?view=auto&rev=531103
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/PoolableOgnlContextFactory.java (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/PoolableOgnlContextFactory.java Sat Apr 21 13:30:23 2007
@@ -0,0 +1,40 @@
+package org.apache.tapestry.services.impl;
+
+import ognl.ClassResolver;
+import ognl.Ognl;
+import ognl.OgnlContext;
+import ognl.TypeConverter;
+import org.apache.commons.pool.BasePoolableObjectFactory;
+
+/**
+ * Used by {@link ExpressionEvaluatorImpl} to pool {@link ognl.OgnlContext} objects.
+ */
+public class PoolableOgnlContextFactory extends BasePoolableObjectFactory {
+
+    private final ClassResolver _resolver;
+
+    private TypeConverter _typeConverter;
+
+    public PoolableOgnlContextFactory(ClassResolver resolver, TypeConverter typeConverter)
+    {
+        _resolver = resolver;
+        _typeConverter = typeConverter;
+    }
+
+    public Object makeObject()
+        throws Exception
+    {
+        return Ognl.createDefaultContext(null, _resolver, _typeConverter);
+    }
+
+    public void activateObject(Object obj)
+    throws Exception
+    {
+        OgnlContext context = (OgnlContext)obj;
+        
+        if (context.getRoot() != null || context.getValues().size() > 0) {
+            context.clear();
+            context.setRoot(null);
+        }
+    }
+}

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/RegexpMatcher.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/RegexpMatcher.java?view=diff&rev=531103&r1=531102&r2=531103
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/RegexpMatcher.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/RegexpMatcher.java Sat Apr 21 13:30:23 2007
@@ -49,7 +49,7 @@
         _pool = new GenericKeyedObjectPool(_factory, MAX_ACTIVE, GenericKeyedObjectPool.WHEN_EXHAUSTED_BLOCK, -1);
         
         _pool.setMaxIdle(MAX_ACTIVE / 2);
-        _pool.setMinEvictableIdleTimeMillis(MAX_ACTIVE);
+        _pool.setMinEvictableIdleTimeMillis(SLEEP_TIME);
         _pool.setTimeBetweenEvictionRunsMillis(SLEEP_TIME);
     }
     

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestExpressionBinding.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestExpressionBinding.java?view=diff&rev=531103&r1=531102&r2=531103
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestExpressionBinding.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestExpressionBinding.java Sat Apr 21 13:30:23 2007
@@ -139,12 +139,16 @@
         ValueConverter vc = newValueConverter();
         
         expect(ec.getCompiledExpression("exp")).andReturn(compiled);
-        
+
         expect(ev.isConstant("exp")).andReturn(false);
 
         Object newValue = new Object();
 
         ev.writeCompiled(component, compiled, newValue);
+
+        expect(ec.getCompiledExpression(component, "exp")).andReturn(compiled);
+
+        expect(compiled.getAccessor()).andReturn(null);
 
         replay();
 

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/components/TestAny.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/components/TestAny.java?view=diff&rev=531103&r1=531102&r2=531103
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/components/TestAny.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/components/TestAny.java Sat Apr 21 13:30:23 2007
@@ -14,64 +14,25 @@
 
 package org.apache.tapestry.components;
 
-import static org.easymock.EasyMock.expect;
-
-import org.apache.hivemind.ApplicationRuntimeException;
-import org.apache.hivemind.Location;
-import org.apache.tapestry.BaseComponentTestCase;
-import org.apache.tapestry.IBinding;
-import org.apache.tapestry.IMarkupWriter;
-import org.apache.tapestry.IRender;
-import org.apache.tapestry.IRequestCycle;
+import org.apache.tapestry.*;
 import org.apache.tapestry.spec.ComponentSpecification;
+import static org.easymock.EasyMock.expect;
 import org.testng.annotations.Test;
 
 /**
  * Tests for the {@link org.apache.tapestry.components.Any} component.
  * 
- * @author Howard M. Lewis Ship
- * @since 4.0
  */
 @Test
 public class TestAny extends BaseComponentTestCase
 {
 
-    public void testElementNull()
-    {
-        IMarkupWriter writer = newWriter();
-        IRequestCycle cycle = newMock(IRequestCycle.class);
-        Location l = newLocation();
-        
-        Any any = newInstance(Any.class, new Object[] { "location", l });
-        
-        expect(cycle.renderStackPush(any)).andReturn(any);
-        
-        expect(cycle.renderStackPop()).andReturn(any);
-        
-        replay();
-
-        try
-        {
-            any.render(writer, cycle);
-            unreachable();
-        }
-        catch (ApplicationRuntimeException ex)
-        {
-            assertEquals(ComponentMessages.anyElementNotDefined(), ex
-                    .getMessage());
-            assertSame(l, ex.getLocation());
-        }
-
-        verify();
-    }
-
     public void testRender()
     {
         IMarkupWriter writer = newWriter();
         IRequestCycle cycle = newCycle(false, writer);
         
-        Any any = newInstance(Any.class,
-                new Object[] { "element", "span" });
+        Any any = newInstance(Any.class, new Object[] { "templateTagName", "span" });
         
         expect(cycle.renderStackPush(any)).andReturn(any);
         
@@ -100,8 +61,7 @@
         IRender body = newRender();
         IBinding binding = newBinding("fred");
         
-        Any any = newInstance(Any.class, new Object[] { "element",
-            "span", "specification", new ComponentSpecification() });
+        Any any = newInstance(Any.class, "templateTagName", "span", "specification", new ComponentSpecification());
         
         expect(cycle.renderStackPush(any)).andReturn(any);
         
@@ -130,8 +90,7 @@
         IRequestCycle cycle = newCycle(true, writer);
         IRender body = newRender();
         
-        Any any = newInstance(Any.class,
-                new Object[] { "element", "span" });
+        Any any = newInstance(Any.class, new Object[] { "templateTagName", "span" });
         
         expect(cycle.renderStackPush(any)).andReturn(any);
         

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/DirectServiceTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/DirectServiceTest.java?view=diff&rev=531103&r1=531102&r2=531103
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/DirectServiceTest.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/DirectServiceTest.java Sat Apr 21 13:30:23 2007
@@ -14,29 +14,22 @@
 
 package org.apache.tapestry.engine;
 
-import static org.easymock.EasyMock.checkOrder;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.isA;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
 import org.apache.hivemind.ApplicationRuntimeException;
 import org.apache.hivemind.Location;
-import org.apache.tapestry.IComponent;
-import org.apache.tapestry.IDirect;
-import org.apache.tapestry.IPage;
-import org.apache.tapestry.IRequestCycle;
-import org.apache.tapestry.StaleSessionException;
+import org.apache.tapestry.*;
 import org.apache.tapestry.event.BrowserEvent;
 import org.apache.tapestry.services.LinkFactory;
 import org.apache.tapestry.services.ResponseRenderer;
 import org.apache.tapestry.services.ServiceConstants;
 import org.apache.tapestry.web.WebRequest;
 import org.apache.tapestry.web.WebSession;
+import static org.easymock.EasyMock.*;
 import org.testng.annotations.Test;
 
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * Tests for {@link org.apache.tapestry.engine.DirectService}.
  * 
@@ -52,9 +45,11 @@
         
         if (checkParameters) {
             checkOrder(c, false);
+
             expect(c.getUpdateComponents()).andReturn(Collections.EMPTY_LIST);
             expect(c.isJson()).andReturn(false);
             expect(c.isAsync()).andReturn(false);
+            expect(c.isStateful()).andReturn(true);
         }
         
         return c;

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/TestExpressionEvaluator.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/TestExpressionEvaluator.java?view=diff&rev=531103&r1=531102&r2=531103
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/TestExpressionEvaluator.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/TestExpressionEvaluator.java Sat Apr 21 13:30:23 2007
@@ -28,8 +28,6 @@
 import java.util.Date;
 
 /**
- * @author Howard M. Lewis Ship
- * @since 4.0
  */
 @Test
 public class TestExpressionEvaluator extends BaseComponentTestCase
@@ -72,16 +70,17 @@
         }
     }
 
-    public void testRead()
+    public void test_Read()
     {
         Fixture f = new Fixture("Foo");
 
         ExpressionEvaluator ee = create();
+        trainIntialize(ee);
 
         assertEquals("Foo", ee.read(f, "value"));
     }
 
-    public void testReadFail()
+    public void test_Read_Fail()
     {
         Fixture f = new Fixture();
 
@@ -98,18 +97,19 @@
         }
     }
 
-    public void testWrite()
+    public void test_Write()
     {
         Fixture f = new Fixture("Foo");
 
         ExpressionEvaluator ee = create();
-
+        trainIntialize(ee);
+        
         ee.write(f, "value", "Bar");
 
         assertEquals("Bar", f.getValue());
     }
 
-    public void testWriteFail()
+    public void test_Write_Fail()
     {
         Fixture f = new Fixture();
 
@@ -127,7 +127,7 @@
         }
     }
 
-    public void testIsConstant()
+    public void test_Is_Constant()
     {
         ExpressionEvaluatorImpl ee = create();
 
@@ -157,7 +157,7 @@
         return spec;
     }
 
-    public void testIsConstantFail()
+    public void test_Is_Constant_Fail()
     {
         ExpressionEvaluator ee = create();
 
@@ -173,7 +173,27 @@
 
     }
 
-    public void testTypeConverter() throws Exception
+    void trainIntialize(ExpressionEvaluator evaluator)
+    {
+        ExpressionEvaluatorImpl impl = (ExpressionEvaluatorImpl)evaluator;
+        
+        IApplicationSpecification as = newMock(IApplicationSpecification.class);
+
+        expect(as.checkExtension(Tapestry.OGNL_TYPE_CONVERTER)).andReturn(false);
+
+        impl.setApplicationSpecification(as);
+        impl.setContributions(Collections.EMPTY_LIST);
+        impl.setNullHandlerContributions(Collections.EMPTY_LIST);
+        impl.setClassFactory(new ClassFactoryImpl());
+
+        replay();
+
+        impl.initializeService();
+
+        verify();
+    }
+
+    public void test_Type_Converter() throws Exception
     {
         IApplicationSpecification as = newMock(IApplicationSpecification.class);
         

Added: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/util/io/SerializableAdaptorTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/util/io/SerializableAdaptorTest.java?view=auto&rev=531103
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/util/io/SerializableAdaptorTest.java (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/util/io/SerializableAdaptorTest.java Sat Apr 21 13:30:23 2007
@@ -0,0 +1,23 @@
+package org.apache.tapestry.util.io;
+
+import com.javaforge.tapestry.testng.TestBase;
+import org.testng.annotations.Test;
+
+import java.util.Locale;
+
+/**
+ *
+ */
+@Test
+public class SerializableAdaptorTest extends TestBase {
+
+    public void test_Squeeze()
+    {
+        SerializableAdaptor squeezer = new SerializableAdaptor();
+
+        String data = squeezer.squeeze(null, Locale.getDefault());
+
+        assert data != null;
+        assert data.length() > 0;
+    }
+}