commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Timothy James Pinet" <tpi...@zenasus.com>
Subject Re: [compress] What is the purpose of the reflection usage in ArchiveStreamFactory and CompressorStreamFactory?
Date Sun, 05 Oct 2008 22:44:21 GMT
Reflection does handle checked exceptions for Constructor.newInstance() and 
this is handled appropriately for:

public ArchiveInputStream createArchiveInputStream( final String 
archiverName, final InputStream out ) throws ArchiveException {...}

However, the other method:

public ArchiveInputStream createArchiveInputStream( final InputStream 
input ) throws IOException {...}

is not implemented to handle checked constructor exceptions since all 
Exception catches are not handled. It looks as though this method was not 
completed. I will fix it up and suggest a patch to bring it to a workable 
state.

Thanks,
Tim

--------------------------------------------------
From: "Torsten Curdt" <tcurdt@apache.org>
Sent: Sunday, October 05, 2008 10:27 AM
To: "Commons Developers List" <dev@commons.apache.org>
Subject: [compress] What is the purpose of the reflection usage in 
ArchiveStreamFactory and CompressorStreamFactory?

> 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: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message