admin@glassfish.java.net

Re: a question on config api

From: Tom Mueller <tom.mueller_at_oracle.com>
Date: Wed, 02 Feb 2011 09:59:09 -0600

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
>>>>>
>>>>>
>>>>
>>