Repository: tapestry-5 Updated Branches: refs/heads/master 5d5b1e787 -> 57171a34a
Add a way to distinguish real resources from virtual resources Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/b5cf6465 Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/b5cf6465 Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/b5cf6465 Branch: refs/heads/master Commit: b5cf646552e1aa9ccf1d823f97f79d46e743f260 Parents: 5d5b1e7 Author: Howard M. Lewis Ship <[email protected]> Authored: Mon Jun 23 08:19:40 2014 -0700 Committer: Howard M. Lewis Ship <[email protected]> Committed: Mon Jun 23 08:19:50 2014 -0700 ---------------------------------------------------------------------- .../tapestry5/internal/util/VirtualResource.java | 8 ++++++-- .../main/java/org/apache/tapestry5/ioc/Resource.java | 13 +++++++++++-- .../tapestry5/ioc/internal/util/AbstractResource.java | 8 ++++++-- 3 files changed, 23 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b5cf6465/tapestry-core/src/main/java/org/apache/tapestry5/internal/util/VirtualResource.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/util/VirtualResource.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/util/VirtualResource.java index 0fc0738..e9548b4 100644 --- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/util/VirtualResource.java +++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/util/VirtualResource.java @@ -1,5 +1,3 @@ -// Copyright 2012, 2013 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 @@ -92,4 +90,10 @@ public abstract class VirtualResource implements Resource { return new ByteArrayInputStream(content); } + + @Override + public boolean isVirtual() + { + return true; + } } http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b5cf6465/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/Resource.java ---------------------------------------------------------------------- diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/Resource.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/Resource.java index ae4f439..b81c1c5 100644 --- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/Resource.java +++ b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/Resource.java @@ -1,5 +1,3 @@ -// Copyright 2006, 2008, 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 @@ -39,6 +37,17 @@ public interface Resource */ boolean exists(); + + /** + * Returns true if the resource is virtual, meaning this is no underlying file. Many operations are unsupported + * on virtual resources, including {@link #toURL()}, {@link #forLocale(java.util.Locale)}, + * {@link #withExtension(String)}, {@link #getFile()}, {@link #getFolder()}, {@link #getPath()}}; these + * operations will throw an {@link java.lang.UnsupportedOperationException}. + * + * @since 5.4 + */ + boolean isVirtual(); + /** * Opens a stream to the content of the resource, or returns null if the resource does not exist. The native * input stream supplied by the resource is wrapped in a {@link java.io.BufferedInputStream}. http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b5cf6465/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AbstractResource.java ---------------------------------------------------------------------- diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AbstractResource.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AbstractResource.java index f85cf02..b80e0f3 100644 --- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AbstractResource.java +++ b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AbstractResource.java @@ -1,5 +1,3 @@ -// Copyright 2006-2013 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 @@ -357,4 +355,10 @@ public abstract class AbstractResource extends LockSupport implements Resource return new File(url.getPath()); } } + + @Override + public boolean isVirtual() + { + return false; + } }
