Yeah, it will be available in camel 2.20.x out of the box like:

EhcacheComponent component = new EhcacheComponent());
component.setCacheManager(manager);

Main main = new Main();
main.bind("ehcache", component);

I will back-port some of the changes I made today in 2.19.x so it will
be available in the next camel 2.19 patch.


---
Luca Burgazzoli


On Tue, May 16, 2017 at 5:47 PM, Henri Tremblay
<henri.tremb...@gmail.com> wrote:
> Nothing. It's perfect ;-)
>
> In fact I wanted to inject the cache manager. It seemed highly supported by
> all the code except from constructors and builders.
>
> CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder()
>     .withCache("testCache",
> CacheConfigurationBuilder.newCacheConfigurationBuilder(String.class,
> String.class,
>         ResourcePoolsBuilder.newResourcePoolsBuilder().heap(10,
> EntryUnit.ENTRIES)))
>     .build(true);
>
> Main main = new Main();
> main.getOrCreateCamelContext().addComponent("ehcache", new EhcacheComponent() 
> {
>     @Override
>     protected Endpoint createEndpoint(String uri, String remaining,
> Map<String, Object> parameters) throws Exception {
>         EhcacheConfiguration configuration = EhcacheConfiguration.create(
>             getCamelContext(),
>             remaining,
>             parameters);
>         configuration.setCacheManager(cacheManager);
>         return new EhcacheEndpoint(uri, this, configuration);
>     }
> });
>
>
> On 16 May 2017 at 10:55, Luca Burgazzoli <lburgazz...@gmail.com> wrote:
>
>> In camel 2.19.x EhcacheConfiguration is an internal object used to
>> holds the endpoint configurations but in 2.20.0 you can provide your
>> own instance on component level so it will provides the defaults for
>> every endpoint (i.e. you'll be able to set the default cache manager
>> so you do not need to set it for each endpoint).
>>
>> Just asking, what do you want to achieve with "an overloaded version
>> of the component or endpoint" ? Because if the component lacks any
>> functionality we are more that happy to improve it :)
>>
>> ---
>> Luca Burgazzoli
>>
>>
>> On Tue, May 16, 2017 at 4:41 PM, Henri Tremblay
>> <henri.tremb...@gmail.com> wrote:
>> > Thanks. Looks much better now. I've posted my new answer to SO. And
>> indeed,
>> > the official documentation is not talking about a possible cache manager
>> to
>> > pass.
>> >
>> > I still have one question though. Is it normal that EhcacheConfiguration
>> > can be instantiated? It seems normal to want to propose an overloaded
>> > version of the component or endpoint. And it is currently impossible
>> > (without overloading EhcacheConfiguration but I'm not sure it is
>> allowed).
>> >
>> > On 16 May 2017 at 05:28, Luca Burgazzoli <lburgazz...@gmail.com> wrote:
>> >
>> >> Yes it is possible using the cacheManager uri option.
>> >> The docs on website may be out of sync, for the latest doc have a look
>> >> at: https://github.com/apache/camel/blob/master/components/
>> >> camel-ehcache/src/main/docs/ehcache-component.adoc
>> >>
>> >> I will add the missing info to the camel website doc.
>> >>
>> >> Also answered on StackOverflow.
>> >>
>> >> ---
>> >> Luca Burgazzoli
>> >>
>> >>
>> >> On Mon, May 15, 2017 at 8:11 PM, Henri Tremblay
>> >> <henri.tremb...@gmail.com> wrote:
>> >> > Hi,
>> >> >
>> >> > Following a stack overflow question (
>> >> > http://stackoverflow.com/questions/43915633/how-to-
>> >> access-apache-camel-eh-cache-outside-camel-context)
>> >> > I realized that it is impossible cleanly.
>> >> >
>> >> > Am I right?
>> >> >
>> >> > Let's rephrase the problem here:
>> >> >
>> >> > Camel is using camel-ehcache but the same cache manager can be used
>> >> > somewhere else. So I would like to do one of these:
>> >> > 1- Give my own cache manager to camel
>> >> > 2- Retrieve camel cache manager
>> >> >
>> >> > The problem is EhcacheConfiguration. All ways to create this class
>> have
>> >> the
>> >> > default scope. It feels like a bug to me. Because, being able to
>> create
>> >> it,
>> >> > I could call setCacheManager and be done with it.
>> >> >
>> >> > I also noticed that the EhcacheEndpoint can't pass the "managed"
>> flag. It
>> >> > seems useful in the case of a shared CacheManager to set it to false.
>> >> >
>> >> > So, am I missing something?
>> >> >
>> >> > Thanks,
>> >> > Henri Tremblay
>> >> > Ehcache developer
>> >> > Java Champion
>> >>
>>

Reply via email to