You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@abdera.apache.org by jm...@apache.org on 2006/07/19 02:33:59 UTC

svn commit: r423309 - in /incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server: ./ cache/ exceptions/ servlet/

Author: jmsnell
Date: Tue Jul 18 17:33:59 2006
New Revision: 423309

URL: http://svn.apache.org/viewvc?rev=423309&view=rev
Log:
Sets up a Cache interface for server side caching.  This will be used by
an abstract CachingRequestHandler impl that I'm working on.  This is a 
work in progress.

Added:
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/cache/
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/cache/Cache.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/cache/CacheEntry.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/cache/CacheFactory.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/cache/CachePolicy.java   (contents, props changed)
      - copied, changed from r422904, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/CachePolicy.java
Removed:
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/CachePolicy.java
Modified:
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/ResponseContext.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/exceptions/AbderaServerException.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/servlet/AbderaServlet.java

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/ResponseContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/ResponseContext.java?rev=423309&r1=423308&r2=423309&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/ResponseContext.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/ResponseContext.java Tue Jul 18 17:33:59 2006
@@ -26,6 +26,8 @@
 
 import javax.activation.MimeType;
 
+import org.apache.abdera.server.cache.CachePolicy;
+
 public interface ResponseContext {
 
   public int getStatus();

Added: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/cache/Cache.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/cache/Cache.java?rev=423309&view=auto
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/cache/Cache.java (added)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/cache/Cache.java Tue Jul 18 17:33:59 2006
@@ -0,0 +1,72 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  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.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.server.cache;
+
+import org.apache.abdera.server.RequestContext;
+import org.apache.abdera.server.ResponseContext;
+
+/**
+ * Provides an interface for a server-side cache, out of which responses can
+ * be served rather than always going back to the RequestHandler.
+ */
+public interface Cache {
+  
+  /**
+   * Initialize the cache
+   */
+  void initialize();
+  
+  /**
+   * Clear the cache
+   */
+  void clear();
+  
+  /**
+   * Clear the specified entry from the cache
+   */
+  void clear(String cacheKey);
+  
+  /**
+   * Retrieve a cache entry, or null 
+   */
+  CacheEntry get(String cacheKey);
+  
+  /**
+   * Set a cache entry
+   */
+  void set(String cacheKey, CacheEntry entry);
+  
+  /**
+   * Returns the current disposition for the cache entry
+   */
+  CacheEntry.CacheDisposition getDisposition(String cacheKey);
+  
+  /**
+   * Process the request from the cache.  The method will return either
+   * FRESH, STALE or TRANSPARENT.  A response of FRESH indicates that the
+   * cache was able to successfully handle the request.  STALE means that 
+   * the Cache Entry for the request should not be used.  TRANSPARENT means
+   * that the Cache Entry either does not exist or that the cache cannot
+   * process the request for a variety of reasons
+   */
+  CacheEntry.CacheDisposition process(
+    RequestContext request, 
+    ResponseContext response, 
+    String cacheKey);
+  
+}

Added: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/cache/CacheEntry.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/cache/CacheEntry.java?rev=423309&view=auto
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/cache/CacheEntry.java (added)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/cache/CacheEntry.java Tue Jul 18 17:33:59 2006
@@ -0,0 +1,35 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  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.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.server.cache;
+
+import org.apache.abdera.server.ResponseContext;
+
+public interface CacheEntry extends ResponseContext {
+
+  public static enum CacheDisposition {
+    STALE,        // the cache entry is stale and should not be used
+    FRESH,        // the cache entry is fresh and usable
+    TRANSPARENT   // the cache entry either does not exist, or the request should not be processed by the cache
+  }
+  
+  /**
+   * Returns the current disposition of this cache entry
+   */
+  CacheDisposition getDisposition();
+  
+}

Added: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/cache/CacheFactory.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/cache/CacheFactory.java?rev=423309&view=auto
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/cache/CacheFactory.java (added)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/cache/CacheFactory.java Tue Jul 18 17:33:59 2006
@@ -0,0 +1,28 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  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.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.server.cache;
+
+public interface CacheFactory {
+
+  public static final CacheFactory INSTANCE = null;
+  
+  Cache newCache();
+
+  Cache newCache(CachePolicy defaultPolicy);
+  
+}

Copied: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/cache/CachePolicy.java (from r422904, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/CachePolicy.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/cache/CachePolicy.java?p2=incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/cache/CachePolicy.java&p1=incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/CachePolicy.java&r1=422904&r2=423309&rev=423309&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/CachePolicy.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/cache/CachePolicy.java Tue Jul 18 17:33:59 2006
@@ -15,7 +15,7 @@
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */
-package org.apache.abdera.server;
+package org.apache.abdera.server.cache;
 
 import java.util.Date;
 

Propchange: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/cache/CachePolicy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/cache/CachePolicy.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/cache/CachePolicy.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/exceptions/AbderaServerException.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/exceptions/AbderaServerException.java?rev=423309&r1=423308&r2=423309&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/exceptions/AbderaServerException.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/exceptions/AbderaServerException.java Tue Jul 18 17:33:59 2006
@@ -28,8 +28,8 @@
 
 import javax.activation.MimeType;
 
-import org.apache.abdera.server.CachePolicy;
 import org.apache.abdera.server.ResponseContext;
+import org.apache.abdera.server.cache.CachePolicy;
 
 @SuppressWarnings("serial")
 public class AbderaServerException 

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/servlet/AbderaServlet.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/servlet/AbderaServlet.java?rev=423309&r1=423308&r2=423309&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/servlet/AbderaServlet.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/servlet/AbderaServlet.java Tue Jul 18 17:33:59 2006
@@ -26,11 +26,11 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.abdera.server.CachePolicy;
 import org.apache.abdera.server.RequestContext;
 import org.apache.abdera.server.RequestHandler;
 import org.apache.abdera.server.RequestHandlerFactory;
 import org.apache.abdera.server.ResponseContext;
+import org.apache.abdera.server.cache.CachePolicy;
 import org.apache.abdera.server.exceptions.AbderaServerException;
 import org.apache.abdera.server.exceptions.MethodNotAllowedException;