Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
**Note: This version may not work with versions of Jetty older than 9**
**Note: This version may not work with versions of Jetty older than 9.2**

# Jetty session clustering with REDIS

* [REDIS website](http://redis.io/) (tested on version 2.2.1)
* [JEDIS website](https://github.com/xetorthio/jedis) (tested on version 2.6.0)
* [Jetty website](http://www.eclipse.org/jetty/) (tested on version 9.2.3.v20140905)
* [Jetty website](http://www.eclipse.org/jetty/) (tested on version 9.2.10.v20150310)

## Build instruction:

Expand Down
69 changes: 52 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>

<artifactId>jetty-session-redis</artifactId>
<version>3.0.ga-SNAPSHOT</version>
<version>3.1.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>jetty-session-redis</name>
Expand All @@ -20,25 +20,35 @@
<developerConnection>scm:git:git@github.com:jcern/${project.name}.git</developerConnection>
<url>http://github.com/jcern/${project.name}</url>
</scm>
<properties>
<jetty.version>9.2.10.v20150310</jetty.version>

<jedis.version>2.6.1</jedis.version>
<jackson.version>2.4.3</jackson.version>
<junit.version>4.11</junit.version>
<slf4j.version>1.7.5</slf4j.version>
<logback.version>1.1.2</logback.version>
<logback-extensions.version>0.1.2</logback-extensions.version>
</properties>

<dependencies>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.6.0</version>
<version>${jedis.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.eclipse.jetty.aggregate</groupId>
<artifactId>jetty-all</artifactId>
<version>9.2.3.v20140905</version>
<version>${jetty.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-nosql</artifactId>
<version>9.2.3.v20140905</version>
<version>${jetty.version}</version>
</dependency>

<!-- jetty classes + runner + jsp stack -->
Expand All @@ -56,18 +66,39 @@
</dependency>

<!-- serialization in json -->

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>

<!--
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.0</version>
<version>${jackson.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.0</version>
<version>${jackson.version}</version>
<optional>true</optional>
</dependency>
-->

<!-- serialization in xstream -->
<dependency>
Expand All @@ -89,28 +120,31 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>

<!-- logging -->

<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
<scope>test</scope>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
<scope>test</scope>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
<scope>test</scope>
<artifactId>jul-to-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
</dependencies>

Expand All @@ -130,6 +164,7 @@
<exclude>**/logging.properties</exclude>
<exclude>**/*.js</exclude>
<exclude>**/*.swf</exclude>
<exclude>.idea/**</exclude>
</excludes>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,14 @@ public void execute() throws JedisException {
});
}
});
for (int i = 0; i < status.size(); i++)
if (ZERO.equals(status.get(i)))
for (int i = 0; i < status.size(); i++) {
if (status.get(i).equals(false)) {
expired.add(clusterIds.get(i));
if (LOG.isDebugEnabled() && !expired.isEmpty())
}
}
if (LOG.isDebugEnabled()) {
LOG.debug("[RedisSessionIdManager] Scavenger found {} sessions to expire: {}", expired.size(), expired);
}
return expired;
}

Expand Down
47 changes: 21 additions & 26 deletions src/main/java/com/ovea/jetty/session/serializer/JsonSerializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,13 @@
*/
package com.ovea.jetty.session.serializer;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.introspect.VisibilityChecker;
import com.ovea.jetty.session.SerializerException;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializationConfig;
import org.codehaus.jackson.map.introspect.AnnotatedField;
import org.codehaus.jackson.map.introspect.JacksonAnnotationIntrospector;
import org.codehaus.jackson.map.introspect.VisibilityChecker;

import java.io.IOException;

import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.ANY;

/**
* @author Mathieu Carbou (mathieu.carbou@gmail.com)
Expand All @@ -38,26 +34,25 @@ public final class JsonSerializer extends SerializerSkeleton {
public void start() {
mapper = new ObjectMapper();

mapper.configure(SerializationConfig.Feature.WRAP_ROOT_VALUE, false);
mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, false);
mapper.configure(SerializationConfig.Feature.AUTO_DETECT_GETTERS, false);
mapper.configure(SerializationConfig.Feature.AUTO_DETECT_IS_GETTERS, false);
mapper.configure(SerializationConfig.Feature.AUTO_DETECT_FIELDS, true);
mapper.configure(SerializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS, true);
mapper.configure(SerializationConfig.Feature.USE_STATIC_TYPING, false);
mapper.configure(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING, false);
mapper.configure(SerializationConfig.Feature.SORT_PROPERTIES_ALPHABETICALLY, true);
mapper.configure(SerializationConfig.Feature.USE_ANNOTATIONS, true);
mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
mapper.configure(SerializationFeature.INDENT_OUTPUT, false);
// mapper.configure(SerializationFeature.AUTO_DETECT_GETTERS, false);
// mapper.configure(SerializationFeature.AUTO_DETECT_IS_GETTERS, false);
// mapper.configure(SerializationFeature.AUTO_DETECT_FIELDS, true);
// mapper.configure(SerializationFeature.CAN_OVERRIDE_ACCESS_MODIFIERS, true);
// mapper.configure(SerializationFeature.USE_STATIC_TYPING, false);
mapper.configure(SerializationFeature.WRITE_ENUMS_USING_TO_STRING, false);
// mapper.configure(SerializationFeature.SORT_PROPERTIES_ALPHABETICALLY, true);
// mapper.configure(SerializationFeature.USE_ANNOTATIONS, true);
// mapper.configure(DeserializationFeature.USE_ANNOTATIONS, true);
// mapper.configure(DeserializationFeature.AUTO_DETECT_SETTERS, false);
// mapper.configure(DeserializationFeature.AUTO_DETECT_CREATORS, true);
// mapper.configure(DeserializationFeature.AUTO_DETECT_FIELDS, true);
// mapper.configure(DeserializationFeature.USE_GETTERS_AS_SETTERS, false);
// mapper.configure(DeserializationFeature.CAN_OVERRIDE_ACCESS_MODIFIERS, true);
mapper.configure(DeserializationFeature.READ_ENUMS_USING_TO_STRING, true);

mapper.configure(DeserializationConfig.Feature.USE_ANNOTATIONS, true);
mapper.configure(DeserializationConfig.Feature.AUTO_DETECT_SETTERS, false);
mapper.configure(DeserializationConfig.Feature.AUTO_DETECT_CREATORS, true);
mapper.configure(DeserializationConfig.Feature.AUTO_DETECT_FIELDS, true);
mapper.configure(DeserializationConfig.Feature.USE_GETTERS_AS_SETTERS, false);
mapper.configure(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS, true);
mapper.configure(DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING, true);

mapper.setVisibilityChecker(new VisibilityChecker.Std(ANY, ANY, ANY, ANY, ANY));
mapper.setVisibilityChecker(new VisibilityChecker.Std(JsonAutoDetect.Visibility.ANY, JsonAutoDetect.Visibility.ANY, JsonAutoDetect.Visibility.ANY, JsonAutoDetect.Visibility.ANY, JsonAutoDetect.Visibility.ANY));

super.start();
}
Expand Down