users@jersey.java.net

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

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 06 Nov 2008 11:57:16 +0100

On Nov 6, 2008, at 1:21 AM, Craig McClanahan wrote:

> 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?

Class scanning is not enabled for the client, mainly because i have to
implemented it!, but i am also concerned about conflicts between the
server and client when the latter is used by the former.

I am wondering in this case if we should use the META-INF/services to
automatically register all components if the multipart module is in
the class path. Does that make more sense? Thus no configuration is
required.

That technique is used by the JSON module to register the JSON readers/
writers. Any provider implementation can be registered in a file, in
META-INF/services, that is named according to the provider interface
it implements.

Paul.

> 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);
> }
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>