admin@glassfish.java.net

Re: a question on config api

From: Bill Shannon <bill.shannon_at_oracle.com>
Date: Thu, 03 Feb 2011 10:48:29 -0800

It's hard in the CLI because it crosses semantic layers.

Quote processing is done without any knowledge of the command or items
being quoted. By the time the command sees its arguments, the quotes
are gone, leaving it no way to distinguish between 'a=' and 'a=""'.

We could add "asadmin settonull sessionfilename", but that's pretty
gross too, and most people will miss the subtle difference between
null and the empty string.

Likewise, in the GUI, adding the ability to distinguish probably requires
a separate checkbox to say "set to null" and disable the text field.

I think it's better to have a distinguished value for the field, as I
described in my previous message, or a separate boolean attribute that
controls whether session state is saved or not.


Shing Wai Chan wrote on 02/03/2011 10:25 AM:
> I think we need to have a way to set "" explicitly in both asadmin and admin gui.
> Shing Wai Chan
>
> On 2/3/11 10:19 AM, Tom Mueller wrote:
>> From my previous response: There isn't anyway using the current set command to
>> set a value to an empty string via asadmin.
>>
>> Tom
>>
>> On 2/3/2011 12:09 PM, Shing Wai Chan wrote:
>>> Hi Tom,
>>> Thanks for your reply.
>>> This is what I need.
>>> But now, we need to know how to do that in CLI and admin gui.
>>> Note that in admin gui, or CLI, if we don't specify, then it is a null which
>>> becomes a default.
>>> Is there a way to specify "" in admin gui or CLI?
>>> Thanks.
>>> Shing Wai Chan
>>>
>>> On 2/3/11 10:01 AM, Tom Mueller wrote:
>>>> I checked the config API interface, and found my assumption below is incorrect.
>>>>
>>>> If you call setSessionFileName(""), you get "" as the value for the
>>>> attribute. If you call setSessionFileName(null), the value is reset to the
>>>> default value.
>>>>
>>>> Note, though, that if you do:
>>>>
>>>> asadmin set someattribute=
>>>>
>>>> the set command translates this into a setSomeattribute(null), so the value
>>>> is reset to the default value. There isn't anyway using the current set
>>>> command to set a value to an empty string via asadmin. However, if you edit
>>>> the domain.xml and insert someattribute="" in the XML, then the empty string
>>>> will be used by the server.
>>>>
>>>> Tom
>>>>
>>>> On 2/2/2011 2:23 PM, Shing Wai Chan wrote:
>>>>> Having "" session file name to indicate disable writing is a feature in
>>>>> sun-web.xml.
>>>>> See http://blogs.sun.com/jluehe/entry/how_to_disable_persisting_of
>>>>>
>>>>> Is it more consistent for ManagerProperties behaving the same way?
>>>>> Shing Wai Chan
>>>>>
>>>>> On 2/2/11 12:07 PM, Tom Mueller wrote:
>>>>>> What does having a value of "" for the session-file-name mean? Does is
>>>>>> mean to not store session data?
>>>>>> If so, maybe there should be a boolean flag: enable-session-data-storage.
>>>>>>
>>>>>> I haven't verified this by locating the code, but I suspect that
>>>>>> setSessionFileName("") means return it to the default value.
>>>>>>
>>>>>> Tom
>>>>>>
>>>>>>
>>>>>> On 2/2/2011 12:27 PM, Shing Wai Chan wrote:
>>>>>>> Hi Tom,
>>>>>>> Let me describe what I need.
>>>>>>> Out of the box, I want to have a default value "SESSIONS.ser".
>>>>>>> And that need to be able to set with value "".
>>>>>>> I try @Attribute(defaultValue="SESSIONS.ser") before.
>>>>>>> I find that the default value will be provided if I set it "".
>>>>>>> How can we achieve this?
>>>>>>> Thanks.
>>>>>>> Shing Wai Chan
>>>>>>>
>>>>>>>
>>>>>>> On 2/2/11 7:59 AM, Tom Mueller wrote:
>>>>>>>> Shing Wai,
>>>>>>>> I'm not sure that I understand the question either.
>>>>>>>>
>>>>>>>> I don't understand what you mean by "internally we have a default". Do
>>>>>>>> you mean that inside your code, you check to see if the value of the
>>>>>>>> attribute is null, and then use "SESSIONS.ser" instead?
>>>>>>>>
>>>>>>>> What actually is the problem?
>>>>>>>>
>>>>>>>> Is it that when you have @Attribute(defaultValue="SESSIONS.ser"), and
>>>>>>>> then someone does setSessionFileName(""), that the value doesn't go to
>>>>>>>> the empty string but instead goes back to the default value? Same with
>>>>>>>> calling setSessionFileName(null)?
>>>>>>>>
>>>>>>>> Tom
>>>>>>>>
>>>>>>>>
>>>>>>>> On 2/1/2011 9:08 PM, Jennifer Chou wrote:
>>>>>>>>> Maybe I don't quite understand. Can you check if
>>>>>>>>> ManagerProperties.getSessionFileName() returns null to distinguish that
>>>>>>>>> sessionFileName was not set?
>>>>>>>>> Can you give some specific examples for when defaultValue, "", null
>>>>>>>>> should be used?
>>>>>>>>>
>>>>>>>>> On 2/1/2011 9:27 PM, Shing Wai Chan wrote:
>>>>>>>>>> If I do not set the default value, then I will get null for
>>>>>>>>>> ManagerProperties.getSessionFileName() when user does not specify
>>>>>>>>>> element.
>>>>>>>>>> In our case, how can distinguish between not set and explicitly set it
>>>>>>>>>> to "".
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On 2/1/11 4:48 PM, Jennifer Chou wrote:
>>>>>>>>>>> Actually, I think if you have a default value it will always return
>>>>>>>>>>> the default value if you don't set any value (set to "" or null).
>>>>>>>>>>> I guess you should not use the defaultValue on the attribute so you
>>>>>>>>>>> can set it to "" or null.
>>>>>>>>>>> Then maybe you can add a static field or method to return the default
>>>>>>>>>>> value? I don't know if that will work for you.
>>>>>>>>>>>
>>>>>>>>>>> On 2/1/2011 7:06 PM, Shing Wai Chan wrote:
>>>>>>>>>>>> cc. Tom
>>>>>>>>>>>> Any comment?
>>>>>>>>>>>> Shing Wai Chan
>>>>>>>>>>>>
>>>>>>>>>>>> On 2/1/11 3:32 PM, Shing Wai Chan wrote:
>>>>>>>>>>>>> Hi Jennifer,
>>>>>>>>>>>>>
>>>>>>>>>>>>> I have a question on admin backend. Hope that you can help me.
>>>>>>>>>>>>> There is a attribute in config-api/.../ManagerProperties.java:
>>>>>>>>>>>>> @Attribute
>>>>>>>>>>>>> public String getSessionFileName();
>>>>>>>>>>>>>
>>>>>>>>>>>>> Right now, the default is null.
>>>>>>>>>>>>> But internally, we have a default "SESSIONS.ser".
>>>>>>>>>>>>> There is a bug that we cannot unset this value.
>>>>>>>>>>>>>
>>>>>>>>>>>>> What is the best way to do that?
>>>>>>>>>>>>> I try to change it as follows:
>>>>>>>>>>>>> - @Attribute
>>>>>>>>>>>>> + @Attribute(defaultValue="SESSIONS.ser")
>>>>>>>>>>>>> public String getSessionFileName();
>>>>>>>>>>>>>
>>>>>>>>>>>>> and find that the admin backend will provide the default value
>>>>>>>>>>>>> "SESSIONS.ser"
>>>>>>>>>>>>> if we don't set a value for sessionFileName.
>>>>>>>>>>>>>
>>>>>>>>>>>>> What is the best way to resolve this?
>>>>>>>>>>>>> Is there anyway we can specify "" or null and has a non-empty
>>>>>>>>>>>>> default String?
>>>>>>>>>>>>>
>>>>>>>>>>>>> Please let me know.
>>>>>>>>>>>>> Thanks.
>>>>>>>>>>>>> Shing Wai Chan
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>
>>>>>
>>>
>