You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by jk...@apache.org on 2007/06/16 19:08:52 UTC
svn commit: r547953 - in /tapestry/tapestry4/trunk/tapestry-framework/src:
descriptor/META-INF/tapestry.ognl.xml
java/org/apache/tapestry/enhance/ClassFactoryImpl.java
java/org/apache/tapestry/services/impl/ExpressionCacheImpl.java
Author: jkuhnert
Date: Sat Jun 16 10:08:51 2007
New Revision: 547953
URL: http://svn.apache.org/viewvc?view=rev&rev=547953
Log:
Final touches on dev mode class caching semantics to handle new ognl runtime class inspector.
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/descriptor/META-INF/tapestry.ognl.xml
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/enhance/ClassFactoryImpl.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ExpressionCacheImpl.java
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/descriptor/META-INF/tapestry.ognl.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/descriptor/META-INF/tapestry.ognl.xml?view=diff&rev=547953&r1=547952&r2=547953
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/descriptor/META-INF/tapestry.ognl.xml (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/descriptor/META-INF/tapestry.ognl.xml Sat Jun 16 10:08:51 2007
@@ -35,7 +35,7 @@
<service-point id="ExpressionCache" interface="ExpressionCache">
<invoke-factory>
- <construct class="impl.ExpressionCacheImpl">
+ <construct class="impl.ExpressionCacheImpl" initialize-method="initializeService">
<event-listener service-id="tapestry.ResetEventHub"/>
<event-listener service-id="tapestry.describe.ReportStatusHub"/>
<set-service property="evaluator" service-id="ExpressionEvaluator"/>
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/enhance/ClassFactoryImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/enhance/ClassFactoryImpl.java?view=diff&rev=547953&r1=547952&r2=547953
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/enhance/ClassFactoryImpl.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/enhance/ClassFactoryImpl.java Sat Jun 16 10:08:51 2007
@@ -26,7 +26,7 @@
*/
public class ClassFactoryImpl implements ClassFactory, ResetEventListener {
- static final int EXPIRED_CLASS_COUNT = 100;
+ static final int EXPIRED_CLASS_COUNT = 120;
/**
* ClassPool shared by all modules (all CtClassSource instances).
@@ -49,10 +49,7 @@
}
catch (Exception ex)
{
- throw new ApplicationRuntimeException(EnhanceMessages.unableToCreateClass(
- name,
- superClass,
- ex), ex);
+ throw new ApplicationRuntimeException(EnhanceMessages.unableToCreateClass(name, superClass, ex), ex);
}
}
@@ -70,30 +67,24 @@
}
catch (Exception ex)
{
- throw new ApplicationRuntimeException(
- EnhanceMessages.unableToCreateInterface(name, ex), ex);
+ throw new ApplicationRuntimeException(EnhanceMessages.unableToCreateInterface(name, ex), ex);
}
}
public void resetEventDidOccur()
{
- _classCounter = 0;
+ if (_classCounter >= EXPIRED_CLASS_COUNT)
+ {
+ _classCounter = 0;
- _pool = new HiveMindClassPool();
- _classSource.setPool(_pool);
+ _pool = new HiveMindClassPool();
+ _classSource.setPool(_pool);
+ }
}
void checkPoolExpiration()
{
_classCounter++;
-
- synchronized(_classSource) {
- if (_classCounter >= EXPIRED_CLASS_COUNT) {
- _pool.clearImportedPackages();
-
- _classCounter = 0;
- }
- }
}
}
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ExpressionCacheImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ExpressionCacheImpl.java?view=diff&rev=547953&r1=547952&r2=547953
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ExpressionCacheImpl.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ExpressionCacheImpl.java Sat Jun 16 10:08:51 2007
@@ -15,15 +15,19 @@
package org.apache.tapestry.services.impl;
import edu.emory.mathcs.backport.java.util.concurrent.locks.ReentrantLock;
+import ognl.ClassCacheInspector;
import ognl.Node;
import ognl.Ognl;
+import ognl.OgnlRuntime;
import org.apache.hivemind.ApplicationRuntimeException;
+import org.apache.tapestry.AbstractComponent;
import org.apache.tapestry.event.ReportStatusEvent;
import org.apache.tapestry.event.ReportStatusListener;
import org.apache.tapestry.event.ResetEventListener;
import org.apache.tapestry.services.ExpressionCache;
import org.apache.tapestry.services.ExpressionEvaluator;
+import java.beans.Introspector;
import java.util.HashMap;
import java.util.Map;
import java.util.WeakHashMap;
@@ -32,8 +36,8 @@
* @author Howard M. Lewis Ship
* @since 4.0
*/
-public class ExpressionCacheImpl implements ExpressionCache, ResetEventListener, ReportStatusListener {
-
+public class ExpressionCacheImpl implements ExpressionCache, ResetEventListener, ReportStatusListener, ClassCacheInspector {
+
private final ReentrantLock _lock = new ReentrantLock();
private String _serviceId;
@@ -43,7 +47,17 @@
private Map _objectCache = new WeakHashMap();
private ExpressionEvaluator _evaluator;
-
+
+ private final boolean _cachingDisabled = Boolean.getBoolean("org.apache.tapestry.disable-caching");
+
+ public void initializeService()
+ {
+ if (_cachingDisabled)
+ {
+ OgnlRuntime.setClassCacheInspector(this);
+ }
+ }
+
public void resetEventDidOccur()
{
try {
@@ -52,10 +66,22 @@
_cache.clear();
_objectCache.clear();
+
+ Introspector.flushCaches();
+
} finally {
_lock.unlock();
}
+ }
+
+ public boolean shouldCache(Class type)
+ {
+ if (!_cachingDisabled || type == null
+ || AbstractComponent.class.isAssignableFrom(type))
+ return false;
+
+ return true;
}
public void reportStatus(ReportStatusEvent event)