tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r1094828 - in /tapestry/tapestry5/trunk: tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ tapestry-core/src/main/java/org/apache/tapestry5/services/ tapestry-core/src/test/java/org/apache/tapestry5/integration/reload/serv...
Date Tue, 19 Apr 2011 00:18:40 GMT
Author: hlship
Date: Tue Apr 19 00:18:40 2011
New Revision: 1094828

URL: http://svn.apache.org/viewvc?rev=1094828&view=rev
Log:
TAP5-1508: Disable the UpdateListenerHub and CheckForUpdatesFilter when in production mode

Added:
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ForceDevelopmentModeModule.java
      - copied, changed from r1094827, tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/reload/services/AppModule.java
Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/CheckForUpdatesFilter.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/reload/services/AppModule.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentInstantiatorSourceImplTest.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/test/InternalBaseTestCase.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/services/UpdateListenerHub.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/CheckForUpdatesFilter.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/CheckForUpdatesFilter.java?rev=1094828&r1=1094827&r2=1094828&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/CheckForUpdatesFilter.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/CheckForUpdatesFilter.java
Tue Apr 19 00:18:40 2011
@@ -1,10 +1,10 @@
-// Copyright 2006, 2007, 2008, 2009 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2009, 2011 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
 // You may obtain a copy of the License at
 //
-//     http://www.apache.org/licenses/LICENSE-2.0
+// http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing, software
 // distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,9 +14,13 @@
 
 package org.apache.tapestry5.internal.services;
 
+import org.apache.tapestry5.SymbolConstants;
 import org.apache.tapestry5.internal.util.Holder;
 import org.apache.tapestry5.ioc.Invokable;
+import org.apache.tapestry5.ioc.annotations.IntermediateType;
+import org.apache.tapestry5.ioc.annotations.Symbol;
 import org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier;
+import org.apache.tapestry5.ioc.util.TimeInterval;
 import org.apache.tapestry5.services.*;
 
 import java.io.IOException;
@@ -60,11 +64,22 @@ public class CheckForUpdatesFilter imple
     private long lastCheck = 0;
 
     /**
-     * @param updateListenerHub invoked, at intervals, to spur the process of detecting changes
-     * @param checkInterval     interval, in milliseconds, between checks
-     * @param updateTimeout     time, in  milliseconds, to wait to obtain update lock.
+     * @param updateListenerHub
+     *            invoked, at intervals, to spur the process of detecting changes
+     * @param checkInterval
+     *            interval, in milliseconds, between checks
+     * @param updateTimeout
+     *            time, in milliseconds, to wait to obtain update lock.
      */
-    public CheckForUpdatesFilter(UpdateListenerHub updateListenerHub, long checkInterval,
long updateTimeout)
+    public CheckForUpdatesFilter(UpdateListenerHub updateListenerHub,
+
+    @Symbol(SymbolConstants.FILE_CHECK_INTERVAL)
+    @IntermediateType(TimeInterval.class)
+    long checkInterval,
+
+    @Symbol(SymbolConstants.FILE_CHECK_UPDATE_TIMEOUT)
+    @IntermediateType(TimeInterval.class)
+    long updateTimeout)
     {
         this.updateListenerHub = updateListenerHub;
         this.checkInterval = checkInterval;
@@ -97,12 +112,14 @@ public class CheckForUpdatesFilter imple
             }
         };
 
-        // Obtain a read lock while handling the request. This will not impair parallel operations,
except when a file check
+        // Obtain a read lock while handling the request. This will not impair parallel operations,
except when a file
+        // check
         // is needed (the exclusive write lock will block threads attempting to get a read
lock).
 
         boolean result = barrier.withRead(invokable);
 
-        if (exceptionHolder.hasValue()) throw exceptionHolder.get();
+        if (exceptionHolder.hasValue())
+            throw exceptionHolder.get();
 
         return result;
     }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java?rev=1094828&r1=1094827&r2=1094828&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
Tue Apr 19 00:18:40 2011
@@ -197,6 +197,7 @@ import org.apache.tapestry5.ioc.services
 import org.apache.tapestry5.ioc.services.ClassFactory;
 import org.apache.tapestry5.ioc.services.Coercion;
 import org.apache.tapestry5.ioc.services.CoercionTuple;
+import org.apache.tapestry5.ioc.services.DefaultImplementationBuilder;
 import org.apache.tapestry5.ioc.services.LazyAdvisor;
 import org.apache.tapestry5.ioc.services.MasterObjectProvider;
 import org.apache.tapestry5.ioc.services.PerthreadManager;
@@ -204,6 +205,7 @@ import org.apache.tapestry5.ioc.services
 import org.apache.tapestry5.ioc.services.PlasticProxyFactory;
 import org.apache.tapestry5.ioc.services.PropertyAccess;
 import org.apache.tapestry5.ioc.services.PropertyShadowBuilder;
