Hey there
Out of curiosity why must reflection be used for the create*Stream()
methods in the ArchiveStreamFactory and CompressorStreamFactory?
There is a cast at the end of each method to a corresponding
interface anyway (ex ArchiveInputStream, ArchiveOutputStream, etc)
so why cant we use this knowledge ahead of time and execute on the
interface?
I think the idea that it makes "dropping in" a new implementation
easier. But I agree with you.
As the registerArchive*Stream methods need to be called to register
the implementation this becomes a moo point.
I would change the factory to
public ArchiveInputStream createArchiveInputStream( final String
archiverName, final InputStream stream ) throws ArchiveException {
if ("ar".equals(archiverName)) {
return new ArAchiveInputStream(stream)
}
..
return null;
}
and then instead of registering a new implementation you just extend
the factory and overload the create*Stream methods to add your custom
impl ...and of course delegate to the super class.
The current implementation makes it next to impossible to capture
errors being thrown by the constructors of new implementations since
the reflective methods discard any Exceptions and simply return null.
Hm ... I thought that would be indeed possible:
http://java.sun.com/docs/books/tutorial/reflect/member/ctorTrouble.html
cheers
--
Torsten
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]