Hi Chuck, I send you a sample code where a resource generates a representation according to the file extension. It doesn't rely on a Filter, but seems to work. the code illustrate 2 cases, the first one where the Resource knows the mappings between extensions and metadata, the second one where the resource relies on the parent application metadataService:
************************** // Case 1 - without the Application metadata service if ("js".equals(ext)) { getVariants().add(new Variant(MediaType.APPLICATION_JSON)); } else if ("xml".equals(ext)) { getVariants().add(new Variant(MediaType.APPLICATION_ATOM_XML)); } else { // What you want, even let the Variants set empty (will return 404 // response) getVariants().add(new Variant(MediaType.TEXT_PLAIN)); } // Case 2 - uses the Application metadata service Application application = (Application) context.getAttributes().get( Application.KEY); Metadata metadata = application.getMetadataService().getMetadata(ext); if (metadata != null && metadata instanceof MediaType) { getVariants().add(new Variant((MediaType) metadata)); } else { // What you want, even let the Variants set empty (will return 404 // response) getVariants().add(new Variant(MediaType.TEXT_PLAIN)); } ************************** I hope this will help you. Best regards, Thierry Boileau On Thu, Mar 6, 2008 at 9:48 AM, Stephan Koops <[EMAIL PROTECTED]> wrote: > Hello Chuck, > > > Thanks - I'll crank out a filter. > > > > One quick question...it's clear to me how I'd get the extension, and how to > > lookup the metadata, but it's not clear how to propagate that to the > resource. > > How do I properly set the variant. > I think you mean request.getClientInfo.setAcceptedMediaTypes(...) and > request.getClientInfo.setAcceptedLanguages(...) . > > Let me now, if you are ready; I need this filter also. > > best regards > Stephan >
testExtension.jar
Description: application/java