+import org.apache.tapestry5.ioc.services.ServiceOverride;
 import org.apache.tapestry5.ioc.services.StrategyBuilder;
 import org.apache.tapestry5.ioc.services.SymbolSource;
 import org.apache.tapestry5.ioc.services.ThreadLocale;
@@ -999,7 +1001,8 @@ public final class TapestryModule
      * the request</dd>
      * <dt>CheckForUpdates</dt>
      * <dd>Periodically fires events that checks to see if the file system sources
for any cached data has changed (see
-     * {@link org.apache.tapestry5.internal.services.CheckForUpdatesFilter}).
+     * {@link org.apache.tapestry5.internal.services.CheckForUpdatesFilter}). Starting in
5.3, this filter will be null
+     * in production mode (it will only be active in development mode).
      * <dt>ErrorFilter</dt>
      * <dd>Catches request errors and lets the {@link org.apache.tapestry5.services.RequestExceptionHandler}
handle them
      * </dd>
@@ -1012,15 +1015,8 @@ public final class TapestryModule
      */
     public void contributeRequestHandler(OrderedConfiguration<RequestFilter> configuration,
Context context,
 
-    @Symbol(SymbolConstants.FILE_CHECK_INTERVAL)
-    @IntermediateType(TimeInterval.class)
-    long checkInterval,
-
-    @Symbol(SymbolConstants.FILE_CHECK_UPDATE_TIMEOUT)
-    @IntermediateType(TimeInterval.class)
-    long updateTimeout,
-
-    UpdateListenerHub updateListenerHub)
+    @Symbol(SymbolConstants.PRODUCTION_MODE)
+    boolean productionMode)
     {
         RequestFilter staticFilesFilter = new StaticFilesFilter(context);
 
@@ -1049,8 +1045,14 @@ public final class TapestryModule
             }
         };
 
-        configuration.add("CheckForUpdates",
-                new CheckForUpdatesFilter(updateListenerHub, checkInterval, updateTimeout),
"before:*");
+        if (productionMode)
+        {
+            configuration.add("CheckForUpdates", null, "before:*");
+        }
+        else
+        {
+            configuration.addInstance("CheckForUpdates", CheckForUpdatesFilter.class, "before:*");
+        }
 
         configuration.add("StaticFiles", staticFilesFilter);
 
@@ -1059,7 +1061,6 @@ public final class TapestryModule
         configuration.add("StoreIntoGlobals", storeIntoGlobals, "after:StaticFiles", "before:ErrorFilter");
 
         configuration.add("EndOfRequest", fireEndOfRequestEvent, "after:StoreIntoGlobals",
"before:ErrorFilter");
-
     }
 
     /**
@@ -2948,4 +2949,28 @@ public final class TapestryModule
     {
         return new LinkTransformerInterceptor(linkTransformer, delegate);
     }
+
+    /**
+     * In production mode, overrides {@link UpdateListenerHub} to be an empty placeholder.
+     */
+    @Contribute(ServiceOverride.class)
+    public static void productionModeOverrides(MappedConfiguration<Class, Object> configuration,
+            @Symbol(SymbolConstants.PRODUCTION_MODE)
+            boolean productionMode)
+    {
+        if (productionMode)
+        {
+            configuration.add(UpdateListenerHub.class, new UpdateListenerHub()
+            {
+                public void fireCheckForUpdates()
+                {
+                }
+
+                public void addUpdateListener(UpdateListener listener)
+                {
+
+                }
+            });
+        }
+    }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/reload/services/AppModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/reload/services/AppModule.java?rev=1094828&r1=1094827&r2=1094828&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/reload/services/AppModule.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/reload/services/AppModule.java
Tue Apr 19 00:18:40 2011
@@ -1,10 +1,10 @@
-// Copyright 2008 The Apache Software Foundation
+// Copyright 2008, 2011 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
 // You may obtain a copy of the License at
 //
-//     http://www.apache.org/licenses/LICENSE-2.0
+// http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing, software
 // distributed under the License is distributed on an "AS IS" BASIS,
@@ -19,8 +19,9 @@ import org.apache.tapestry5.ioc.MappedCo
 
 public class AppModule
 {
-    public static void contributeApplicationDefaults(MappedConfiguration<String, String>
conf)
+    public static void contributeApplicationDefaults(MappedConfiguration<String, Object>
conf)
     {
         conf.add(SymbolConstants.FILE_CHECK_INTERVAL, "0ms");
+        conf.add(SymbolConstants.PRODUCTION_MODE, false);
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentInstantiatorSourceImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentInstantiatorSourceImplTest.java?rev=1094828&r1=1094827&r2=1094828&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentInstantiatorSourceImplTest.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentInstantiatorSourceImplTest.java
Tue Apr 19 00:18:40 2011
@@ -1,10 +1,10 @@
-// Copyright 2006, 2007, 2008, 2009, 2010 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2009, 2010, 2011 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
 // You may obtain a copy of the License at
 //
-//     http://www.apache.org/licenses/LICENSE-2.0
+// http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing, software
 // distributed under the License is distributed on an "AS IS" BASIS,
@@ -78,7 +78,7 @@ public class ComponentInstantiatorSource
         replay();
 
         ComponentInstantiatorSourceImpl e = new ComponentInstantiatorSourceImpl(logger, contextLoader,
transformer,
-                                                                                null, converter);
+                null, converter);
 
         assertEquals(e.inControlledPackage("foo.bar.Baz"), false);
 
@@ -102,7 +102,6 @@ public class ComponentInstantiatorSource
 
         verify();
     }
