You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2012/08/04 02:19:49 UTC
[3/3] git commit: Introduce a service designed to track compatibility
traits
Introduce a service designed to track compatibility traits
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/c4381ff6
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/c4381ff6
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/c4381ff6
Branch: refs/heads/5.4-js-rewrite
Commit: c4381ff637c01465d1de5595724b78ba8c496d2a
Parents: 7a7a274
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Fri Aug 3 14:59:13 2012 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Fri Aug 3 14:59:13 2012 -0700
----------------------------------------------------------------------
.../internal/compatibility/CompatibilityImpl.java | 41 ++++++++++++++
.../apache/tapestry5/services/TapestryModule.java | 3 +-
.../services/compatibility/Compatibility.java | 36 ++++++++++++
.../compatibility/CompatibilityModule.java | 43 +++++++++++++++
.../tapestry5/services/compatibility/Trait.java | 29 ++++++++++
.../services/compatibility/package-info.java | 20 +++++++
6 files changed, 171 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/c4381ff6/tapestry-core/src/main/java/org/apache/tapestry5/internal/compatibility/CompatibilityImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/compatibility/CompatibilityImpl.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/compatibility/CompatibilityImpl.java
new file mode 100644
index 0000000..be70f99
--- /dev/null
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/compatibility/CompatibilityImpl.java
@@ -0,0 +1,41 @@
+// Copyright 2012 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.compatibility;
+
+import org.apache.tapestry5.services.compatibility.Compatibility;
+import org.apache.tapestry5.services.compatibility.Trait;
+
+import java.util.Collection;
+import java.util.EnumSet;
+
+public class CompatibilityImpl implements Compatibility
+{
+ private final EnumSet<Trait> traits;
+
+ public CompatibilityImpl(Collection<Trait> configuration)
+ {
+ traits = EnumSet.noneOf(Trait.class);
+
+ traits.addAll(configuration);
+ }
+
+ @Override
+ public boolean enabled(Trait trait)
+ {
+ assert trait != null;
+
+ return traits.contains(trait);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/c4381ff6/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java b/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
index 1c46f31..16bef0f 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
@@ -78,6 +78,7 @@ import org.apache.tapestry5.services.ajax.AjaxResponseRenderer;
import org.apache.tapestry5.services.assets.AssetPathConstructor;
import org.apache.tapestry5.services.assets.AssetRequestHandler;
import org.apache.tapestry5.services.assets.AssetsModule;
+import org.apache.tapestry5.services.compatibility.CompatibilityModule;
import org.apache.tapestry5.services.dynamic.DynamicTemplate;
import org.apache.tapestry5.services.dynamic.DynamicTemplateParser;
import org.apache.tapestry5.services.javascript.*;
@@ -117,7 +118,7 @@ import java.util.regex.Pattern;
*/
@Marker(Core.class)
@SubModule(
- {InternalModule.class, AssetsModule.class, PageLoadModule.class, JavaScriptModule.class})
+ {InternalModule.class, AssetsModule.class, PageLoadModule.class, JavaScriptModule.class, CompatibilityModule.class})
public final class TapestryModule
{
private final PipelineBuilder pipelineBuilder;
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/c4381ff6/tapestry-core/src/main/java/org/apache/tapestry5/services/compatibility/Compatibility.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/services/compatibility/Compatibility.java b/tapestry-core/src/main/java/org/apache/tapestry5/services/compatibility/Compatibility.java
new file mode 100644
index 0000000..15685e9
--- /dev/null
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/services/compatibility/Compatibility.java
@@ -0,0 +1,36 @@
+// Copyright 2012 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.compatibility;
+
+import org.apache.tapestry5.ioc.annotations.UsesConfiguration;
+
+/**
+ * Used globally to track what compatibility traits are enabled.
+ * <p/>
+ * Temporarily, all traits are enabled.
+ *
+ * @since 5.4
+ */
+@UsesConfiguration(Trait.class)
+public interface Compatibility
+{
+ /**
+ * Returns true if the indicated compatibility trait is enabled.
+ *
+ * @param trait
+ * @return true if enabled, false otherwise
+ */
+ boolean enabled(Trait trait);
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/c4381ff6/tapestry-core/src/main/java/org/apache/tapestry5/services/compatibility/CompatibilityModule.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/services/compatibility/CompatibilityModule.java b/tapestry-core/src/main/java/org/apache/tapestry5/services/compatibility/CompatibilityModule.java
new file mode 100644
index 0000000..29eb254
--- /dev/null
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/services/compatibility/CompatibilityModule.java
@@ -0,0 +1,43 @@
+// Copyright 2012 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.compatibility;
+
+import org.apache.tapestry5.internal.compatibility.CompatibilityImpl;
+import org.apache.tapestry5.ioc.Configuration;
+import org.apache.tapestry5.ioc.ServiceBinder;
+import org.apache.tapestry5.ioc.annotations.Contribute;
+
+/**
+ * Defines services for managing compatibility across releases.
+ *
+ * @since 5.4
+ */
+public class CompatibilityModule
+{
+ public static void bind(ServiceBinder binder)
+ {
+ binder.bind(Compatibility.class, CompatibilityImpl.class);
+ }
+
+ @Contribute(Compatibility.class)
+ public void enableAllCompatibilityTemporarily(Configuration<Trait> configuration)
+ {
+ for (Trait t : Trait.values())
+ {
+ configuration.add(t);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/c4381ff6/tapestry-core/src/main/java/org/apache/tapestry5/services/compatibility/Trait.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/services/compatibility/Trait.java b/tapestry-core/src/main/java/org/apache/tapestry5/services/compatibility/Trait.java
new file mode 100644
index 0000000..398d904
--- /dev/null
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/services/compatibility/Trait.java
@@ -0,0 +1,29 @@
+// Copyright 2012 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.compatibility;
+
+/**
+ * Defines different traits that may be enabled or disabled. This was introduced in Tapestry 5.4 to allow certain
+ * features that exist in Tapestry 5.3 to be optionally enabled for compatibility.
+ */
+public enum Trait
+{
+ /**
+ * Indicates that the Scriptaculous JavaScript libraries should be included. Tapestry 5.3 includes options for performing
+ * some kinds of animations when certain elements were updated or removed; that is no longer present in Tapestry 5.4
+ * and Scriptaculous is not used.
+ */
+ SCRIPTACULOUS;
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/c4381ff6/tapestry-core/src/main/java/org/apache/tapestry5/services/compatibility/package-info.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/services/compatibility/package-info.java b/tapestry-core/src/main/java/org/apache/tapestry5/services/compatibility/package-info.java
new file mode 100644
index 0000000..2465408
--- /dev/null
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/services/compatibility/package-info.java
@@ -0,0 +1,20 @@
+// Copyright 2012 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.
+
+/**
+ * A more structured approach to tracking how compatibility features are enabled, as well as tracking
+ * compatibility exceptions.
+ * @since 5.4
+ */
+package org.apache.tapestry5.services.compatibility;