admin@glassfish.java.net

Re: Question for Remote Command Developers

From: Jane Young <Jane.Young_at_Sun.COM>
Date: Tue, 08 Apr 2008 02:35:05 -0700

Hi, Byron.

This is a very good idea. Thanks for adding that. For the boolean
case, you may also want to consider case insensitive values (True,
TRUE, true etc.) but for other acceptableValue, case sensitivity is not
required.
Commands like list-components/applications can utilize acceptableValue
for type option where valid types are: application, ejb, web,
connector, webservice and jruby. Currently, I have a methond in
ListComponentsCommand.java that checks for the valid types and throws an
exception if value for type is not valid.
There's also the create-jmsdest command that takes values "topic" or
"queue" for --desttype option. I'm sure there are other remote commands
that can utilize this feature.

Thanks!
Jane


Byron Nevins wrote:

> I've implemented, but not checked in yet, support for validating param
> values against an acceptable list of values.
> This is immediately useful for boolean parameters -- we want
> 'booleanOptionX=garbage' to be a hard error rather than just silently
> setting it to false.
>
> Are there other use cases for "acceptableValues" in Remote Commands?
>
> E.g.
>
> before:
> @Param(optional=true)
> String enabled = Boolean.TRUE.toString();
>
> after:
> @Param(optional=true, acceptableValues="true,false")
> String enabled = Boolean.TRUE.toString();
>
> At injection time -- if the parameter has a value -- then it is
> compared against the comma separated list of acceptable values.
> If it does not match any of them -- an Exception is thrown before the
> execute() method is called.
>