You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@juneau.apache.org by James Bognar <ja...@apache.org> on 2017/06/05 20:30:52 UTC

Improved @RestResource properties annotation.

One of the current limitations of the @RestResource(properties) annotation
is that you can only specify String values.  But several serializer/parser
properties are classes.  You can specify a class string, but if the class
was loaded in a different classloader from the servlet container,
Class.forName(String) does not work.

Here's an example of what we currently have:
@RestResource(
properties={
@Property(name=HTML_uriAnchorText, value=PROPERTY_NAME),
@Property(name=REST_allowMethodParam, value="*"),
@Property(name=BEAN_debug, value="true"),
@Property(name=BEAN_sortProperties, value="true"),
@Property(name=HTML_addBeanTypeProperties, value="true"),
@Property(name=BEAN_beanDictionary, value="org.foo.MyBeanDictionary")
}
)

Instead, perhaps we can define them like so broken down into strings,
booleans, and classes?
@RestResource(
properties=@Properties(
strings={
@Property(name=HTML_uriAnchorText, value=PROPERTY_NAME),
@Property(name=REST_allowMethodParam, value="*")
},
flags={
BEAN_debug,
BEAN_sortProperties,
HTML_addBeanTypeProperties,
},
classes={
@ClassProperty(name=BEAN_dictionary, value=MyBeanDictionary.class)
}
)
)

Re: Improved @RestResource properties annotation.

Posted by James Bognar <ja...@salesforce.com>.
Ugh...formatting...

Here's an example of what we currently have:
@RestResource(
   properties={
      @Property(name=HTML_uriAnchorText, value=PROPERTY_NAME),
      @Property(name=REST_allowMethodParam, value="*"),
      @Property(name=BEAN_debug, value="true"),
      @Property(name=BEAN_sortProperties, value="true"),
      @Property(name=HTML_addBeanTypeProperties, value="true"),
      @Property(name=BEAN_beanDictionary, value="org.foo.MyBeanDictionary")
   }
)

Instead, perhaps we can define them like so broken down into strings,
booleans, and classes?
@RestResource(
   properties=@Properties(
      strings={
         @Property(name=HTML_uriAnchorText, value=PROPERTY_NAME),
         @Property(name=REST_allowMethodParam, value="*")
      },
      flags={
         BEAN_debug,
         BEAN_sortProperties,
         HTML_addBeanTypeProperties,
      },
      classes={
         @ClassProperty(name=BEAN_dictionary, value=MyBeanDictionary.class)
      }
   )
)

On Mon, Jun 5, 2017 at 4:30 PM, James Bognar <ja...@apache.org> wrote:

> One of the current limitations of the @RestResource(properties) annotation
> is that you can only specify String values.  But several serializer/parser
> properties are classes.  You can specify a class string, but if the class
> was loaded in a different classloader from the servlet container,
> Class.forName(String) does not work.
>
> Here's an example of what we currently have:
> @RestResource(
> properties={
> @Property(name=HTML_uriAnchorText, value=PROPERTY_NAME),
> @Property(name=REST_allowMethodParam, value="*"),
> @Property(name=BEAN_debug, value="true"),
> @Property(name=BEAN_sortProperties, value="true"),
> @Property(name=HTML_addBeanTypeProperties, value="true"),
> @Property(name=BEAN_beanDictionary, value="org.foo.MyBeanDictionary")
> }
> )
>
> Instead, perhaps we can define them like so broken down into strings,
> booleans, and classes?
> @RestResource(
> properties=@Properties(
> strings={
> @Property(name=HTML_uriAnchorText, value=PROPERTY_NAME),
> @Property(name=REST_allowMethodParam, value="*")
> },
> flags={
> BEAN_debug,
> BEAN_sortProperties,
> HTML_addBeanTypeProperties,
> },
> classes={
> @ClassProperty(name=BEAN_dictionary, value=MyBeanDictionary.class)
> }
> )
> )
>



-- 
James Bognar