https://jira.jboss.org/jira/browse/SHRINKWRAP-104
I've added support for empty directories (and tests) in r3836. This is nice, because
importers can now account for empty dirs as well.
The design I've used is a new Asset implementation:
public enum DirectoryAsset implements Asset {
|
| /**
| * Singleton Instance
| */
| INSTANCE;
|
| /**
| * {@inheritDoc}
| * @see org.jboss.shrinkwrap.api.Asset#openStream()
| */
| @Override
| public InputStream openStream()
| {
| // To signify that we've got nothing to back us (we're just a
directory),
| // we use null. A stream backed by an empty byte array would be an
| // empty file, which is different.
| return null;
| }
|
| }
This sucks because:
1) We don't really obey the contract of "Asset", returning a null reference
on "openStream"
2) The implementation relies upon "instanceof" runtime type checking to do
things like creating directories in the exporter. Meaning we're checking for a
specific implementation.
An alternate approach is to add:
Asset.isDirectory()
...to all Asset types. In this case "DirectoryAsset.openStream" would still
return null, but we could do "Asset.isDirectory" instead of the runtime type
checking.
Which is uglier to you?
S,
ALR
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4269221#...
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&a...