Hi Poul,
Thanks for you answer (Welcome back from vacation :-)).
Thanks for the explanation. I agree with your observation that this Wadl API' needs some work. In fact it does seems like some kind of kludge (overly complicated and yet not flexible enough). In my case, I would like to pass a custom Object instance to my WadlGenerator and that does not seem to be possible (your example with strings and int's wont work here).
Anyway, while this is annoying I can live without better WADL right now (it's only for documentation after all :-))
Thanks,
Morten
--- Den ons 19/5/10 skrev Paul Sandoz <Paul.Sandoz_at_Sun.COM>:
> Fra: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
> Emne: Re: [Jersey] WadlGeneratorConfig and inputStream and parameter passing ?
> Til: users_at_jersey.dev.java.net
> Dato: onsdag 19. maj 2010 16.15
> Hi Morten,
>
> On May 12, 2010, at 11:13 PM, Morten wrote:
>
> > I am interested in using extending WadlGeneratorConfig
> in order
> > to customize my Wadl (and maybe specify my JAXBContext
> - see seperate post).
> >
> > I looked at the examples which all shows how to pass
> file references to a builder in configure(). As per normal
> Java EE practices, it would seem to be a much better
> practice to use URLs, URI's or inputstreams instead as this
> will work in all kind of deployment scenarios unlike Files.
> The javadoc makes references to using inputstreams but the
> prop() method only accepts strings so I am curious about how
> to use InputStream's instead of files ?
> >
>
> If you have a WadlGenerator implementation with a method
> "setFoo" and a property of name "foo" and value "bar", for
> example:
>
> public class MyWadlGeneratorConfig extends
> WadlGeneratorConfig {
> @Override
> public List<WadlGeneratorDescription>
> configure() {
> return generator(
> MyWadlGenerator.class )
> .prop( "foo", "bar" )
> .descriptions();
> }
> }
>
> public class MyWadlGenerator {
> void setFoo(InputStream in) { ... }
> }
>
> The the resource named "bar" will be looked up using
> ClassLoader.getResourceAsStream
>
>
> > Another problem is how to pass parameters into any
> WadlGenerators that I create ? All the configure examples
> uses xxx.class references which jersey instantiate so that I
> can't pass parameters to the constructor. Any examples of
> how to create my own instances (I tried overloading
> getWadlGenerator() instead of configure() but got some
> nullpointer execeptions if I did so I guess I did not
> implement it correctly). Any examples of creating my own
> instances of WadlGenerators so I can pass relevant
> information?
> >
>
> You can pass in properties to setter methods:
>
> public class MyWadlGeneratorConfig extends
> WadlGeneratorConfig {
> @Override
> public List<WadlGeneratorDescription>
> configure() {
> return generator(
> MyWadlGenerator.class )
> .prop( "string", "someString"
> )
> .prop( "b", 1 )
> .descriptions();
> }
> }
>
> public class MyWadlGenerator {
> void setString(String s) { ... }
> void setInteger(Integer s) { ... }
> }
>
> It is not ideal though.
>
> From looking at the code i think there was an intention to
> allow this (see the static generator methods on
> WadlGeneratorConfig) but then it seems like it was forgotten
> because the following of WadlGeneratorConfig requires
> overriding:
>
> public abstract List<WadlGeneratorDescription>
> configure();
>
> rather than:
>
> public abstract WadlGenerator configure();
>
> IMHO this whole area needs to be cleaned up. Marc did some
> work in a branch on using Java annotations rather than
> JavaDoc, which i think improves the ease of use, but Marc is
> no longer with us so we need to pick up that work.
>
> Paul.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>