admin@glassfish.java.net

Re: REST API and Case Issues

From: Jason Lee <jason.d.lee_at_oracle.com>
Date: Fri, 16 Apr 2010 11:46:59 -0500

Perhaps a concrete example might help. Take this OPTIONS request for a
JDBC connection pool

$ curl -X OPTIONS
http://localhost:4848/management/domain/resources/jdbc-connection-pool
{"JdbcConnectionPool":
   {
     "Method":{
       "Name":"POST",
       "Message Parameters":{
         "validationmethod":{"Acceptable
Values":"auto-commit,meta-data,table,custom-validation", "Default
Value":"", "Type":"string", "Optional":"true"},
         "leaktimeout":{"Acceptable Values":"", "Default Value":"",
"Type":"string", "Optional":"true"},
         "creationretryinterval":{"Acceptable Values":"", "Default
Value":"", "Type":"string", "Optional":"true"},
         "lazyconnectionassociation":{"Acceptable Values":"", "Default
Value":"false", "Type":"boolean", "Optional":"true"},
         "allownoncomponentcallers":{"Acceptable Values":"", "Default
Value":"false", "Type":"boolean", "Optional":"true"},
         "statementtimeout":{"Acceptable Values":"", "Default Value":"",
"Type":"string", "Optional":"true"},
         "datasourceclassname":{"Acceptable Values":"", "Default
Value":"", "Type":"string", "Optional":"true"},
         "id":{"Acceptable Values":"", "Default Value":"",
"Type":"string", "Optional":"false"},
         "maxpoolsize":{"Acceptable Values":"", "Default Value":"",
"Type":"string", "Optional":"true"},
         "steadypoolsize":{"Acceptable Values":"", "Default Value":"",
"Type":"string", "Optional":"true"},
         "description":{"Acceptable Values":"", "Default Value":"",
"Type":"string", "Optional":"true"},
         "wrapjdbcobjects":{"Acceptable Values":"", "Default
Value":"true", "Type":"boolean", "Optional":"true"},
         "matchconnections":{"Acceptable Values":"", "Default
Value":"false", "Type":"boolean", "Optional":"true"},
         "creationretryattempts":{"Acceptable Values":"", "Default
Value":"", "Type":"string", "Optional":"true"},
         "nontransactionalconnections":{"Acceptable Values":"", "Default
Value":"false", "Type":"boolean", "Optional":"true"},
         "associatewiththread":{"Acceptable Values":"", "Default
Value":"false", "Type":"boolean", "Optional":"true"},
         "sqltracelisteners":{"Acceptable Values":"", "Default
Value":"", "Type":"string", "Optional":"true"},
         "ping":{"Acceptable Values":"", "Default Value":"false",
"Type":"boolean", "Optional":"true"},
         "maxconnectionusagecount":{"Acceptable Values":"", "Default
Value":"", "Type":"string", "Optional":"true"},
         "statementcachesize":{"Acceptable Values":"", "Default
Value":"0", "Type":"string", "Optional":"true"},
         "isolationlevel":{"Acceptable Values":"", "Default Value":"",
"Type":"string", "Optional":"true"},
         "initsql":{"Acceptable Values":"", "Default Value":"",
"Type":"string", "Optional":"true"},
         "poolresize":{"Acceptable Values":"", "Default Value":"",
"Type":"string", "Optional":"true"},
         "driverclassname":{"Acceptable Values":"", "Default Value":"",
"Type":"string", "Optional":"true"},
         "maxwait":{"Acceptable Values":"", "Default Value":"",
"Type":"string", "Optional":"true"},
         "failconnection":{"Acceptable Values":"", "Default
Value":"false", "Type":"boolean", "Optional":"true"},
         "idletimeout":{"Acceptable Values":"", "Default Value":"",
"Type":"string", "Optional":"true"},
         "property":{"Acceptable Values":"", "Default Value":"",
"Type":"string", "Optional":"true"},
         "isconnectvalidatereq":{"Acceptable Values":"", "Default
Value":"false", "Type":"boolean", "Optional":"true"},
         "isisolationguaranteed":{"Acceptable Values":"", "Default
Value":"true", "Type":"boolean", "Optional":"true"},
         "validateatmostonceperiod":{"Acceptable Values":"", "Default
Value":"", "Type":"string", "Optional":"true"},
         "validationclassname":{"Acceptable Values":"", "Default
Value":"", "Type":"string", "Optional":"true"},
         "validationtable":{"Acceptable Values":"", "Default Value":"",
"Type":"string", "Optional":"true"},
         "pooling":{"Acceptable Values":"", "Default Value":"true",
"Type":"boolean", "Optional":"true"},
         "leakreclaim":{"Acceptable Values":"", "Default Value":"false",
"Type":"boolean", "Optional":"true"},
         "target":{"Acceptable Values":"", "Default Value":"",
"Type":"string", "Optional":"true"},
         "lazyconnectionenlistment":{"Acceptable Values":"", "Default
Value":"false", "Type":"boolean", "Optional":"true"},
         "restype":{"Acceptable
Values":"javax.sql.DataSource,javax.sql.XADataSource,javax.sql.ConnectionPoolDataSource,java.sql.Driver",
"Default Value":"", "Type":"string", "Optional":"true"}
       }
     },
     "Method":{
       "Name":"GET"
     }
   }
}

Note that the keys for the message parameters for the POST method are
all lower case. In the console, we have markup in our pages that look
like this:

<sun:textField id="ds" styleClass="integer" columns="$int{10}"
text="#{pageSession.valueMap.SteadyPoolSize}" />

<sun:textField id="ds2" styleClass="integer" columns="$int{10}"
text="#{pageSession.valueMap.MaxPoolSize}" />

and so on.

Personally, I'd prefer we change the output of the REST API to preserve
the case of these attributes, as that requires far fewer changes on the
console (to be fair, I haven't yet an idea of the level of effort in
changing the REST side), and also makes stub generation (for Python or
Ruby, for example) a little nicer.

Any thoughts? We can't move forward with the console migration until
this issue is resolved.

On 4/15/10 3:47 PM, Jerome Dochez wrote:
> so the console is ignoring case while the REST API does not ?
>
> On Apr 15, 2010, at 11:53 AM, Jason Lee wrote:
>
>
>> On 4/14/10 5:24 PM, Jerome Dochez wrote:
>>
>>> it depends on what ConfigBean these REST APIs are mapped to. For the most part the REST API to alter the ConfigBeans directly but there are cases (like deployment) where you don't want to just alter the configuration, you want to deploy so it makes more sense to redirect the REST APIs to a command class rather than changing the config bean directly.
>>>
>>> which ones were creating issue for you ?
>>>
>>>
>> Hrm. That's a good point. The resource in question, at the moment, is JdbcConnectionPoolResource.
>>
>> OK. So I understand the why of the command class, and that makes sense. I still prefer, I think, to see mixed case on property names returned by the REST API. Anyone have thoughts on that? Would it be unwise to change what the REST API returns? Should be try to address the case issue on the console side?
>>
>> --
>> Jason Lee
>> Senior Member of Technical Staff
>> GlassFish Administration Console
>>
>> Oracle Corporation
>> Phone x31197/+1 405-343-1964
>> Blog http://blogs.steeplesoft.com
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: admin-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: admin-help_at_glassfish.dev.java.net
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: admin-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: admin-help_at_glassfish.dev.java.net
>
>


-- 
Jason Lee
Senior Member of Technical Staff
GlassFish Administration Console
Oracle Corporation
Phone x31197/+1 405-343-1964
Blog http://blogs.steeplesoft.com