You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by James Strachan <ja...@yahoo.co.uk> on 2003/04/04 16:36:28 UTC
[beanutils] default converters for File and URL?
I wondered if we should add default converters in beanutils that can
turn a String into a File or a URL? It seems like a no brainer and I'll
happily do the work - I just wondered if anyone could imagine a problem
with doing such a thing? I'd find this useful both on Jelly and on
other projects...
James
-------
http://radio.weblogs.com/0112098/
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [beanutils] default converters for File and URL?
Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
On Friday, April 4, 2003, at 04:29 PM, James Strachan wrote:
> On Friday, April 4, 2003, at 04:04 PM, Joe Germuska wrote:
<snip>
>> I'm not sure I understand all of the precedence rules -- is this how it
>> works? Each ClassLoader has one instance of a Class object for
>> ConvertUtils, and that object is ultimately where the registered
>> converters are stored. So as long as I don't load ConvertUtils with a
>> shared ClassLoader, there is no risk? So then, since I'm usually using
>> the BeanUtils package from a web application's WEB-INF/lib, the
>> conversions should only be visible within that web app.
>
> Agreed. Unless commons-beanutils gets into the system ClassLoader :)
>
> It'd be a good idea to use the instance based converter repositories to
> avoid this.
at the moment, the static utility classes are backed by singleton
instances. the plan is to replace this system by using an instance per
context class loader. this should gaurantee independence between web apps.
i've been busy and need some more time to think about what craig said on
this subject and i'm also considering whether to use a WeakHashMap (this
would allow the context classloader and associated instance to be garbage
collected) but hopefully i'll have some more time over the next few weeks
so it looks like getting done sooner or later.
any wisdom on this subject would be gratefully received :)
- robert
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [beanutils] default converters for File and URL?
Posted by Henri Yandell <ba...@generationjava.com>.
On Fri, 4 Apr 2003, Craig R. McClanahan wrote:
>
>
> On Fri, 4 Apr 2003, Joe Germuska wrote:
>
> > Date: Fri, 4 Apr 2003 11:03:41 -0600
> > From: Joe Germuska <Jo...@Germuska.com>
> > Reply-To: Jakarta Commons Developers List <co...@jakarta.apache.org>
> > To: Jakarta Commons Developers List <co...@jakarta.apache.org>
> > Subject: Re: [beanutils] default converters for File and URL?
> >
> > >So once a DateConverter is made, is the 'proper' way to handle the
> > >"YY/DD/MM" style thing to have a custom Locale? Or should I pursue the
> > >idea of optional arguments being settable on converters?
> >
> > I think this has some promise. After all, I can imagine using it via
> > a digester rule like
> > <set-property property="startDate" value="2003-04-04"
> > format="yyyy-MM-dd" /> This was part of the use case that started
> > our whole discussion. I think setting a format explicitly is much
> > safer than counting on Locales.
> >
>
> The interesting part of this issue (and why there's no default
> DateConverter) is deciding what String format to use by default. I would
> have leaned towards YYYY-MM-DD because that's what java.sql.Date does, but
> it's not particularly user friendly for input fields.
It's the only one that doesn't cause arguments :)
Probably it should try the Long, Medium then Short DateFormats based on
the default system Locale as the default. If it's still possible, it
should then try ISO-ish standards: YYYY-MM-DD HH:MM first, then
YYYY-MM-DD.
It should probably then stop there.
An opinion :)
Hen
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [beanutils] default converters for File and URL?
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Fri, 4 Apr 2003, Joe Germuska wrote:
> Date: Fri, 4 Apr 2003 11:03:41 -0600
> From: Joe Germuska <Jo...@Germuska.com>
> Reply-To: Jakarta Commons Developers List <co...@jakarta.apache.org>
> To: Jakarta Commons Developers List <co...@jakarta.apache.org>
> Subject: Re: [beanutils] default converters for File and URL?
>
> >So once a DateConverter is made, is the 'proper' way to handle the
> >"YY/DD/MM" style thing to have a custom Locale? Or should I pursue the
> >idea of optional arguments being settable on converters?
>
> I think this has some promise. After all, I can imagine using it via
> a digester rule like
> <set-property property="startDate" value="2003-04-04"
> format="yyyy-MM-dd" /> This was part of the use case that started
> our whole discussion. I think setting a format explicitly is much
> safer than counting on Locales.
>
The interesting part of this issue (and why there's no default
DateConverter) is deciding what String format to use by default. I would
have leaned towards YYYY-MM-DD because that's what java.sql.Date does, but
it's not particularly user friendly for input fields.
> Joe
Craig
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [beanutils] default converters for File and URL?
Posted by Joe Germuska <Jo...@Germuska.com>.
>So once a DateConverter is made, is the 'proper' way to handle the
>"YY/DD/MM" style thing to have a custom Locale? Or should I pursue the
>idea of optional arguments being settable on converters?
I think this has some promise. After all, I can imagine using it via
a digester rule like
<set-property property="startDate" value="2003-04-04"
format="yyyy-MM-dd" /> This was part of the use case that started
our whole discussion. I think setting a format explicitly is much
safer than counting on Locales.
Joe
--
--
Joe Germuska
Joe@Germuska.com
http://blog.germuska.com
"If nature worked that way, the universe would crash all the time."
--Jaron Lanier
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [beanutils] default converters for File and URL?
Posted by Henri Yandell <ba...@generationjava.com>.
On Fri, 4 Apr 2003, James Strachan wrote:
>
> On Friday, April 4, 2003, at 05:29 PM, robert burrell donkin wrote:
>
> >
> > On Friday, April 4, 2003, at 05:13 PM, James Strachan wrote:
> >
> >>
> >> On Friday, April 4, 2003, at 04:57 PM, Henri Yandell wrote:
> >>>
> >>> Looking at Converters, why is there no UtilDateConverter? Or just
> >>> DateConverter?
> >>>
> >>> Also, why does said converter not take a DateFormat in some way to
> >>> allow
> >>> instance users to be able to allow that to be configurable?
> >>>
> >>> Possibly the Converter API needs an additional argument-list option?
> >>>
> >>> So I can say:
> >>>
> >>> converterBean.convert(java.util.Date.class, "02/02/02", "YY/DD/MM")
> >>
> >> While we're at it, it could be useful to add a Locale to a
> >> ConverterUtilsBean so that converters can be locale-specific.
> >
> > isn't this already covered by LocaleConvertUtilsBean?
>
> Yes - DOH! Forget I mentioned it :)
So once a DateConverter is made, is the 'proper' way to handle the
"YY/DD/MM" style thing to have a custom Locale? Or should I pursue the
idea of optional arguments being settable on converters?
Hen
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [beanutils] default converters for File and URL?
Posted by James Strachan <ja...@yahoo.co.uk>.
On Friday, April 4, 2003, at 05:29 PM, robert burrell donkin wrote:
>
> On Friday, April 4, 2003, at 05:13 PM, James Strachan wrote:
>
>>
>> On Friday, April 4, 2003, at 04:57 PM, Henri Yandell wrote:
>>
>>>
>>> On Fri, 4 Apr 2003, James Strachan wrote:
>>>
>>>> On Friday, April 4, 2003, at 04:04 PM, Joe Germuska wrote:
>>>>
>>>>> But what if I'm using some library that has its own conversion
>>>>> needs,
>>>>> for example, in reading in an XML configuration file? I guess
>>>>> most
>>>>> conversions are pretty universal, volatile, but I can easily
>>>>> imagine
>>>>> conflicting Converters for java.util.Date, for example.
>>>
>>> Looking at Converters, why is there no UtilDateConverter? Or just
>>> DateConverter?
>>>
>>> Also, why does said converter not take a DateFormat in some way to
>>> allow
>>> instance users to be able to allow that to be configurable?
>>>
>>> Possibly the Converter API needs an additional argument-list option?
>>>
>>> So I can say:
>>>
>>> converterBean.convert(java.util.Date.class, "02/02/02", "YY/DD/MM")
>>
>> While we're at it, it could be useful to add a Locale to a
>> ConverterUtilsBean so that converters can be locale-specific.
>
> isn't this already covered by LocaleConvertUtilsBean?
Yes - DOH! Forget I mentioned it :)
James
-------
http://radio.weblogs.com/0112098/
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [beanutils] default converters for File and URL?
Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
On Friday, April 4, 2003, at 05:13 PM, James Strachan wrote:
>
> On Friday, April 4, 2003, at 04:57 PM, Henri Yandell wrote:
>
>>
>> On Fri, 4 Apr 2003, James Strachan wrote:
>>
>>> On Friday, April 4, 2003, at 04:04 PM, Joe Germuska wrote:
>>>
>>>> But what if I'm using some library that has its own conversion needs,
>>>> for example, in reading in an XML configuration file? I guess most
>>>> conversions are pretty universal, volatile, but I can easily imagine
>>>> conflicting Converters for java.util.Date, for example.
>>
>> Looking at Converters, why is there no UtilDateConverter? Or just
>> DateConverter?
>>
>> Also, why does said converter not take a DateFormat in some way to allow
>> instance users to be able to allow that to be configurable?
>>
>> Possibly the Converter API needs an additional argument-list option?
>>
>> So I can say:
>>
>> converterBean.convert(java.util.Date.class, "02/02/02", "YY/DD/MM")
>
> While we're at it, it could be useful to add a Locale to a
> ConverterUtilsBean so that converters can be locale-specific.
isn't this already covered by LocaleConvertUtilsBean?
- robert
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [beanutils] default converters for File and URL?
Posted by James Strachan <ja...@yahoo.co.uk>.
On Friday, April 4, 2003, at 04:57 PM, Henri Yandell wrote:
>
> On Fri, 4 Apr 2003, James Strachan wrote:
>
>> On Friday, April 4, 2003, at 04:04 PM, Joe Germuska wrote:
>>
>>> But what if I'm using some library that has its own conversion needs,
>>> for example, in reading in an XML configuration file? I guess most
>>> conversions are pretty universal, volatile, but I can easily imagine
>>> conflicting Converters for java.util.Date, for example.
>
> Looking at Converters, why is there no UtilDateConverter? Or just
> DateConverter?
>
> Also, why does said converter not take a DateFormat in some way to
> allow
> instance users to be able to allow that to be configurable?
>
> Possibly the Converter API needs an additional argument-list option?
>
> So I can say:
>
> converterBean.convert(java.util.Date.class, "02/02/02", "YY/DD/MM")
While we're at it, it could be useful to add a Locale to a
ConverterUtilsBean so that converters can be locale-specific.
James
-------
http://radio.weblogs.com/0112098/
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [beanutils] default converters for File and URL?
Posted by Henri Yandell <ba...@generationjava.com>.
On Fri, 4 Apr 2003, James Strachan wrote:
> On Friday, April 4, 2003, at 04:04 PM, Joe Germuska wrote:
>
> > But what if I'm using some library that has its own conversion needs,
> > for example, in reading in an XML configuration file? I guess most
> > conversions are pretty universal, volatile, but I can easily imagine
> > conflicting Converters for java.util.Date, for example.
Looking at Converters, why is there no UtilDateConverter? Or just
DateConverter?
Also, why does said converter not take a DateFormat in some way to allow
instance users to be able to allow that to be configurable?
Possibly the Converter API needs an additional argument-list option?
So I can say:
converterBean.convert(java.util.Date.class, "02/02/02", "YY/DD/MM")
Hen
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [beanutils] default converters for File and URL?
Posted by James Strachan <ja...@yahoo.co.uk>.
On Friday, April 4, 2003, at 04:04 PM, Joe Germuska wrote:
> At 3:36 PM +0100 2003/04/04, James Strachan wrote:
>> I wondered if we should add default converters in beanutils that can
>> turn a String into a File or a URL? It seems like a no brainer and
>> I'll happily do the work - I just wondered if anyone could imagine a
>> problem with doing such a thing? I'd find this useful both on Jelly
>> and on other projects...
>
> I agree that this is a no-brainer -- but it leads me to speak up about
> something I was discussing with someone here at work yesterday...
>
> The static nature of registering converters makes me a little
> nervous... are my concerns unfounded? Or is this just something in
> how the code evolved that people live with. I'm worried that I might
> register a convertor in place of one of the defaults and then break
> something somewhere else.
Agreed. Though I'm proposing adding default converters for File and URL
which can be overloaded by user applications if required. So this would
only break existing code if it was expecting there to be no converter
for File or URL.
> I'm not sure I understand all of the precedence rules -- is this how
> it works? Each ClassLoader has one instance of a Class object for
> ConvertUtils, and that object is ultimately where the registered
> converters are stored. So as long as I don't load ConvertUtils with a
> shared ClassLoader, there is no risk? So then, since I'm usually
> using the BeanUtils package from a web application's WEB-INF/lib, the
> conversions should only be visible within that web app.
Agreed. Unless commons-beanutils gets into the system ClassLoader :)
It'd be a good idea to use the instance based converter repositories to
avoid this.
> But what if I'm using some library that has its own conversion needs,
> for example, in reading in an XML configuration file? I guess most
> conversions are pretty universal, volatile, but I can easily imagine
> conflicting Converters for java.util.Date, for example.
>
> Should there be some available mechanism like a "ConverterSet" which
> could be instantiated and then used only in a limited environment?
>
> Am I thinking about this right? Or is it really no big deal?
You are and I agree.
ConverterUtils has an instance API called ConverterUtilBean which can
be instantiated and used privately to avoid clashes.
James
-------
http://radio.weblogs.com/0112098/
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [beanutils] default converters for File and URL?
Posted by Joe Germuska <Jo...@Germuska.com>.
At 3:36 PM +0100 2003/04/04, James Strachan wrote:
>I wondered if we should add default converters in beanutils that can
>turn a String into a File or a URL? It seems like a no brainer and
>I'll happily do the work - I just wondered if anyone could imagine a
>problem with doing such a thing? I'd find this useful both on Jelly
>and on other projects...
I agree that this is a no-brainer -- but it leads me to speak up
about something I was discussing with someone here at work
yesterday...
The static nature of registering converters makes me a little
nervous... are my concerns unfounded? Or is this just something in
how the code evolved that people live with. I'm worried that I might
register a convertor in place of one of the defaults and then break
something somewhere else.
I'm not sure I understand all of the precedence rules -- is this how
it works? Each ClassLoader has one instance of a Class object for
ConvertUtils, and that object is ultimately where the registered
converters are stored. So as long as I don't load ConvertUtils with
a shared ClassLoader, there is no risk? So then, since I'm usually
using the BeanUtils package from a web application's WEB-INF/lib, the
conversions should only be visible within that web app.
But what if I'm using some library that has its own conversion needs,
for example, in reading in an XML configuration file? I guess most
conversions are pretty universal, volatile, but I can easily imagine
conflicting Converters for java.util.Date, for example.
Should there be some available mechanism like a "ConverterSet" which
could be instantiated and then used only in a limited environment?
Am I thinking about this right? Or is it really no big deal?
Joe
--
--
Joe Germuska
Joe@Germuska.com
http://blog.germuska.com
"If nature worked that way, the universe would crash all the time."
--Jaron Lanier
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [beanutils] default converters for File and URL?
Posted by James Strachan <ja...@yahoo.co.uk>.
On Friday, April 4, 2003, at 03:44 PM, Henri Yandell wrote:
>
> I know I found it useful. [Got a URLConverter in simple-jndi].
Cool. Fancy adding it to beanutils and I'll take care of FileConverter?
James
-------
http://radio.weblogs.com/0112098/
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [beanutils] default converters for File and URL?
Posted by Henri Yandell <ba...@generationjava.com>.
I know I found it useful. [Got a URLConverter in simple-jndi].
Hen
On Fri, 4 Apr 2003, James Strachan wrote:
> I wondered if we should add default converters in beanutils that can
> turn a String into a File or a URL? It seems like a no brainer and I'll
> happily do the work - I just wondered if anyone could imagine a problem
> with doing such a thing? I'd find this useful both on Jelly and on
> other projects...
>
> James
> -------
> http://radio.weblogs.com/0112098/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org