You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2011/01/30 12:09:51 UTC

svn commit: r1065248 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache: MapQueryCacheFactory.java OSQueryCacheFactory.java QueryCacheFactory.java

Author: aadamchik
Date: Sun Jan 30 11:09:51 2011
New Revision: 1065248

URL: http://svn.apache.org/viewvc?rev=1065248&view=rev
Log:
CAY-1445 Initialize QueryCache via dependency injection

* restoring deleted QueryCache* interfaces with appropriate deprecation notes to smooth the transition
  for our users

Added:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/MapQueryCacheFactory.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/OSQueryCacheFactory.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/QueryCacheFactory.java

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/MapQueryCacheFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/MapQueryCacheFactory.java?rev=1065248&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/MapQueryCacheFactory.java (added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/MapQueryCacheFactory.java Sun Jan 30 11:09:51 2011
@@ -0,0 +1,47 @@
+/*****************************************************************
+ *   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.cayenne.cache;
+
+import java.util.Map;
+
+/**
+ * @since 3.0
+ * @deprecated since 3.1 MapQueryCacheFactory and QueryCacheFactory are unused. Analog of
+ *             MapQueryCacheFactory is DI-friendly {@link MapQueryCacheProvider}.
+ */
+public class MapQueryCacheFactory implements QueryCacheFactory {
+
+    public static final String CACHE_SIZE_PROPERTY = "cayenne.MapQueryCacheFactory.cacheSize";
+
+    public QueryCache getQueryCache(Map<String, String> properties) {
+        if (properties != null) {
+            String size = properties.get(CACHE_SIZE_PROPERTY);
+            if (size != null) {
+                try {
+                    return new MapQueryCache(Integer.parseInt(size));
+                }
+                catch (NumberFormatException e) {
+                    // ignore
+                }
+            }
+        }
+
+        return new MapQueryCache();
+    }
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/OSQueryCacheFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/OSQueryCacheFactory.java?rev=1065248&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/OSQueryCacheFactory.java (added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/OSQueryCacheFactory.java Sun Jan 30 11:09:51 2011
@@ -0,0 +1,40 @@
+/*****************************************************************
+ *   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.cayenne.cache;
+
+import java.util.Map;
+
+/**
+ * A factory for the OSCache factory. "/oscache.properties" file is read to load the
+ * standard OSCache properties and also extra properties
+ * 
+ * @since 3.0
+ * @deprecated since 3.1 OSQueryCacheFactory and QueryCacheFactory are unused. Analog of
+ *             OSQueryCacheFactory is DI-friendly {@link OSQueryCacheProvider}.
+ */
+public class OSQueryCacheFactory implements QueryCacheFactory {
+
+    /**
+     * Creates QueryCache, ignoring provided properties, and reading data from
+     * "oscache.properties" file instead.
+     */
+    public QueryCache getQueryCache(Map<String, String> properties) {
+        return new OSQueryCache();
+    }
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/QueryCacheFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/QueryCacheFactory.java?rev=1065248&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/QueryCacheFactory.java (added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/QueryCacheFactory.java Sun Jan 30 11:09:51 2011
@@ -0,0 +1,38 @@
+/*****************************************************************
+ *   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.cayenne.cache;
+
+import java.util.Map;
+
+import org.apache.cayenne.di.Provider;
+
+/**
+ * Creates QueryCache.
+ * 
+ * @since 3.0
+ * @deprecated since 3.1 QueryCacheFactory is unused and replaced by corresponding
+ *             {@link Provider} implementation for various types of QueryCache.
+ */
+public interface QueryCacheFactory {
+
+    /**
+     * Creates a new instance of the QueryCache, configuring it using provided properties.
+     */
+    QueryCache getQueryCache(Map<String, String> properties);
+}