Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
src Made SessionData an interface, and introduced DefaultSessionData (#465) Oct 9, 2018
README.md
pom.xml

README.md

Pippo Session Hazelcast

Hazelcast Session Manager integration for Pippo

Sample code

First we must create the Hanzelcast configuration file: src/main/resources/hazelcast.xml.

<?xml version="1.0" encoding="UTF-8"?>
<hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config
    http://www.hazelcast.com/schema/config/hazelcast-config-3.0.xsd"
           xmlns="http://www.hazelcast.com/schema/config"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <properties>
        <property name="hazelcast.logging.type">slf4j</property>
    </properties>
    
    <!-- time-to-live-seconds = 300 seconds = 5 minutes -->
    <map name="session">
        <time-to-live-seconds>300</time-to-live-seconds>
        <max-idle-seconds>0</max-idle-seconds>
        <eviction-policy>LRU</eviction-policy>
    </map>

</hazelcast>

Add the following code sniped in your application:

public class MyApplication extends Application {

    private HazelcastInstance instance;

    @Override
    protected void onInit() {
        this.instance = Hazelcast.newHazelcastInstance();
        // add routes here
    }

    @Override
    protected RequestResponseFactory createRequestResponseFactory() {
        SessionDataStorage sessionDataStorage = new HazelcastSessionDataStorage(this.instance);
        SessionManager sessionManager = new SessionManager(sessionDataStorage);

        return new SessionRequestResponseFactory(this, sessionManager);
    }

    @Override
    protected void onDestroy() {
        this.instance.shutdown();
    }

}

Map Options

For more map options to configure the session, you can consult Hazelcast