You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directmemory.apache.org by ol...@apache.org on 2012/02/22 23:07:01 UTC
svn commit: r1292537 - in
/incubator/directmemory/trunk/server/directmemory-server/src:
main/java/org/apache/directmemory/server/services/
test/java/org/apache/directmemory/server/services/
Author: olamy
Date: Wed Feb 22 22:07:00 2012
New Revision: 1292537
URL: http://svn.apache.org/viewvc?rev=1292537&view=rev
Log:
oups I missed some add
Added:
incubator/directmemory/trunk/server/directmemory-server/src/main/java/org/apache/directmemory/server/services/CacheServletConstants.java (with props)
incubator/directmemory/trunk/server/directmemory-server/src/main/java/org/apache/directmemory/server/services/JavaSerializedCacheContentTypeHandler.java (with props)
incubator/directmemory/trunk/server/directmemory-server/src/test/java/org/apache/directmemory/server/services/ServletWithClientBinaryTypeTest.java (with props)
Added: incubator/directmemory/trunk/server/directmemory-server/src/main/java/org/apache/directmemory/server/services/CacheServletConstants.java
URL: http://svn.apache.org/viewvc/incubator/directmemory/trunk/server/directmemory-server/src/main/java/org/apache/directmemory/server/services/CacheServletConstants.java?rev=1292537&view=auto
==============================================================================
--- incubator/directmemory/trunk/server/directmemory-server/src/main/java/org/apache/directmemory/server/services/CacheServletConstants.java (added)
+++ incubator/directmemory/trunk/server/directmemory-server/src/main/java/org/apache/directmemory/server/services/CacheServletConstants.java Wed Feb 22 22:07:00 2012
@@ -0,0 +1,37 @@
+package org.apache.directmemory.server.services;
+/*
+ * 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.
+ */
+
+/**
+ * @author Olivier Lamy
+ */
+public class CacheServletConstants
+{
+ public static final String JAVA_SERIALIZED_OBJECT_CONTENT_TYPE_HEADER = "application/x-java-serialized-object";
+
+ public static final String SERIALIZER_HTTP_HEADER = "X-DirectMemory-Serializer";
+
+ public static final String EXPIRES_IN_HTTP_HEADER = "X-DirectMemory-ExpiresIn";
+
+
+ private CacheServletConstants()
+ {
+ // no op only a constants class
+ }
+}
Propchange: incubator/directmemory/trunk/server/directmemory-server/src/main/java/org/apache/directmemory/server/services/CacheServletConstants.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/directmemory/trunk/server/directmemory-server/src/main/java/org/apache/directmemory/server/services/CacheServletConstants.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: incubator/directmemory/trunk/server/directmemory-server/src/main/java/org/apache/directmemory/server/services/JavaSerializedCacheContentTypeHandler.java
URL: http://svn.apache.org/viewvc/incubator/directmemory/trunk/server/directmemory-server/src/main/java/org/apache/directmemory/server/services/JavaSerializedCacheContentTypeHandler.java?rev=1292537&view=auto
==============================================================================
--- incubator/directmemory/trunk/server/directmemory-server/src/main/java/org/apache/directmemory/server/services/JavaSerializedCacheContentTypeHandler.java (added)
+++ incubator/directmemory/trunk/server/directmemory-server/src/main/java/org/apache/directmemory/server/services/JavaSerializedCacheContentTypeHandler.java Wed Feb 22 22:07:00 2012
@@ -0,0 +1,58 @@
+package org.apache.directmemory.server.services;
+/*
+ * 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.
+ */
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.directmemory.server.commons.DirectMemoryCacheException;
+import org.apache.directmemory.server.commons.DirectMemoryCacheRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @author Olivier Lamy
+ */
+public class JavaSerializedCacheContentTypeHandler
+ implements CacheContentTypeHandler
+{
+ private Logger log = LoggerFactory.getLogger( getClass() );
+
+ @Override
+ public byte[] handleGet( DirectMemoryCacheRequest request, byte[] cacheResponseContent, HttpServletResponse resp )
+ throws DirectMemoryCacheException, IOException
+ {
+ resp.setContentType( CacheServletConstants.JAVA_SERIALIZED_OBJECT_CONTENT_TYPE_HEADER );
+ return cacheResponseContent;
+ }
+
+ @Override
+ public DirectMemoryCacheRequest handlePut( HttpServletRequest request, HttpServletResponse response )
+ throws DirectMemoryCacheException, IOException
+ {
+ String expiresInHeader = request.getHeader( CacheServletConstants.EXPIRES_IN_HTTP_HEADER );
+ int expiresIn = StringUtils.isEmpty( expiresInHeader ) ? 0 : Integer.valueOf( expiresInHeader );
+ log.debug( "expiresIn: {} for header value: {}", expiresIn, expiresInHeader );
+ return new DirectMemoryCacheRequest().setExpiresIn( expiresIn ).setCacheContent(
+ IOUtils.toByteArray( request.getInputStream() ) );
+ }
+}
Propchange: incubator/directmemory/trunk/server/directmemory-server/src/main/java/org/apache/directmemory/server/services/JavaSerializedCacheContentTypeHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/directmemory/trunk/server/directmemory-server/src/main/java/org/apache/directmemory/server/services/JavaSerializedCacheContentTypeHandler.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: incubator/directmemory/trunk/server/directmemory-server/src/test/java/org/apache/directmemory/server/services/ServletWithClientBinaryTypeTest.java
URL: http://svn.apache.org/viewvc/incubator/directmemory/trunk/server/directmemory-server/src/test/java/org/apache/directmemory/server/services/ServletWithClientBinaryTypeTest.java?rev=1292537&view=auto
==============================================================================
--- incubator/directmemory/trunk/server/directmemory-server/src/test/java/org/apache/directmemory/server/services/ServletWithClientBinaryTypeTest.java (added)
+++ incubator/directmemory/trunk/server/directmemory-server/src/test/java/org/apache/directmemory/server/services/ServletWithClientBinaryTypeTest.java Wed Feb 22 22:07:00 2012
@@ -0,0 +1,34 @@
+package org.apache.directmemory.server.services;
+/*
+ * 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.
+ */
+
+import org.apache.directmemory.server.commons.ExchangeType;
+
+/**
+ * @author Olivier Lamy
+ */
+public class ServletWithClientBinaryTypeTest
+ extends AbstractServletWithClientTest
+{
+ @Override
+ protected ExchangeType getExchangeType()
+ {
+ return ExchangeType.JAVA_SERIALIZED_OBJECT;
+ }
+}
Propchange: incubator/directmemory/trunk/server/directmemory-server/src/test/java/org/apache/directmemory/server/services/ServletWithClientBinaryTypeTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/directmemory/trunk/server/directmemory-server/src/test/java/org/apache/directmemory/server/services/ServletWithClientBinaryTypeTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision