You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by th...@apache.org on 2014/06/17 00:08:46 UTC

git commit: TAP5-1611: renaming ComponentReplacer to ComponentOverride, following Lance's suggestion.

Repository: tapestry-5
Updated Branches:
  refs/heads/master 79fd52350 -> d3bc1f1b8


TAP5-1611: renaming ComponentReplacer to ComponentOverride, following Lance's suggestion.


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/d3bc1f1b
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/d3bc1f1b
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/d3bc1f1b

Branch: refs/heads/master
Commit: d3bc1f1b8109fe0183fb076644cf72369930c6c9
Parents: 79fd523
Author: Thiago H. de Paula Figueiredo <th...@apache.org>
Authored: Mon Jun 16 19:08:04 2014 -0300
Committer: Thiago H. de Paula Figueiredo <th...@apache.org>
Committed: Mon Jun 16 19:08:04 2014 -0300

----------------------------------------------------------------------
 .../internal/ComponentOverrideImpl.java         | 89 ++++++++++++++++++++
 .../internal/ComponentReplacerImpl.java         | 89 --------------------
 .../tapestry5/modules/TapestryModule.java       |  4 +-
 .../tapestry5/services/ComponentOverride.java   | 51 +++++++++++
 .../tapestry5/services/ComponentReplacer.java   | 51 -----------
 .../integration/app3/services/AppModule.java    |  4 +-
 6 files changed, 144 insertions(+), 144 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d3bc1f1b/tapestry-core/src/main/java/org/apache/tapestry5/internal/ComponentOverrideImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/ComponentOverrideImpl.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/ComponentOverrideImpl.java
new file mode 100644
index 0000000..e9ab678
--- /dev/null
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/ComponentOverrideImpl.java
@@ -0,0 +1,89 @@
+// Copyright 2014 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package org.apache.tapestry5.internal;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.apache.tapestry5.ioc.util.CaseInsensitiveMap;
+import org.apache.tapestry5.services.ComponentOverride;
+import org.slf4j.Logger;
+
+public class ComponentOverrideImpl implements ComponentOverride
+{
+
+    final Logger logger;
+    final private Map<Class, Class> replacements;
+    final private Map<String, Class> nameToClass;
+
+    @SuppressWarnings("rawtypes")
+    public ComponentOverrideImpl(Map<Class, Class> contributions, Logger logger)
+    {
+
+        this.logger = logger;
+        this.replacements = Collections.unmodifiableMap(contributions);
+        Map<String, Class> nameToClass = new HashMap<String, Class>();
+
+        int maxLength = 0;
+
+        for (Class<?> clasz : contributions.keySet())
+        {
+
+            final String name = clasz.getName();
+            if (name.length() > maxLength) {
+                maxLength = name.length();
+            }
+            nameToClass.put(name, contributions.get(clasz));
+
+        }
+
+        this.nameToClass = Collections.unmodifiableMap(nameToClass);
+        
+        if (replacements.size() > 0 && logger.isInfoEnabled())
+        {
+            
+            StringBuilder builder = new StringBuilder(1000);
+            final String format = "%" + maxLength + "s: %s\n";
+            builder.append("Component replacements (including components, pages and mixins):\n");
+            List<String> names = new ArrayList<String>(nameToClass.keySet());
+            Collections.sort(names);
+            
+            for (String name : names) {
+                builder.append(String.format(format, name, nameToClass.get(name).getName()));
+            }
+            
+            logger.info(builder.toString());
+            
+        }
+
+    }
+
+    @Override
+    public Map<Class, Class> getReplacements()
+    {
+        return replacements;
+    }
+
+    @Override
+    public Class getReplacement(String className)
+    {
+        return nameToClass.get(className);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d3bc1f1b/tapestry-core/src/main/java/org/apache/tapestry5/internal/ComponentReplacerImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/ComponentReplacerImpl.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/ComponentReplacerImpl.java
deleted file mode 100644
index 8d7fc75..0000000
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/ComponentReplacerImpl.java
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright 2014 The Apache Software Foundation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-package org.apache.tapestry5.internal;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import org.apache.tapestry5.ioc.util.CaseInsensitiveMap;
-import org.apache.tapestry5.services.ComponentReplacer;
-import org.slf4j.Logger;
-
-public class ComponentReplacerImpl implements ComponentReplacer
-{
-
-    final Logger logger;
-    final private Map<Class, Class> replacements;
-    final private Map<String, Class> nameToClass;
-
-    @SuppressWarnings("rawtypes")
-    public ComponentReplacerImpl(Map<Class, Class> contributions, Logger logger)
-    {
-
-        this.logger = logger;
-        this.replacements = Collections.unmodifiableMap(contributions);
-        Map<String, Class> nameToClass = new HashMap<String, Class>();
-
-        int maxLength = 0;
-
-        for (Class<?> clasz : contributions.keySet())
-        {
-
-            final String name = clasz.getName();
-            if (name.length() > maxLength) {
-                maxLength = name.length();
-            }
-            nameToClass.put(name, contributions.get(clasz));
-
-        }
-
-        this.nameToClass = Collections.unmodifiableMap(nameToClass);
-        
-        if (replacements.size() > 0 && logger.isInfoEnabled())
-        {
-            
-            StringBuilder builder = new StringBuilder(1000);
-            final String format = "%" + maxLength + "s: %s\n";
-            builder.append("Component replacements (including components, pages and mixins):\n");
-            List<String> names = new ArrayList<String>(nameToClass.keySet());
-            Collections.sort(names);
-            
-            for (String name : names) {
-                builder.append(String.format(format, name, nameToClass.get(name).getName()));
-            }
-            
-            logger.info(builder.toString());
-            
-        }
-
-    }
-
-    @Override
-    public Map<Class, Class> getReplacements()
-    {
-        return replacements;
-    }
-
-    @Override
-    public Class getReplacement(String className)
-    {
-        return nameToClass.get(className);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d3bc1f1b/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java b/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
index 1a08540..aa965ad 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
@@ -375,7 +375,7 @@ public final class TapestryModule
         binder.bind(DateUtilities.class, DateUtilitiesImpl.class);
         binder.bind(PartialTemplateRenderer.class, PartialTemplateRendererImpl.class);
         binder.bind(org.apache.tapestry5.services.exceptions.ExceptionReporter.class, ExceptionReporterImpl.class);
-        binder.bind(ComponentReplacer.class, ComponentReplacerImpl.class).eagerLoad();
+        binder.bind(ComponentOverride.class, ComponentOverrideImpl.class).eagerLoad();
     }
 
     // ========================================================================
@@ -2667,7 +2667,7 @@ public final class TapestryModule
     
     @Advise(serviceInterface = ComponentInstantiatorSource.class)
     public static void componentReplacer(MethodAdviceReceiver methodAdviceReceiver, 
-          final ComponentReplacer componentReplacer) throws NoSuchMethodException, SecurityException {
+          final ComponentOverride componentReplacer) throws NoSuchMethodException, SecurityException {
         
         if (componentReplacer.getReplacements().size() > 0) {
             

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d3bc1f1b/tapestry-core/src/main/java/org/apache/tapestry5/services/ComponentOverride.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/services/ComponentOverride.java b/tapestry-core/src/main/java/org/apache/tapestry5/services/ComponentOverride.java
new file mode 100644
index 0000000..1219b15
--- /dev/null
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/services/ComponentOverride.java
@@ -0,0 +1,51 @@
+// Copyright 2014 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.services;
+
+import java.util.Map;
+
+import org.apache.tapestry5.ioc.MethodAdviceReceiver;
+import org.apache.tapestry5.ioc.annotations.UsesMappedConfiguration;
+
+/**
+ * Service that allows replacing one component, page or mixin class by another without changing the sources.
+ * This service shouldn't be used directly: it's not an internal service just because it receives
+ * contributions.
+ * 
+ * Contributions to it are mapped: the key is the component, page or mixin class to be
+ * replaced, the value is the replacement.
+ *
+ * @since 5.4
+ * @see ComponentClassResolver.
+ */
+@UsesMappedConfiguration(key = Class.class, value = Class.class)
+public interface ComponentOverride
+{
+
+    /**
+     * Returns an immutable map of replacements. Internal use only.
+     * 
+     * @return a {@link Map}.
+     */
+    Map<Class, Class> getReplacements();
+    
+    /**
+     * Returns the replacement for a class given its name.
+     * @param className the fully qualified class name.
+     * @return a {@link Class} or null.
+     */
+    Class getReplacement(String className);
+    
+}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d3bc1f1b/tapestry-core/src/main/java/org/apache/tapestry5/services/ComponentReplacer.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/services/ComponentReplacer.java b/tapestry-core/src/main/java/org/apache/tapestry5/services/ComponentReplacer.java
deleted file mode 100644
index 375a8c6..0000000
--- a/tapestry-core/src/main/java/org/apache/tapestry5/services/ComponentReplacer.java
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2014 The Apache Software Foundation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package org.apache.tapestry5.services;
-
-import java.util.Map;
-
-import org.apache.tapestry5.ioc.MethodAdviceReceiver;
-import org.apache.tapestry5.ioc.annotations.UsesMappedConfiguration;
-
-/**
- * Service that allows replacing one component, page or mixin class by another without changing the sources.
- * This service shouldn't be used directly: it's not an internal service just because it receives
- * contributions.
- * 
- * Contributions to it are mapped: the key is the component, page or mixin class to be
- * replaced, the value is the replacement.
- *
- * @since 5.4
- * @see ComponentClassResolver.
- */
-@UsesMappedConfiguration(key = Class.class, value = Class.class)
-public interface ComponentReplacer
-{
-
-    /**
-     * Returns an immutable map of replacements. Internal use only.
-     * 
-     * @return a {@link Map}.
-     */
-    Map<Class, Class> getReplacements();
-    
-    /**
-     * Returns the replacement for a class given its name.
-     * @param className the fully qualified class name.
-     * @return a {@link Class} or null.
-     */
-    Class getReplacement(String className);
-    
-}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d3bc1f1b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app3/services/AppModule.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app3/services/AppModule.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app3/services/AppModule.java
index 58648bd..3fda2b3 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app3/services/AppModule.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app3/services/AppModule.java
@@ -25,7 +25,7 @@ import org.apache.tapestry5.ioc.Configuration;
 import org.apache.tapestry5.ioc.MappedConfiguration;
 import org.apache.tapestry5.ioc.OrderedConfiguration;
 import org.apache.tapestry5.ioc.annotations.Contribute;
-import org.apache.tapestry5.services.ComponentReplacer;
+import org.apache.tapestry5.services.ComponentOverride;
 import org.apache.tapestry5.services.DisplayBlockContribution;
 import org.apache.tapestry5.services.Request;
 import org.apache.tapestry5.services.compatibility.Compatibility;
@@ -86,7 +86,7 @@ public class AppModule
         }, "before:*");
     }
     
-    @Contribute(ComponentReplacer.class)
+    @Contribute(ComponentOverride.class)
     public static void overridePageAndComponentAndMixin(MappedConfiguration<Class, Class> configuration) {
         configuration.add(OverridenPage.class, OverridePage.class);
         configuration.add(OverridenComponent.class, OverrideComponent.class);