users@jersey.java.net

Re: [Jersey] Hello World! and Welcome to jersey-multipart

From: Craig McClanahan <Craig.McClanahan_at_Sun.COM>
Date: Wed, 05 Nov 2008 16:21:37 -0800

Paul Sandoz wrote:
> Hi Craig,
>
> Ah! drat forgot to do this in the Client constructor:
>
> injectableFactory.configure(providerServices);
>
> which processes use-registered providers. I will fix that tomorrow.
>
Your fix does indeed make my injectable provider work on the client side
... thanks! However, I find that I still have to explicitly register
all my providers in the client config before they are recognized.
Shouldn't the following code (from the setup method of
MultiPartReaderWriterTest) work without the four add() calls? All of
the listed providers are in package "com.sun.jersey.impl.multipart" so I
would have expected the package scanner to find them.

Craig

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        Map<String,String> initParams = new HashMap<String,String>();
        initParams.put("com.sun.jersey.config.property.resourceConfigClass",
                       "com.sun.jersey.api.core.PackagesResourceConfig");
        initParams.put("com.sun.jersey.config.property.packages",
                       "com.sun.jersey.impl.multipart");
        System.out.println("Starting grizzly ...");
        selectorThread = GrizzlyWebContainerFactory.create(BASE_URI,
initParams)
;
        ClientConfig config = new DefaultClientConfig();
        config.getClasses().add(MultiPartReader.class);
        config.getClasses().add(MultiPartWriter.class);
        config.getClasses().add(MultiPartBeanProvider.class);
        config.getClasses().add(MultiPartConfigProvider.class);
        client = Client.create(config);
    }