-
1. Re: Covarient returns from a storage delagate
aslak Aug 21, 2009 3:41 AM (in response to johnbailey)The storage engines will be wrapped up/delegated to by the Java/WebArchive spec impls and never exposed directly through the chaining in the Archive interface.
The thought was to let the Storage Engines have there own Archive interfaces and not depended on the specs.
The spec impls would wrap up the storage engines(handeled by a support Superclass) like:public JavaArchive add(Asset... assets) { archive.add(assets); return this; }
They do not extend the storage engines nor do they expose them directly in this way:public JavaArchiveImpl extends MemoryArchiveImpl { } public JavaArchive add(Asset... assets) { return archive.add(assets); }
Here is a more complete stack example:public interface ServiceProviderDelegate { Archive<?> getDelegate(); } public interface MemoryArchive extends Archive<MemoryArchive> { } public class MemoryArchiveImpl implements MemoryArchive { } public class JavaArchiveImpl implements JavaArchive, ServiceProviderDelegate { Archive<?> archive; public JavaArchiveImpl(Archive<?> archive) { this.archive = archive; } public JavaArchive add(Asset... assets) { archive.add(assets); return this; } @Override public Archive<?> getDelegate() { return archive; } } JavaArchive jar = new JavaArchiveImpl(new MemoryArchiveImpl());
-
2. Re: Covarient returns from a storage delagate
alrubinger Aug 21, 2009 3:58 AM (in response to johnbailey)As Aslak describes.
With the remaining question mark of:public JavaArchive add(Asset... assets)
...pursuant to our Asset.getPath discussion. But definitely:public JavaArchive addClasses(Class<?>... classes) { for(Class<?> clazz : classes) { ClassAsset asset = new ClassAsset(clazz); Path path = new BasicPath(ClassAssetUtil.convertClassNameToPathName(clazz)); storageDelegate.add(path,asset); } }
S,
ALR -
3. Re: Covarient returns from a storage delagate
johnbailey Aug 21, 2009 8:29 AM (in response to johnbailey)Yeah my assumption was there was no reason we would need to return the delegating spec archives. My initial implemantation of the memory map did not have any reference to the delegating archive instance or type. The only thing that led me to ask the question was Aslak's patch was maintaining the actual type as a parameter and returning that on the covarient return, which really just causes a class cast exception. Just wanted to make sure I wasn't missing something.
-
4. Re: Covarient returns from a storage delagate
aslak Aug 21, 2009 9:13 AM (in response to johnbailey)Yea, the patch was work in progress. It was after I submitted the patch we realised that the MemoryMapArchive should have its own interface.