- 
 
     /**
      * This allows tests the exists() method.
@@ -121,7 +120,7 @@ public class ComponentInstantiatorSource
         assertTrue(source.exists(SYNTH_COMPONENT_CLASSNAME));
 
         getMocksControl().resetToNice();
-        
+
         Named named = (Named) createComponent(SYNTH_COMPONENT_CLASSNAME);
 
         assertEquals(named.getName(), "Original");
@@ -133,7 +132,8 @@ public class ComponentInstantiatorSource
 
         while (true)
         {
-            if (readDTM(url) != dtm) break;
+            if (readDTM(url) != dtm)
+                break;
 
             // Keep re-writing the file until we see the DTM change.
 
@@ -220,10 +220,11 @@ public class ComponentInstantiatorSource
 
         URL url = extraClasspath.toURL();
 
-        extraLoader = new URLClassLoader(new URL[] { url }, contextLoader);
+        extraLoader = new URLClassLoader(new URL[]
+        { url }, contextLoader);
         RegistryBuilder builder = new RegistryBuilder(extraLoader);
 
-        builder.add(TapestryModule.class);
+        builder.add(TapestryModule.class, ForceDevelopmentModeModule.class);
 
         registry = builder.build();
 

Copied: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ForceDevelopmentModeModule.java
(from r1094827, tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/reload/services/AppModule.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ForceDevelopmentModeModule.java?p2=tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ForceDevelopmentModeModule.java&p1=tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/reload/services/AppModule.java&r1=1094827&r2=1094828&rev=1094828&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/reload/services/AppModule.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ForceDevelopmentModeModule.java
Tue Apr 19 00:18:40 2011
@@ -1,10 +1,10 @@
-// Copyright 2008 The Apache Software Foundation
+// Copyright 2011 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
 // You may obtain a copy of the License at
 //
-//     http://www.apache.org/licenses/LICENSE-2.0
+// http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing, software
 // distributed under the License is distributed on an "AS IS" BASIS,
@@ -12,15 +12,20 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry5.integration.reload.services;
+package org.apache.tapestry5.internal.services;
 
 import org.apache.tapestry5.SymbolConstants;
 import org.apache.tapestry5.ioc.MappedConfiguration;
+import org.apache.tapestry5.ioc.annotations.Contribute;
+import org.apache.tapestry5.ioc.services.ApplicationDefaults;
+import org.apache.tapestry5.ioc.services.SymbolProvider;
 
-public class AppModule
+public class ForceDevelopmentModeModule
 {
-    public static void contributeApplicationDefaults(MappedConfiguration<String, String>
conf)
+    @Contribute(SymbolProvider.class)
+    @ApplicationDefaults
+    public static void enableDevelopmentMode(MappedConfiguration<String, Object> configuration)
     {
-        conf.add(SymbolConstants.FILE_CHECK_INTERVAL, "0ms");
+        configuration.add(SymbolConstants.PRODUCTION_MODE, false);
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/test/InternalBaseTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/test/InternalBaseTestCase.java?rev=1094828&r1=1094827&r2=1094828&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/test/InternalBaseTestCase.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/test/InternalBaseTestCase.java
Tue Apr 19 00:18:40 2011
@@ -82,7 +82,7 @@ public class InternalBaseTestCase extend
     {
         RegistryBuilder builder = new RegistryBuilder();
 
-        builder.add(TapestryModule.class);
+        builder.add(TapestryModule.class, ForceDevelopmentModeModule.class);
 
         registry = builder.build();
 

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/services/UpdateListenerHub.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/services/UpdateListenerHub.java?rev=1094828&r1=1094827&r2=1094828&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/services/UpdateListenerHub.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/services/UpdateListenerHub.java
Tue Apr 19 00:18:40 2011
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2008, 2010 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2010, 2011 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -30,6 +30,8 @@ import org.apache.tapestry5.ioc.ObjectLo
  * A <em>weak reference</em> to the listener is kept; this ensures that registering
as a listener will not prevent a
  * listener instance from being reclaimed by the garbage collector (this is useful as proxies
created by
  * {@link ObjectLocator#proxy(Class, Class)} may register as listeners, but still be ephemeral).
+ * <p>
+ * Starting in Tapestry 5.3, this services does <em>nothing</em> in production
mode.
  * 
  * @since 5.1.0.0
  */



Mime
View raw message