dev@glassfish.java.net

Re: [Fwd: Computed default value question]

From: Jerome Dochez <jerome.dochez_at_oracle.com>
Date: Mon, 13 Dec 2010 10:28:56 -0800

On Dec 10, 2010, at 11:06 AM, Chris Kasso wrote:

>
> I sent this question just as the migration was starting and never saw any responses so I'll try once more...
>
> Chris
>
> From: Chris Kasso <chris.kasso_at_oracle.com>
> Date: November 22, 2010 5:00:12 PM PST
> To: dev_at_glassfish.dev.java.net
> Subject: Computed default value question
> Reply-To: dev_at_glassfish.dev.java.net
>
>
> I have a configbean where I need to compute the default value so I
> can't use @Attribute(defaultValue=="XXXX"). I would like the
> getter method to return this computed value if the attribute
> was never set.
>
> In my scenario the computed default could be established when the bean
> is instantiated or when the getter is invoked.
>
> Is there a way to do this with our ConfigBeans?
the only way I can think of is to use a @DuckType method to act as the getter, it will use the "real" getter (the one mapped to the xml element) or compute the value the default. That means that glassfish code will need to use the @DuckType rather than the real getter, so it's not full proof if people use the wrong API.

jerome

>
> thanks,
> Chris
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>
>
>