camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Ford (JIRA)" <>
Subject [jira] Commented: (CAMEL-3255) Add property to DefaultCamelContext to allow for lazy loading of the DefaultTypeConverter
Date Thu, 21 Oct 2010 12:17:40 GMT


Mark Ford commented on CAMEL-3255:


I respectively disagree that having a base class makes it easier for a future variation. I
think the strategy pattern works better here than inheritance since it isolates the differences
in behavior. It's conceivable that additional variations would want to change behavior in
your base class but also have variations on their resource loading strategies. Inheritance
will result in a proliferation of classes.

The problem I see with both implementations is that the check for whether the types converters
are loaded is in many places. I based my restoration of the checks on the diff from CAMEL-2392.
I'm assuming you did the same either by following my changes or referring back to the issue.
In my solution it's troubling since the calls are hard to find since they're buried in method
bodies in some places (as was done originally). In yours, it's obvious but awkward since the
subclass does nothing but override a number of methods to do the check before calling super.
It's not a good use of inheritance here.

A better solution in both cases would be to refactor the code to have a single point for accessing
the type mappings. This single point could then invoke the strategy method to see if they
were loaded or not. I was going to do this in a second pass after I had a little more time
but figured I'd start with a smaller change. If there's interest on your part, I'm willing
to submit another patch along these lines.

> Add property to DefaultCamelContext to allow for lazy loading of the DefaultTypeConverter
> -----------------------------------------------------------------------------------------
>                 Key: CAMEL-3255
>                 URL:
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-core
>    Affects Versions: 2.2.0, 2.3.0, 2.4.0
>            Reporter: Mark Ford
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.5.0
>         Attachments: patch.txt
> The loading of type converters was changed from a lazy loading to an up front loading
in a Camel 2.2. See issue CAMEL-2392 for details. Accordingly to the logging, it takes approximately
300 millis for this process to complete. 
> The proposal is to allow the configuration of this loading strategy for cases where the
initialization time of contexts is more important than the loading of type converters. The
"lazyLoadTypeConverters" property on the context will default to false to preserve the current
up front loading behavior as the default. If this value is set to true, then the loading of
the type converters will happen when accessed.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message