Return-Path: Delivered-To: apmail-camel-dev-archive@www.apache.org Received: (qmail 16559 invoked from network); 1 Jan 2011 17:10:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 1 Jan 2011 17:10:47 -0000 Received: (qmail 46173 invoked by uid 500); 31 Dec 2010 09:04:06 -0000 Delivered-To: apmail-camel-dev-archive@camel.apache.org Received: (qmail 46128 invoked by uid 500); 31 Dec 2010 09:04:06 -0000 Mailing-List: contact dev-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list dev@camel.apache.org Received: (qmail 46120 invoked by uid 500); 31 Dec 2010 09:04:06 -0000 Delivered-To: apmail-activemq-camel-dev@activemq.apache.org Received: (qmail 46117 invoked by uid 99); 31 Dec 2010 09:04:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 31 Dec 2010 09:04:06 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 31 Dec 2010 09:04:05 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id oBV93jCl013667 for ; Fri, 31 Dec 2010 09:03:45 GMT Message-ID: <32590445.79931293786225413.JavaMail.jira@thor> Date: Fri, 31 Dec 2010 04:03:45 -0500 (EST) From: "Claus Ibsen (JIRA)" To: camel-dev@activemq.apache.org Subject: [jira] Updated: (CAMEL-3473) register several cacheEnpoint with different name In-Reply-To: <32373170.58801293633225144.JavaMail.jira@thor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CAMEL-3473?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Claus Ibsen updated CAMEL-3473: ------------------------------- Priority: Minor (was: Major) Fix Version/s: 2.6.0 > register several cacheEnpoint with different name > ------------------------------------------------- > > Key: CAMEL-3473 > URL: https://issues.apache.org/jira/browse/CAMEL-3473 > Project: Camel > Issue Type: Bug > Affects Versions: 2.5.0 > Reporter: skydjol > Priority: Minor > Fix For: 2.6.0 > > > When you declare in camel context > > > > CamelCacheProducer produce systematically in same cache because in CacheComponent, CacheConfiguration is modified by method createEndpoint > {code:title=CamelCacheProducer.java|borderStyle=solid} > public void process(Exchange exchange) throws Exception { > if (LOG.isTraceEnabled()) { > LOG.trace("Cache Name: " + config.getCacheName()); > } > if (cacheManager.cacheExists(config.getCacheName())) { > if (LOG.isTraceEnabled()) { > LOG.trace("Found an existing cache: " + config.getCacheName()); > LOG.trace("Cache " + config.getCacheName() + " currently contains " > + cacheManager.getCache(config.getCacheName()).getSize() + " elements"); > } > cache = cacheManager.getCache(config.getCacheName()); > } else { > cache = new Cache(config.getCacheName(), > config.getMaxElementsInMemory(), > config.getMemoryStoreEvictionPolicy(), > config.isOverflowToDisk(), > config.getDiskStorePath(), > config.isEternal(), > config.getTimeToLiveSeconds(), > config.getTimeToIdleSeconds(), > config.isDiskPersistent(), > config.getDiskExpiryThreadIntervalSeconds(), > null); > cacheManager.addCache(cache); > if (LOG.isDebugEnabled()) { > LOG.debug("Added a new cache: " + cache.getName()); > } > } > String key = exchange.getIn().getHeader(CacheConstants.CACHE_KEY, String.class); > String operation = exchange.getIn().getHeader(CacheConstants.CACHE_OPERATION, String.class); > if (operation == null) { > throw new CacheException("Operation not specified in the message header [" + CacheConstants.CACHE_KEY + "]"); > } > if ((key == null) && (!operation.equalsIgnoreCase(CacheConstants.CACHE_OPERATION_DELETEALL))) { > throw new CacheException("Cache Key is not specified in message header header or endpoint URL."); > } > performCacheOperation(exchange, operation, key); > } > {code} > {code:title=CacheComponent.java|borderStyle=solid} > public class CacheComponent extends DefaultComponent { > private CacheConfiguration config; > private CacheManagerFactory cacheManagerFactory = new CacheManagerFactory(); > > public CacheComponent() { > config = new CacheConfiguration(); > } > public CacheComponent(CamelContext context) { > super(context); > config = new CacheConfiguration(); > } > @Override > @SuppressWarnings("unchecked") > protected Endpoint createEndpoint(String uri, String remaining, Map parameters) throws Exception { > config.parseURI(new URI(uri)); > > CacheEndpoint cacheEndpoint = new CacheEndpoint(uri, this, config, cacheManagerFactory); > setProperties(cacheEndpoint.getConfig(), parameters); > return cacheEndpoint; > } > public CacheManagerFactory getCacheManagerFactory() { > return cacheManagerFactory; > } > public void setCacheManagerFactory(CacheManagerFactory cacheManagerFactory) { > this.cacheManagerFactory = cacheManagerFactory; > } > @Override > protected void doStart() throws Exception { > super.doStart(); > ServiceHelper.startService(cacheManagerFactory); > } > @Override > protected void doStop() throws Exception { > ServiceHelper.stopService(cacheManagerFactory); > super.doStop(); > } > } > {code} > The resolution could be in CacheComponent > {code:title=CacheComponent.java|borderStyle=solid} > @Override > @SuppressWarnings("unchecked") > protected Endpoint createEndpoint(String uri, String remaining, Map parameters) throws Exception { > CacheConfiguration config = new CacheConfiguration(); > config.parseURI(new URI(uri)); > > CacheEndpoint cacheEndpoint = new CacheEndpoint(uri, this, config, cacheManagerFactory); > setProperties(cacheEndpoint.getConfig(), parameters); > return cacheEndpoint; > } > {code} -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.