Hi

Yes it makes sense to include such a converter in the camel-core.
Fell free to create a JIRA ticket and attach your class.



On Thu, Aug 18, 2011 at 11:19 AM, Bengt Rodehav <[email protected]> wrote:
> Claus,
>
> I've now solved the problem by creating a String->TimeZone converter.
>
> My converter looks like this:
>
> *public class String2TimeZoneConverter implements TypeConverter {
>>   @SuppressWarnings("unchecked")
>>   public <T> T convertTo(Class<T> type, Object value) {
>>     return (T) TimeZone.getTimeZone((String) value);
>>   }
>>   public <T> T convertTo(Class<T> type, Exchange exchange, Object value) {
>>     return convertTo(type, value);
>>   }
>>   public <T> T mandatoryConvertTo(Class<T> type, Object value) {
>>     return convertTo(type, value);
>>   }
>>   public <T> T mandatoryConvertTo(Class<T> type, Exchange exchange, Object
>> value) {
>>     return convertTo(type, value);
>>   }
>> }*
>
> *
> *
> I currently set the converter explicitly on the context like this:
>
> *context.getTypeConverterRegistry().addTypeConverter(TimeZone.class,
>> String.class, new String2TimeZoneConverter());*
>
>
> I can then create an endpoint using the following URI:
>
> quartz://groupName/timerName?cron=<cronExpression>&trigger.timeZone=Europe/Stockholm
>
> I guess it would be useful to include a String->TimeZone converter in camel
> core. What do you think?
>
> /Bengt
>
>
>
> 2011/8/16 Bengt Rodehav <[email protected]>
>
>> Claus,
>>
>> I think I spoke to soon. I didn't test what I thought I was testing and
>> when verifiying again it does seem like a type converter is needed just like
>> you wrote. I''ll keep you posted when I get it to work.
>>
>> /Bengt
>>
>>
>> 2011/8/16 Claus Ibsen <[email protected]>
>>
>>> On Tue, Aug 16, 2011 at 12:34 PM, Bengt Rodehav <[email protected]>
>>> wrote:
>>> > Thanks for your reply Claus,
>>> >
>>> > I hadn't noticed the "trigger.XXX" syntax in camel-quartz. I tried the
>>> > following syntax:
>>> >
>>> >
>>> quartz://groupName/timerName?cron=<cronExpression>&trigger.timeZone=Europe/Stockholm
>>> >
>>> > This seems to work without having to implement a String ->TimeZone
>>> > converter. I don't know why but as long as it works I'm happy.
>>> >
>>>
>>> Camel also uses the JDK java bean property "thingy" which apparently
>>> work for TimeZone.
>>>
>>> I added your example to the quartz wiki page
>>>
>>>
>>> > Thanks for your help,
>>> >
>>> > /Bengt
>>> >
>>> > 2011/8/15 Claus Ibsen <[email protected]>
>>> >
>>> >> On Mon, Aug 15, 2011 at 8:50 AM, Bengt Rodehav <[email protected]>
>>> wrote:
>>> >> > I have previously been using the Quartz support in ServiceMix 3.x. In
>>> >> those
>>> >> > configurations we always specified the time zone as a separate
>>> property.
>>> >> > Since a while back we've migrated to Camel and thus use camel-quartz
>>> for
>>> >> > this. We currently use Camel 2.7.1.
>>> >> >
>>> >> > However, I cannot see an option in camel-quartz to specify the time
>>> zone
>>> >> for
>>> >> > my cron expressions. It seems like a missing feature.
>>> >> > camel-quartz seems to use UTC  (not the local time zone) but I'm not
>>> 100%
>>> >> > sure on this. Anyway, it is very important to being able to specify a
>>> >> > timezone for the cron expression.
>>> >> >
>>> >> > Does anyone know if this is supported?
>>> >> >
>>> >>
>>> >> It seems you set in on the trigger
>>> >>
>>> >>
>>> http://www.quartz-scheduler.org/api/1.8.1/org/quartz/CronTrigger.html#setTimeZone(java.util.TimeZone)
>>> >>
>>> >> So something like in the uri
>>> >>
>>> >> quartz:xxxx?trigger.timeZone=yyy
>>> >>
>>> >> However we may need a String -> TimeZone converter.
>>> >>
>>> >>
>>> >> It also looks as if you can specify it in the cron syntax
>>> >> http://forums.terracotta.org/forums/posts/list/5142.page
>>> >>
>>> >>
>>> >> Maybe we should also allow people to set a timezone on the quartz
>>> >> component, so it will use that as a default, in case the endpoint has
>>> >> not been configured with an explicit timezone?
>>> >>
>>> >> Fell free to create a JIRA ticket
>>> >>
>>> >> And as we love contribution, then patches with unit tests is welcome :)
>>> >>
>>> >>
>>> >> > /Bengt
>>> >> >
>>> >>
>>> >>
>>> >>
>>> >> --
>>> >> Claus Ibsen
>>> >> -----------------
>>> >> FuseSource
>>> >> Email: [email protected]
>>> >> Web: http://fusesource.com
>>> >> Twitter: davsclaus, fusenews
>>> >> Blog: http://davsclaus.blogspot.com/
>>> >> Author of Camel in Action: http://www.manning.com/ibsen/
>>> >>
>>> >
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> -----------------
>>> FuseSource
>>> Email: [email protected]
>>> Web: http://fusesource.com
>>> Twitter: davsclaus, fusenews
>>> Blog: http://davsclaus.blogspot.com/
>>> Author of Camel in Action: http://www.manning.com/ibsen/
>>>
>>
>>
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: [email protected]
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Reply via email to