|
From: Bill B. <bb...@re...> - 2008-06-25 14:15:11
|
Ryan J. McDonough wrote:
> Yeah, I was planning on doing that as well, just not right away because
> there's a few things I want to do. But I came across something that i
> don't thing the spec supports: proving hints to providers. Currently,
> the provider will always use the highest quality settings for images
> that can be compressed. However, if I want to use a lower setting
> there's not a good way to configure that. You could configure this at
> the application level, but if I want to different configurations for
> different resources, there's not a portable way to do it.
>
> This is an item that will also affect a FileProvider as well: where do
> you read and write the files. The Jersey FileProvider uses temp files
> which isn't very flexible. If I were writing files, I'd want to specify
> a specific location. With that said, I was thinking about something like
> this:
>
> @POST
> @ConsumeMime("*/*")
> @ProviderHints(provider = FileProvider.class,
> hints= {@Hint(name="basedir",value="/opt/files")})
> public File processFile(File file) {
>
> To define the root location for this resource. With this approach, each
> resource could write files to different locations. For the
> IIOImageProvider, you could do something like this to change the
> compression level.
>
> @POST
> @ConsumeMime("image/*")
> @ProduceMime("image/jpeg")
> @ProviderHints(provider = IIOImageProvider.class,
> hints= {@Hint(name="compresionQuality",value="0.6")})
> public IIOImage transcodeImage(IIOImage image) {
>
> In this case, we'd be overriding the default compression value to get a
> more compressed image. There's still more thinking to be done, such as
> is this just a class-level or method level annotation, etc. However, i
> wanted to get some feedback on the idea.
>
You don't need a @Hint in this case. Just create a new IIOImage
specific annotation
@POST
@ConsumeMime("image/*")
@ProduceMime("image/jpeg")
@CompressionQuality(0.2)
public IIOImage transcodeImage(@CompressionQuality(0.6) image) {...}
The @CompressionQuality annotation would be 0.6 for the
MessageBodyReader, 0.2 for Writer.
You get the list of annotations on the parameter for input, method for
output.
--
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com
|