diff options
author | Artur <artur@vaadin.com> | 2017-05-02 08:30:59 +0300 |
---|---|---|
committer | Ilia Motornyi <elmot@vaadin.com> | 2017-05-02 08:30:59 +0300 |
commit | f8921dc387a572b12ac7c9c6f4677e5a1d0e5b70 (patch) | |
tree | be13f735bb10458e54d80e722242c902c5f2b8e5 /test/dependency-rewrite-addon/src | |
parent | 9c443c9de42343a94df5f7040bfed731f8d8f84e (diff) | |
download | vaadin-framework-f8921dc387a572b12ac7c9c6f4677e5a1d0e5b70.tar.gz vaadin-framework-f8921dc387a572b12ac7c9c6f4677e5a1d0e5b70.zip |
Add support for pluggable filters for rewriting dependencies (#9182)
* Add support for pluggable filters for rewriting dependencies
Fixes #9151
Diffstat (limited to 'test/dependency-rewrite-addon/src')
2 files changed, 29 insertions, 0 deletions
diff --git a/test/dependency-rewrite-addon/src/main/java/com/vaadin/test/dependencyrewriteaddon/RewriteJQueryFilter.java b/test/dependency-rewrite-addon/src/main/java/com/vaadin/test/dependencyrewriteaddon/RewriteJQueryFilter.java new file mode 100644 index 0000000000..415bb9b093 --- /dev/null +++ b/test/dependency-rewrite-addon/src/main/java/com/vaadin/test/dependencyrewriteaddon/RewriteJQueryFilter.java @@ -0,0 +1,28 @@ +package com.vaadin.test.dependencyrewriteaddon; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + +import com.vaadin.server.DependencyFilter; +import com.vaadin.ui.Dependency; +import com.vaadin.ui.Dependency.Type; + +public class RewriteJQueryFilter implements DependencyFilter { + + @Override + public List<Dependency> filter(List<Dependency> dependencies, + FilterContext filterContext) { + List<Dependency> filtered = new ArrayList<>(); + for (Dependency dependency : dependencies) { + if (dependency.getType() == Type.JAVASCRIPT && dependency.getUrl() + .toLowerCase(Locale.ENGLISH).contains("jquery")) { + filtered.add( + new Dependency(Type.JAVASCRIPT, "vaadin://jquery.js")); + } else { + filtered.add(dependency); + } + } + return filtered; + } +} diff --git a/test/dependency-rewrite-addon/src/main/resources/META-INF/services/com.vaadin.server.DependencyFilter b/test/dependency-rewrite-addon/src/main/resources/META-INF/services/com.vaadin.server.DependencyFilter new file mode 100644 index 0000000000..f62efa26fd --- /dev/null +++ b/test/dependency-rewrite-addon/src/main/resources/META-INF/services/com.vaadin.server.DependencyFilter @@ -0,0 +1 @@ +com.vaadin.test.dependencyrewriteaddon.RewriteJQueryFilter |