You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2011/12/21 03:23:21 UTC

svn commit: r1221566 - in /camel/trunk/components/camel-cache/src: main/java/org/apache/camel/component/cache/FileCacheManagerFactory.java test/java/org/apache/camel/component/cache/FileCacheManagerFactoyRefTest.java

Author: ningjiang
Date: Wed Dec 21 02:23:21 2011
New Revision: 1221566

URL: http://svn.apache.org/viewvc?rev=1221566&view=rev
Log:
CAMEL-4805 Added a FileCacheManagerFactory for user to use

Added:
    camel/trunk/components/camel-cache/src/main/java/org/apache/camel/component/cache/FileCacheManagerFactory.java   (with props)
    camel/trunk/components/camel-cache/src/test/java/org/apache/camel/component/cache/FileCacheManagerFactoyRefTest.java   (with props)

Added: camel/trunk/components/camel-cache/src/main/java/org/apache/camel/component/cache/FileCacheManagerFactory.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cache/src/main/java/org/apache/camel/component/cache/FileCacheManagerFactory.java?rev=1221566&view=auto
==============================================================================
--- camel/trunk/components/camel-cache/src/main/java/org/apache/camel/component/cache/FileCacheManagerFactory.java (added)
+++ camel/trunk/components/camel-cache/src/main/java/org/apache/camel/component/cache/FileCacheManagerFactory.java Wed Dec 21 02:23:21 2011
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cache;
+
+import java.io.FileInputStream;
+
+import net.sf.ehcache.CacheManager;
+
+import org.apache.camel.RuntimeCamelException;
+
+public class FileCacheManagerFactory extends CacheManagerFactory {
+    private String fileName;
+    
+    public FileCacheManagerFactory(String name) {
+        fileName = name;
+    }
+    
+    public void setFileName(String name) {
+        fileName = name;
+    }
+    
+    @Override
+    protected CacheManager createCacheManagerInstance() {
+        try {
+            return CacheManager.create(new FileInputStream(fileName));
+        } catch (Exception exception) {
+            throw new RuntimeCamelException(exception);
+        }
+    }
+
+}

Propchange: camel/trunk/components/camel-cache/src/main/java/org/apache/camel/component/cache/FileCacheManagerFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-cache/src/main/java/org/apache/camel/component/cache/FileCacheManagerFactory.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-cache/src/test/java/org/apache/camel/component/cache/FileCacheManagerFactoyRefTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cache/src/test/java/org/apache/camel/component/cache/FileCacheManagerFactoyRefTest.java?rev=1221566&view=auto
==============================================================================
--- camel/trunk/components/camel-cache/src/test/java/org/apache/camel/component/cache/FileCacheManagerFactoyRefTest.java (added)
+++ camel/trunk/components/camel-cache/src/test/java/org/apache/camel/component/cache/FileCacheManagerFactoyRefTest.java Wed Dec 21 02:23:21 2011
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cache;
+
+import org.apache.camel.component.cache.CacheManagerFactoryRefTest.TestingCacheManagerFactory;
+import org.apache.camel.impl.JndiRegistry;
+
+public class FileCacheManagerFactoyRefTest extends CacheManagerFactoryRefTest {
+    
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry jndi = new JndiRegistry(createJndiContext());
+        testingCacheManagerFactory = new FileCacheManagerFactory("src/main/resources/ehcache.xml");
+        jndi.bind("testCacheManagerFactory", testingCacheManagerFactory);
+        return jndi;
+    }
+
+}

Propchange: camel/trunk/components/camel-cache/src/test/java/org/apache/camel/component/cache/FileCacheManagerFactoyRefTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-cache/src/test/java/org/apache/camel/component/cache/FileCacheManagerFactoyRefTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date