To start with I will assume converting between storage types is the primary use case. I
have started to prototype some archive conversion strategies for storage archives.
Eventually we will need to allow converting the storage type in an existing container
archive, but I am starting with the just the conversion of storage archives, as it is a
prerequisite.
Below is an example syntax I have been prototyping for very basic conversion:
| MemoryMapArchive memoryMapArchive = new
MemoryMapArchiveImpl("testArchive.jar");
|
| VfsArchive newArchive =
ArchiveConverter.convert(memoryMapArchive).to(VfsArchive.class);
|
|
The above example is assuming there is a known implementation type for the VfsArchive, and
it can be constructed using only the archive name. This relies on a very basic
ArchiveFactory I have created to create Archive implementations. Once constructed all the
content will be converted from the source archive to the newly created.
There will be Archive implementations that can not be constructed with only the name. For
this there is an alternate conversion syntax that allows for custom conversion strategies.
Below is an example syntax for custom conversion:
|
| MemoryMapArchive memoryMapArchive = new
MemoryMapArchiveImpl("testArchive.jar");
|
| VfsArchiveConverter converter = new VfsConverter();
| VfsConverterMetadata = metadata = new VfsConverterMetatdata(File root);
|
| VfsArchive newArchive = ArchiveConverter.convert(memoryMapArchive).using(converter,
metadata);
|
| // or ....
|
| VfsArchive newArchive = ArchiveConverter.convert(memoryMapArchive).using(new
VfsConverter(File root));
|
| // or ....
|
| VfsArchive newArchive = ArchiveConverter.convert(memoryMapArchive).using(new
VfsConverter());
|
|
|
This example could then allow the conversion of any archive type using whatever strategy
necessary to make the conversion.
This is not the slickest syntax ever, but something similar could be used to get an easily
extensible conversion system in place. Then alternate conversion impls could be created
to provide even nicer API/SPIs..
Below is where I could see it going:
| MemoryMapArchive memoryMapArchive = new
MemoryMapArchiveImpl("testArchive.jar");
|
| VfsArchive newArchive = VfsArchiveConverter.convert(memoryMapArchive).toVfs(File
root);
|
|
Which internally could make the call above with a custom converter and metadata.
Anyway, just throwing this out to get some thoughts on the syntax and overall design. I
am not stuck on it, just the first design that I came up with.
What do you think?
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4251687#...
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&a...