You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by je...@apache.org on 2015/12/22 22:08:16 UTC

[04/17] incubator-geode git commit: GEODE-14: Initial integration of gemfire-modules subproject

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/Callback.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/Callback.java b/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/Callback.java
new file mode 100644
index 0000000..b1c560d
--- /dev/null
+++ b/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/Callback.java
@@ -0,0 +1,17 @@
+
+package com.gemstone.gemfire.modules.session;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Interface which, when implemented, can be put into a servlet context and 
+ * executed by the servlet.
+ */
+public interface Callback {
+    
+    public void call(HttpServletRequest request, HttpServletResponse response)
+            throws ServletException, IOException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/CommandServlet.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/CommandServlet.java b/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/CommandServlet.java
new file mode 100644
index 0000000..cc2c319
--- /dev/null
+++ b/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/CommandServlet.java
@@ -0,0 +1,81 @@
+/*=========================================================================
+ * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * one or more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+
+package com.gemstone.gemfire.modules.session;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+/**
+ *
+ */
+public class CommandServlet extends HttpServlet {
+
+    private ServletContext context;
+
+    /**
+     * The standard servlet method overridden.
+     * @param request
+     * @param response
+     * @throws IOException 
+     */
+    @Override
+    protected void doGet(HttpServletRequest request,
+            HttpServletResponse response) throws IOException, ServletException {
+
+        QueryCommand cmd = QueryCommand.UNKNOWN;
+        String param = request.getParameter("param");
+        String value = request.getParameter("value");
+        PrintWriter out = response.getWriter();
+
+        String cmdStr = request.getParameter("cmd");
+        if (cmdStr != null) {
+            cmd = QueryCommand.valueOf(cmdStr);
+        }
+
+        HttpSession session;
+
+        switch (cmd) {
+            case SET:
+                session = request.getSession();
+                session.setAttribute(param, value);
+                break;
+            case GET:
+                session = request.getSession();
+                String val = (String) session.getAttribute(param);
+                if (val != null) {
+                    out.write(val);
+                }
+                break;
+            case INVALIDATE:
+                session = request.getSession();
+                session.invalidate();
+                break;
+            case CALLBACK:
+                Callback c = (Callback)context.getAttribute("callback");
+                c.call(request, response);
+                break;
+        }
+    }
+
+    /**
+     * Save a reference to the ServletContext for later use.
+     * @param config 
+     */
+    @Override
+    public void init(ServletConfig config) {
+        this.context = config.getServletContext();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/DualCacheTest.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/DualCacheTest.java b/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/DualCacheTest.java
new file mode 100644
index 0000000..8101a8d
--- /dev/null
+++ b/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/DualCacheTest.java
@@ -0,0 +1,56 @@
+/*=========================================================================
+ * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * one or more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package com.gemstone.gemfire.modules.session;
+
+import junit.framework.TestCase;
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.WebConversation;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+import static junit.framework.Assert.*;
+
+/**
+ *
+ */
+public class DualCacheTest extends TestCase {
+
+    /**
+     * Check that our session persists. The values we pass in as query
+     * params are used to set attributes on the session.
+     */
+    public void testSessionFailover() throws Exception {
+        String key = "value_testSessionFailover";
+        String value = "Foo";
+
+        WebConversation wc = new WebConversation();
+        WebRequest req1 = new GetMethodWebRequest("http://localhost:7890/test");
+        req1.setParameter("cmd", QueryCommand.SET.name());
+        req1.setParameter("param", key);
+        req1.setParameter("value", value);
+        WebResponse response = wc.getResponse(req1);
+        String sessionId = response.getNewCookieValue("JSESSIONID");
+
+        assertNotNull("No apparent session cookie", sessionId);
+
+        WebRequest req2 = new GetMethodWebRequest("http://localhost:7891/test");
+        req2.setHeaderField("Cookie", "JSESSIONID=" + sessionId);
+        req2.setParameter("cmd", QueryCommand.GET.name());
+        req2.setParameter("param", key);
+        response = wc.getResponse(req2);
+        sessionId = response.getNewCookieValue("JSESSIONID");
+
+        assertEquals(value, response.getText());
+        assertTrue("The sessionId does not contain the correct JVM route value",
+                sessionId.contains("JVM-2"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/EmbeddedTomcat.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/EmbeddedTomcat.java b/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/EmbeddedTomcat.java
new file mode 100644
index 0000000..d3e37c0
--- /dev/null
+++ b/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/EmbeddedTomcat.java
@@ -0,0 +1,184 @@
+/*=========================================================================
+ * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * one or more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+package com.gemstone.gemfire.modules.session;
+
+import com.gemstone.gemfire.modules.session.catalina.JvmRouteBinderValve;
+import java.io.File;
+import java.net.InetAddress;
+import java.net.MalformedURLException;
+import javax.servlet.ServletException;
+import org.apache.catalina.Context;
+import org.apache.catalina.Engine;
+import org.apache.catalina.Host;
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.Valve;
+import org.apache.catalina.connector.Connector;
+import org.apache.catalina.core.StandardEngine;
+import org.apache.catalina.core.StandardService;
+import org.apache.catalina.core.StandardWrapper;
+import org.apache.catalina.loader.WebappLoader;
+import org.apache.catalina.realm.MemoryRealm;
+import org.apache.catalina.startup.Embedded;
+import org.apache.catalina.valves.ValveBase;
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+
+/**
+ *
+ */
+public class EmbeddedTomcat {
+
+    private String contextPath = null;
+    private Embedded container = null;
+    private Log logger = LogFactory.getLog(getClass());
+    
+    /**
+     * The directory to create the Tomcat server configuration under.
+     */
+    private String catalinaHome = "tomcat";
+    
+    /**
+     * The port to run the Tomcat server on.
+     */
+    private int port = 8089;
+    
+    /**
+     * The classes directory for the web application being run.
+     */
+    private String classesDir = "target/classes";
+
+    private Context rootContext = null;
+
+    private Engine engine;
+    
+    /**
+     * The web resources directory for the web application being run.
+     */
+    private String webappDir = "";
+
+    public EmbeddedTomcat(String contextPath, int port, String jvmRoute) 
+            throws MalformedURLException {
+        this.contextPath = contextPath;
+        this.port = port;
+        
+        // create server
+        container = new Embedded();
+        container.setCatalinaHome(catalinaHome);
+        // Not really necessasry, but let's still do it...
+        container.setRealm(new MemoryRealm());
+        
+        // create webapp loader
+        WebappLoader loader = new WebappLoader(this.getClass().getClassLoader());
+        if (classesDir != null) {
+            loader.addRepository(new File(classesDir).toURI().toURL().toString());
+        }
+        
+        rootContext = container.createContext("", webappDir);
+        rootContext.setLoader(loader);
+        rootContext.setReloadable(true);
+        // Otherwise we get NPE when instantiating servlets
+        rootContext.setIgnoreAnnotations(true);
+
+        // create host
+        Host localHost = container.createHost("127.0.0.1", new File("").getAbsolutePath());
+        localHost.addChild(rootContext);
+
+        localHost.setDeployOnStartup(true);
+        
+        // create engine
+        engine = container.createEngine();
+        engine.setName("localEngine");
+        engine.addChild(localHost);
+        engine.setDefaultHost(localHost.getName());
+        engine.setJvmRoute(jvmRoute);
+        engine.setService(new StandardService());
+        container.addEngine(engine);
+        
+        // create http connector
+        Connector httpConnector = container.createConnector((InetAddress) null, port, false);
+        container.addConnector(httpConnector);
+        container.setAwait(true);
+
+        // Create the JVMRoute valve for session failover
+        ValveBase valve = new JvmRouteBinderValve();
+        ((StandardEngine)engine).addValve(valve);
+    }
+
+    /**
+     * Starts the embedded Tomcat server.
+     */
+    public void startContainer() throws LifecycleException {
+        // start server
+        container.start();
+        
+        // add shutdown hook to stop server
+        Runtime.getRuntime().addShutdownHook(new Thread() {
+            @Override
+            public void run() {
+                stopContainer();
+            }
+        });
+    }
+
+    /**
+     * Stops the embedded Tomcat server.
+     */
+    public void stopContainer() {
+        try {
+            if (container != null) {
+                container.stop();
+                logger.info("Stopped container");
+            }
+        } catch (LifecycleException exception) {
+            logger.warn("Cannot Stop Tomcat" + exception.getMessage());
+        }
+    }
+
+    public StandardWrapper addServlet(String path, String name, String clazz) throws ServletException {
+        StandardWrapper servlet = (StandardWrapper) rootContext.createWrapper();
+        servlet.setName(name);
+        servlet.setServletClass(clazz);
+        servlet.setLoadOnStartup(1);
+
+        rootContext.addChild(servlet);
+        rootContext.addServletMapping(path, name);
+
+        servlet.setParent(rootContext);
+//        servlet.load();
+
+        return servlet;
+    }
+
+    public Embedded getEmbedded() {
+        return container;
+    }
+
+    public Context getRootContext() {
+        return rootContext;
+    }
+
+    public String getPath() {
+        return contextPath;
+    }
+
+    public void setPath(String path) {
+        this.contextPath = path;
+    }
+
+    public int getPort() {
+        return port;
+    }
+
+    public void addValve(Valve valve) {
+        ((StandardEngine) engine).addValve(valve);
+    }
+
+    public void removeValve(Valve valve) {
+        ((StandardEngine) engine).removeValve(valve);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/QueryCommand.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/QueryCommand.java b/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/QueryCommand.java
new file mode 100644
index 0000000..1c68702
--- /dev/null
+++ b/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/QueryCommand.java
@@ -0,0 +1,18 @@
+package com.gemstone.gemfire.modules.session;
+
+/**
+ * Basic commands to pass to our test servlet
+ */
+public enum QueryCommand {
+
+    SET,
+
+    GET,
+
+    INVALIDATE,
+    
+    CALLBACK,
+
+    UNKNOWN;
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/TestSessions.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/TestSessions.java b/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/TestSessions.java
new file mode 100644
index 0000000..b1751b2
--- /dev/null
+++ b/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/TestSessions.java
@@ -0,0 +1,512 @@
+/*=========================================================================
+ * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * one or more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+package com.gemstone.gemfire.modules.session;
+
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.modules.session.catalina.CommitSessionValve;
+import com.gemstone.gemfire.modules.session.catalina.DeltaSessionManager;
+import com.gemstone.gemfire.modules.session.catalina.PeerToPeerCacheLifecycleListener;
+import com.gemstone.gemfire.modules.session.catalina.Tomcat6DeltaSessionManager;
+
+import javax.servlet.http.HttpSession;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.WebConversation;
+import com.meterware.httpunit.WebResponse;
+import org.apache.catalina.Valve;
+import org.apache.catalina.core.StandardWrapper;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.beans.PropertyChangeEvent;
+
+import static junit.framework.Assert.*;
+
+/**
+ *
+ */
+public class TestSessions {
+    private static EmbeddedTomcat server;
+
+    private static Region<String, HttpSession> region;
+
+    private static StandardWrapper servlet;
+
+    private static DeltaSessionManager sessionManager;
+
+    // Set up the servers we need
+    @BeforeClass
+    public static void setupClass() throws Exception {
+        // Create a per-user scratch directory
+        File tmpDir = new File(System.getProperty("java.io.tmpdir"),
+                "gemfire_modules-" + System.getProperty("user.name"));
+        tmpDir.mkdirs();
+        tmpDir.deleteOnExit();
+
+        String gemfireLog = tmpDir.getPath() +
+                System.getProperty("file.separator") + "gemfire_modules.log";
+
+        server = new EmbeddedTomcat("/test", 7890, "JVM-1");
+
+        PeerToPeerCacheLifecycleListener p2pListener = new PeerToPeerCacheLifecycleListener();
+        p2pListener.setProperty("mcast-port", "19991");
+        p2pListener.setProperty("log-level", "config");
+        p2pListener.setProperty("log-file", gemfireLog);
+        p2pListener.setProperty("writable-working-dir", tmpDir.getPath());
+        server.getEmbedded().addLifecycleListener(p2pListener);
+        sessionManager = new Tomcat6DeltaSessionManager();
+        sessionManager.setEnableCommitValve(true);
+        server.getRootContext().setManager(sessionManager);
+
+        servlet = server.addServlet("/test/*", "default", CommandServlet.class.getName());
+        server.startContainer();
+
+        /**
+         * Can only retrieve the region once the container has started up
+         * (and the cache has started too).
+         */
+        region = sessionManager.getSessionCache().getSessionRegion();
+    }
+
+    @AfterClass
+    public static void teardownClass() throws Exception {
+        server.stopContainer();
+    }
+    /**
+     * Reset some data
+     */
+    @Before
+    public void setup() throws Exception {
+        sessionManager.setMaxInactiveInterval(30);
+        region.clear();
+    }
+
+    /**
+     * Check that the basics are working
+     */
+    @Test
+    public void testSanity() throws Exception {
+        WebConversation wc = new WebConversation();
+        WebRequest req = new GetMethodWebRequest("http://localhost:7890/test");
+        req.setParameter("cmd", QueryCommand.GET.name());
+        req.setParameter("param", "null");
+        WebResponse response = wc.getResponse(req);
+
+        assertEquals("JSESSIONID", response.getNewCookieNames()[0]);
+    }
+
+    /**
+     * Test callback functionality. This is here really just as an example.
+     * Callbacks are useful to implement per test actions which can be defined
+     * within the actual test method instead of in a separate servlet class.
+     */
+    @Test
+    public void testCallback() throws Exception {
+        final String helloWorld = "Hello World";
+        Callback c = new Callback() {
+
+            @Override
+            public void call(HttpServletRequest request, HttpServletResponse response)
+                    throws IOException {
+                PrintWriter out = response.getWriter();
+                out.write(helloWorld);
+            }
+        };
+        servlet.getServletContext().setAttribute("callback", c);
+
+        WebConversation wc = new WebConversation();
+        WebRequest req = new GetMethodWebRequest("http://localhost:7890/test");
+
+        req.setParameter("cmd", QueryCommand.CALLBACK.name());
+        req.setParameter("param", "callback");
+        WebResponse response = wc.getResponse(req);
+
+        assertEquals(helloWorld, response.getText());
+    }
+
+    /**
+     * Test that calling session.isNew() works for the initial as well as
+     * subsequent requests.
+     */
+    @Test
+    public void testIsNew() throws Exception {
+        Callback c = new Callback() {
+
+            @Override
+            public void call(HttpServletRequest request, HttpServletResponse response)
+                    throws IOException {
+                HttpSession session = request.getSession();
+                response.getWriter().write(Boolean.toString(session.isNew()));
+            }
+        };
+        servlet.getServletContext().setAttribute("callback", c);
+
+        WebConversation wc = new WebConversation();
+        WebRequest req = new GetMethodWebRequest("http://localhost:7890/test");
+
+        req.setParameter("cmd", QueryCommand.CALLBACK.name());
+        req.setParameter("param", "callback");
+        WebResponse response = wc.getResponse(req);
+
+        assertEquals("true", response.getText());
+        response = wc.getResponse(req);
+
+        assertEquals("false", response.getText());
+    }
+
+    /**
+     * Check that our session persists. The values we pass in as query
+     * params are used to set attributes on the session.
+     */
+    @Test
+    public void testSessionPersists1() throws Exception {
+        String key = "value_testSessionPersists1";
+        String value = "Foo";
+
+        WebConversation wc = new WebConversation();
+        WebRequest req = new GetMethodWebRequest("http://localhost:7890/test");
+        req.setParameter("cmd", QueryCommand.SET.name());
+        req.setParameter("param", key);
+        req.setParameter("value", value);
+        WebResponse response = wc.getResponse(req);
+        String sessionId = response.getNewCookieValue("JSESSIONID");
+
+        assertNotNull("No apparent session cookie", sessionId);
+
+        // The request retains the cookie from the prior response...
+        req.setParameter("cmd", QueryCommand.GET.name());
+        req.setParameter("param", key);
+        req.removeParameter("value");
+        response = wc.getResponse(req);
+
+        assertEquals(value, response.getText());
+    }
+
+    /**
+     * Check that our session persists beyond the container restarting.
+     */
+//    public void testSessionPersists2() throws Exception {
+//        String key = "value_testSessionPersists2";
+//        String value = "Foo";
+//
+//        WebConversation wc = new WebConversation();
+//        WebRequest req = new GetMethodWebRequest("http://localhost:7890/test");
+//        req.setParameter("cmd", QueryCommand.SET.name());
+//        req.setParameter("param", key);
+//        req.setParameter("value", value);
+//        WebResponse response = wc.getResponse(req);
+//        String sessionId = response.getNewCookieValue("JSESSIONID");
+//
+//        assertNotNull("No apparent session cookie", sessionId);
+//
+//        // Restart the container
+//        AllTests.teardownClass();
+//        AllTests.setupClass();
+//
+//        // The request retains the cookie from the prior response...
+//        req.setParameter("cmd", QueryCommand.GET.name());
+//        req.setParameter("param", key);
+//        req.removeParameter("value");
+//        response = wc.getResponse(req);
+//
+//        assertEquals(value, response.getText());
+//    }
+
+    /**
+     * Test that invalidating a session makes it's attributes inaccessible.
+     */
+    @Test
+    public void testInvalidate() throws Exception {
+        String key = "value_testInvalidate";
+        String value = "Foo";
+
+        WebConversation wc = new WebConversation();
+        WebRequest req = new GetMethodWebRequest("http://localhost:7890/test");
+
+        // Set an attribute
+        req.setParameter("cmd", QueryCommand.SET.name());
+        req.setParameter("param", key);
+        req.setParameter("value", value);
+        WebResponse response = wc.getResponse(req);
+
+        // Invalidate the session
+        req.removeParameter("param");
+        req.removeParameter("value");
+        req.setParameter("cmd", QueryCommand.INVALIDATE.name());
+        wc.getResponse(req);
+
+        // The attribute should not be accessible now...
+        req.setParameter("cmd", QueryCommand.GET.name());
+        req.setParameter("param", key);
+        response = wc.getResponse(req);
+
+        assertEquals("", response.getText());
+    }
+
+    /**
+     * Test setting the session expiration
+     */
+    @Test
+    public void testSessionExpiration1() throws Exception {
+        // TestSessions only live for a second
+        sessionManager.setMaxInactiveInterval(1);
+
+        String key = "value_testSessionExpiration1";
+        String value = "Foo";
+
+        WebConversation wc = new WebConversation();
+        WebRequest req = new GetMethodWebRequest("http://localhost:7890/test");
+
+        // Set an attribute
+        req.setParameter("cmd", QueryCommand.SET.name());
+        req.setParameter("param", key);
+        req.setParameter("value", value);
+        WebResponse response = wc.getResponse(req);
+
+        // Sleep a while
+        Thread.sleep(2000);
+
+        // The attribute should not be accessible now...
+        req.setParameter("cmd", QueryCommand.GET.name());
+        req.setParameter("param", key);
+        response = wc.getResponse(req);
+
+        assertEquals("", response.getText());
+    }
+
+    /**
+     * Test setting the session expiration via a property change as would happen
+     * under normal deployment conditions.
+     */
+    @Test
+    public void testSessionExpiration2() throws Exception {
+        // TestSessions only live for a minute
+        sessionManager.propertyChange(
+                new PropertyChangeEvent(server.getRootContext(),
+                        "sessionTimeout",
+                        new Integer(30), new Integer(1)));
+
+        // Check that the value has been set to 60 seconds
+        assertEquals(60, sessionManager.getMaxInactiveInterval());
+    }
+
+    /**
+     * Test that removing a session attribute also removes it from the region
+     */
+    @Test
+    public void testRemoveAttribute() throws Exception {
+        String key = "value_testRemoveAttribute";
+        String value = "Foo";
+
+        WebConversation wc = new WebConversation();
+        WebRequest req = new GetMethodWebRequest("http://localhost:7890/test");
+
+        // Set an attribute
+        req.setParameter("cmd", QueryCommand.SET.name());
+        req.setParameter("param", key);
+        req.setParameter("value", value);
+        WebResponse response = wc.getResponse(req);
+        String sessionId = response.getNewCookieValue("JSESSIONID");
+
+        // Implicitly remove the attribute
+        req.removeParameter("value");
+        wc.getResponse(req);
+
+        // The attribute should not be accessible now...
+        req.setParameter("cmd", QueryCommand.GET.name());
+        req.setParameter("param", key);
+        response = wc.getResponse(req);
+
+        assertEquals("", response.getText());
+        assertNull(region.get(sessionId).getAttribute(key));
+    }
+
+    /**
+     * Test that a session attribute gets set into the region too.
+     */
+    @Test
+    public void testBasicRegion() throws Exception {
+        String key = "value_testBasicRegion";
+        String value = "Foo";
+
+        WebConversation wc = new WebConversation();
+        WebRequest req = new GetMethodWebRequest("http://localhost:7890/test");
+
+        // Set an attribute
+        req.setParameter("cmd", QueryCommand.SET.name());
+        req.setParameter("param", key);
+        req.setParameter("value", value);
+        WebResponse response = wc.getResponse(req);
+        String sessionId = response.getNewCookieValue("JSESSIONID");
+
+        assertEquals(value, region.get(sessionId).getAttribute(key));
+    }
+
+    /**
+     * Test that a session attribute gets removed from the region when the
+     * session is invalidated.
+     */
+    @Test
+    public void testRegionInvalidate() throws Exception {
+        String key = "value_testRegionInvalidate";
+        String value = "Foo";
+
+        WebConversation wc = new WebConversation();
+        WebRequest req = new GetMethodWebRequest("http://localhost:7890/test");
+
+        // Set an attribute
+        req.setParameter("cmd", QueryCommand.SET.name());
+        req.setParameter("param", key);
+        req.setParameter("value", value);
+        WebResponse response = wc.getResponse(req);
+        String sessionId = response.getNewCookieValue("JSESSIONID");
+
+        // Invalidate the session
+        req.removeParameter("param");
+        req.removeParameter("value");
+        req.setParameter("cmd", QueryCommand.INVALIDATE.name());
+        wc.getResponse(req);
+
+        assertNull("The region should not have an entry for this session",
+                region.get(sessionId));
+    }
+
+    /**
+     * Test that multiple attribute updates, within the same request result in
+     * only the latest one being effective.
+     */
+    @Test
+    public void testMultipleAttributeUpdates() throws Exception {
+        final String key = "value_testMultipleAttributeUpdates";
+        Callback c = new Callback() {
+
+            @Override
+            public void call(HttpServletRequest request, HttpServletResponse response)
+                    throws IOException {
+                HttpSession session = request.getSession();
+                for (int i = 0; i < 1000; i++) {
+                    session.setAttribute(key, Integer.toString(i));
+                }
+            }
+        };
+        servlet.getServletContext().setAttribute("callback", c);
+
+        WebConversation wc = new WebConversation();
+        WebRequest req = new GetMethodWebRequest("http://localhost:7890/test");
+
+        // Execute the callback
+        req.setParameter("cmd", QueryCommand.CALLBACK.name());
+        req.setParameter("param", "callback");
+        WebResponse response = wc.getResponse(req);
+
+        String sessionId = response.getNewCookieValue("JSESSIONID");
+
+        assertEquals("999", region.get(sessionId).getAttribute(key));
+    }
+
+    /*
+     * Test for issue #38 CommitSessionValve throws exception on invalidated sessions
+     */
+    @Test
+    public void testCommitSessionValveInvalidSession() throws Exception {
+        Callback c = new Callback() {
+            @Override
+            public void call(HttpServletRequest request, HttpServletResponse response)
+                    throws IOException {
+                HttpSession session = request.getSession();
+                session.invalidate();
+                response.getWriter().write("done");
+            }
+        };
+        servlet.getServletContext().setAttribute("callback", c);
+
+        WebConversation wc = new WebConversation();
+        WebRequest req = new GetMethodWebRequest("http://localhost:7890/test");
+
+        // Execute the callback
+        req.setParameter("cmd", QueryCommand.CALLBACK.name());
+        req.setParameter("param", "callback");
+        WebResponse response = wc.getResponse(req);
+
+        assertEquals("done", response.getText());
+    }
+
+    /**
+     * Test for issue #45 Sessions are being created for every request
+     */
+    @Test
+    public void testExtraSessionsNotCreated() throws Exception {
+      Callback c = new Callback() {
+        @Override
+        public void call(HttpServletRequest request, HttpServletResponse response)
+            throws IOException {
+          // Do nothing with sessions
+          response.getWriter().write("done");
+        }
+      };
+      servlet.getServletContext().setAttribute("callback", c);
+
+      WebConversation wc = new WebConversation();
+      WebRequest req = new GetMethodWebRequest("http://localhost:7890/test");
+
+      // Execute the callback
+      req.setParameter("cmd", QueryCommand.CALLBACK.name());
+      req.setParameter("param", "callback");
+      WebResponse response = wc.getResponse(req);
+
+      assertEquals("done", response.getText());
+      assertEquals("The region should be empty", 0, region.size());
+    }
+
+    /**
+     * Test for issue #46 lastAccessedTime is not updated at the start of the
+     * request, but only at the end.
+     */
+    @Test
+    public void testLastAccessedTime() throws Exception {
+        Callback c = new Callback() {
+            @Override
+            public void call(HttpServletRequest request, HttpServletResponse response)
+                    throws IOException {
+                HttpSession session = request.getSession();
+                // Hack to expose the session to our test context
+                session.getServletContext().setAttribute("session", session);
+                session.setAttribute("lastAccessTime", session.getLastAccessedTime());
+                try {
+                  Thread.sleep(100);
+                } catch (InterruptedException ex) {
+                }
+                session.setAttribute("somethingElse", 1);
+                request.getSession();
+                response.getWriter().write("done");
+            }
+        };
+        servlet.getServletContext().setAttribute("callback", c);
+
+        WebConversation wc = new WebConversation();
+        WebRequest req = new GetMethodWebRequest("http://localhost:7890/test");
+
+        // Execute the callback
+        req.setParameter("cmd", QueryCommand.CALLBACK.name());
+        req.setParameter("param", "callback");
+        WebResponse response = wc.getResponse(req);
+
+        HttpSession session = (HttpSession) servlet.getServletContext().getAttribute("session");
+        Long lastAccess = (Long) session.getAttribute("lastAccessTime");
+
+        assertEquals("Last access time not set correctly", lastAccess.longValue(), session.getLastAccessedTime());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/extensions/gemfire-modules/src/test/resources/com/gemstone/gemfire/modules/Event.hbm.xml
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/test/resources/com/gemstone/gemfire/modules/Event.hbm.xml b/extensions/gemfire-modules/src/test/resources/com/gemstone/gemfire/modules/Event.hbm.xml
new file mode 100644
index 0000000..17faf29
--- /dev/null
+++ b/extensions/gemfire-modules/src/test/resources/com/gemstone/gemfire/modules/Event.hbm.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="com.gemstone.gemfire.modules">
+	<class name="Event" table="EVENTS">
+		<cache usage="read-write"/>
+		<id name="id" column="EVENT_ID">
+			<generator class="native"/>
+		</id>
+		<version name="version"/>
+		<property name="date" type="timestamp" column="EVENT_DATE"/>
+        <property name="title"/>
+	</class>
+</hibernate-mapping>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/extensions/gemfire-modules/src/test/resources/com/gemstone/gemfire/modules/Person.hbm.xml
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/test/resources/com/gemstone/gemfire/modules/Person.hbm.xml b/extensions/gemfire-modules/src/test/resources/com/gemstone/gemfire/modules/Person.hbm.xml
new file mode 100644
index 0000000..c6380e7
--- /dev/null
+++ b/extensions/gemfire-modules/src/test/resources/com/gemstone/gemfire/modules/Person.hbm.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="com.gemstone.gemfire.modules">
+    <class name="Person" table="PERSON">
+        <cache usage="read-write"/>
+        <id name="id" column="PERSON_ID">
+            <generator class="native"/>
+        </id>
+        <property name="age"/>
+        <property name="firstname"/>
+        <property name="lastname"/>
+        <set name="e" table="PERSON_EVENT">
+          <cache usage="read-write"/>
+          <key column="PERSON_ID"/>
+          <many-to-many column="EVENT_ID" class="Event"/>
+        </set>
+    </class>
+</hibernate-mapping>

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/extensions/gemfire-modules/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/test/resources/log4j.properties b/extensions/gemfire-modules/src/test/resources/log4j.properties
new file mode 100644
index 0000000..c136990
--- /dev/null
+++ b/extensions/gemfire-modules/src/test/resources/log4j.properties
@@ -0,0 +1,16 @@
+# For JBoss: Avoid to setup Log4J outside $JBOSS_HOME/server/default/deploy/log4j.xml!
+# For all other servers: Comment out the Log4J listener in web.xml to activate Log4J.
+#log4j.rootLogger=DEBUG, stdout, logfile
+log4j.rootLogger=DEBUG, stdout
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
+
+#log4j.appender.logfile=org.apache.log4j.RollingFileAppender
+#log4j.appender.logfile.MaxFileSize=512KB
+## Keep three backup files.
+#log4j.appender.logfile.MaxBackupIndex=3
+## Pattern to output: date priority [category] - message
+#log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
+#log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/extensions/gemfire-modules/tomcat/conf/tomcat-users.xml
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/tomcat/conf/tomcat-users.xml b/extensions/gemfire-modules/tomcat/conf/tomcat-users.xml
new file mode 100644
index 0000000..6c9f217
--- /dev/null
+++ b/extensions/gemfire-modules/tomcat/conf/tomcat-users.xml
@@ -0,0 +1,3 @@
+<?xml version='1.0' encoding='utf-8'?>
+<tomcat-users>
+</tomcat-users>

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/gradle/dependency-versions.properties
----------------------------------------------------------------------
diff --git a/gradle/dependency-versions.properties b/gradle/dependency-versions.properties
index 3833f54..df052c5 100644
--- a/gradle/dependency-versions.properties
+++ b/gradle/dependency-versions.properties
@@ -59,6 +59,8 @@ JUnitParams.version = 1.0.4
 log4j.version = 2.1
 lucene.version = 5.3.0
 mockito-core.version = 1.10.19
+modules.tomcat.version = 6.0.37
+modules.httpunit.version = 1.7.2
 multithreadedtc.version = 1.01
 mx4j.version = 3.0.1
 mx4j-remote.version = 3.0.1

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/modules/gemfire-modules/build.gradle
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules/build.gradle b/modules/gemfire-modules/build.gradle
deleted file mode 100644
index 5dfc5c4..0000000
--- a/modules/gemfire-modules/build.gradle
+++ /dev/null
@@ -1,11 +0,0 @@
-
-test  {
-  include '**/TestSessions.class'
-  workingDir = "${projectDir}"
-}
-
-dependencies {
-  compile "org.apache.tomcat:catalina:${tomcat_version}"
-  compile "org.apache.tomcat:catalina-ha:${tomcat_version}"
-  testCompile "org.slf4j:slf4j-jdk14:${slf4j_version}"
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/modules/gemfire-modules/pom.xml
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules/pom.xml b/modules/gemfire-modules/pom.xml
deleted file mode 100644
index 55c466e..0000000
--- a/modules/gemfire-modules/pom.xml
+++ /dev/null
@@ -1,118 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-
-  <groupId>com.gemstone</groupId>
-  <artifactId>gemfire-modules</artifactId>
-  <version>${gemfire.modules.version}</version>
-  <packaging>jar</packaging>
-
-  <name>gemfire-modules</name>
-  <url>http://maven.apache.org</url>
-
-  <parent>
-    <groupId>com.gemstone</groupId>
-    <artifactId>gemfire-modules-parent</artifactId>
-    <version>1.0-SNAPSHOT</version>
-  </parent>
-
-  <properties>
-    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-  </properties>
-
-  <dependencies>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-    </dependency>
-    <dependency>
-    	<groupId>org.apache.tomcat</groupId>
-    	<artifactId>catalina</artifactId>
-    </dependency>
-    <dependency>
-    	<groupId>org.apache.tomcat</groupId>
-    	<artifactId>catalina-ha</artifactId>
-        <version>${tomcat.version}</version>
-        <scope>provided</scope>
-    </dependency>
-    <dependency>
-    	<groupId>com.gemstone.gemfire</groupId>
-    	<artifactId>gemfire</artifactId>
-    </dependency>
-    <dependency>
-    	<groupId>org.slf4j</groupId>
-    	<artifactId>slf4j-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-jdk14</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.tomcat</groupId>
-      <artifactId>coyote</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.httpunit</groupId>
-      <artifactId>httpunit</artifactId>
-    </dependency>
-  </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-surefire-plugin</artifactId>
-        <version>2.7.2</version>
-        <configuration>
-          <includes>
-            <!-- This is a suite -->
-            <include>**/TestSessions.java</include>
-          </includes>
-          <runOrder>alphabetical</runOrder>
-        </configuration>
-      </plugin>
-
-      <plugin>
-        <groupId>com.google.code.maven-replacer-plugin</groupId>
-        <artifactId>replacer</artifactId>
-        <version>1.5.1</version>
-        <executions>
-          <execution>
-            <phase>compile</phase>
-            <goals>
-              <goal>replace</goal>
-            </goals>
-          </execution>
-        </executions>
-        <configuration>
-          <includes>
-            <include>target/**/modules-version.properties</include>
-          </includes>
-          <replacements>
-            <replacement>
-              <token>@VERSION@</token>
-              <value>${gemfire.modules.version}</value>
-            </replacement>
-          </replacements>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-
-  <profiles>
-    <profile>
-      <id>s3</id>
-      <build>
-        <plugins>
-          <plugin>
-            <groupId>org.apache.maven.plugins</groupId>
-            <artifactId>maven-deploy-plugin</artifactId>
-            <configuration>
-              <skip>false</skip>
-            </configuration>
-          </plugin>
-        </plugins>
-      </build>
-    </profile>
-  </profiles>
-</project>

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/AbstractGatewayDeltaEvent.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/AbstractGatewayDeltaEvent.java b/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/AbstractGatewayDeltaEvent.java
deleted file mode 100644
index e382174..0000000
--- a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/AbstractGatewayDeltaEvent.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-package com.gemstone.gemfire.modules.gatewaydelta;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-
-import com.gemstone.gemfire.DataSerializable;
-import com.gemstone.gemfire.DataSerializer;
-
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.Region;
-
-@SuppressWarnings("serial")
-public abstract class AbstractGatewayDeltaEvent implements GatewayDeltaEvent, DataSerializable {
-
-  protected String regionName;
-  protected String key;
-
-  public AbstractGatewayDeltaEvent() {
-  }
-
-  public AbstractGatewayDeltaEvent(String regionName, String key) {
-    this.regionName = regionName;
-    this.key = key;
-  }
-  
-  public String getRegionName() {
-    return this.regionName;
-  }
-
-  public String getKey() {
-    return this.key;
-  }
-  
-  @SuppressWarnings("unchecked")
-  public Region getRegion(Cache cache) {
-    return cache.getRegion(this.regionName);
-  }
-
-  public void fromData(DataInput in) throws IOException, ClassNotFoundException {
-    this.regionName = DataSerializer.readString(in);
-    this.key = DataSerializer.readString(in);
-  }
-
-  public void toData(DataOutput out) throws IOException {
-    DataSerializer.writeString(this.regionName, out);
-    DataSerializer.writeString(this.key, out);
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDelta.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDelta.java b/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDelta.java
deleted file mode 100644
index 7c37983..0000000
--- a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDelta.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.gemstone.gemfire.modules.gatewaydelta;
-
-public interface GatewayDelta {
-
-  public static final String GATEWAY_DELTA_REGION_NAME = "__gatewayDelta";
-  
-  public GatewayDeltaEvent getCurrentGatewayDeltaEvent();
- 
-  public void setCurrentGatewayDeltaEvent(GatewayDeltaEvent currentGatewayDeltaEvent);
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaCreateEvent.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaCreateEvent.java b/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaCreateEvent.java
deleted file mode 100644
index ff597da..0000000
--- a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaCreateEvent.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-package com.gemstone.gemfire.modules.gatewaydelta;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-
-import com.gemstone.gemfire.DataSerializable;
-import com.gemstone.gemfire.DataSerializer;
-import com.gemstone.gemfire.Instantiator;
-
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.Region;
-
-import com.gemstone.gemfire.internal.cache.CachedDeserializable;
-import com.gemstone.gemfire.internal.cache.CachedDeserializableFactory;
-
-@SuppressWarnings("serial")
-public class GatewayDeltaCreateEvent extends AbstractGatewayDeltaEvent {
-
-  private byte[] gatewayDelta;
-  
-  public GatewayDeltaCreateEvent() {
-  }
-
-  public GatewayDeltaCreateEvent(String regionName, String key, byte[] gatewayDelta) {
-    super(regionName, key);
-    this.gatewayDelta = gatewayDelta;
-  }
-
-  public byte[] getGatewayDelta() {
-    return this.gatewayDelta;
-  }
-  
-  public void apply(Cache cache) {
-    Region<String,CachedDeserializable> region = getRegion(cache);
-    region.put(this.key, CachedDeserializableFactory.create(this.gatewayDelta), true);
-    if (cache.getLogger().fineEnabled()) {
-      StringBuilder builder = new StringBuilder();
-        builder
-          .append("Applied ")
-          .append(this);
-      cache.getLogger().fine(builder.toString());
-    }
-  }
-
-  public void fromData(DataInput in) throws IOException, ClassNotFoundException {
-    super.fromData(in);
-    this.gatewayDelta = DataSerializer.readByteArray(in);
-  }
-
-  public void toData(DataOutput out) throws IOException {
-    super.toData(out);
-    DataSerializer.writeByteArray(this.gatewayDelta, out);
-  }
-  
-  public static void registerInstantiator(int id) {
-    Instantiator.register(new Instantiator(GatewayDeltaCreateEvent.class, id) {
-      public DataSerializable newInstance() {
-        return new GatewayDeltaCreateEvent();
-      }
-    });
-  }
-  
-  public String toString() {
-    return new StringBuilder()
-      .append("GatewayDeltaCreateEvent[")
-      .append("regionName=")
-      .append(this.regionName)
-      .append("; key=")
-      .append(this.key)
-      .append("; gatewayDelta=")
-      .append(this.gatewayDelta)
-      .append("]")
-      .toString();
-  }
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaDestroyEvent.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaDestroyEvent.java b/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaDestroyEvent.java
deleted file mode 100644
index cf6160c..0000000
--- a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaDestroyEvent.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-package com.gemstone.gemfire.modules.gatewaydelta;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-
-import com.gemstone.gemfire.DataSerializable;
-import com.gemstone.gemfire.Instantiator;
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.EntryNotFoundException;
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.modules.session.catalina.DeltaSession;
-
-@SuppressWarnings("serial")
-public class GatewayDeltaDestroyEvent extends AbstractGatewayDeltaEvent {
-
-  public GatewayDeltaDestroyEvent() {
-  }
-
-  public GatewayDeltaDestroyEvent(String regionName, String key) {
-    super(regionName, key);
-  }
-
-  public void apply(Cache cache) {
-    Region<String,DeltaSession> region = getRegion(cache);
-    try {
-      region.destroy(this.key);
-      if (cache.getLogger().fineEnabled()) {
-        StringBuilder builder = new StringBuilder();
-        builder
-          .append("Applied ")
-          .append(this);
-        cache.getLogger().fine(builder.toString());
-      }
-    } catch (EntryNotFoundException e) {
-      StringBuilder builder = new StringBuilder();
-      builder
-        .append(this)
-        .append(": Session ")
-        .append(this.key)
-        .append(" was not found");
-      cache.getLogger().warning(builder.toString());
-    }
-  }
-
-  public void fromData(DataInput in) throws IOException, ClassNotFoundException {
-    super.fromData(in);
-  }
-
-  public void toData(DataOutput out) throws IOException {
-    super.toData(out);
-  }
-  
-  public static void registerInstantiator(int id) {
-    Instantiator.register(new Instantiator(GatewayDeltaDestroyEvent.class, id) {
-      public DataSerializable newInstance() {
-        return new GatewayDeltaDestroyEvent();
-      }
-    });
-  }
-  
-  public String toString() {
-    return new StringBuilder()
-      .append("GatewayDeltaDestroyEvent[")
-      .append("regionName=")
-      .append(this.regionName)
-      .append("; key=")
-      .append(this.key)
-      .append("]")
-      .toString();
-  }
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaEvent.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaEvent.java b/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaEvent.java
deleted file mode 100644
index c784e66..0000000
--- a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaEvent.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.gemstone.gemfire.modules.gatewaydelta;
-
-import com.gemstone.gemfire.cache.Cache;
-
-public interface GatewayDeltaEvent {
-  
-  public void apply(Cache cache);
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaEventApplicationCacheListener.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaEventApplicationCacheListener.java b/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaEventApplicationCacheListener.java
deleted file mode 100644
index 6c13919..0000000
--- a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaEventApplicationCacheListener.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-package com.gemstone.gemfire.modules.gatewaydelta;
-
-import java.util.Properties;
-
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.CacheFactory;
-import com.gemstone.gemfire.cache.Declarable;
-import com.gemstone.gemfire.cache.EntryEvent;
-import com.gemstone.gemfire.cache.util.CacheListenerAdapter;
-import com.gemstone.gemfire.internal.cache.EntryEventImpl;
-import com.gemstone.gemfire.internal.cache.GatewayEventCallbackArgument;
-
-public class GatewayDeltaEventApplicationCacheListener extends CacheListenerAdapter<String,GatewayDeltaEvent> implements Declarable {
-
-  private final Cache cache;
-  
-  public GatewayDeltaEventApplicationCacheListener() {
-    this.cache = CacheFactory.getAnyInstance();
-  }
-  
-  public void afterCreate(EntryEvent<String,GatewayDeltaEvent> event) {
-    System.out.println("GatewayDeltaApplierCacheListener event: " + event);
-    EntryEventImpl eventImpl = (EntryEventImpl) event;
-    if (this.cache.getLogger().fineEnabled()) {
-      StringBuilder builder = new StringBuilder();
-      builder
-        .append("GatewayDeltaApplierCacheListener: Received event for ")
-        .append(event.getKey())
-        .append("->")
-        .append(event.getNewValue())
-        .append(".");
-      this.cache.getLogger().fine(builder.toString());
-    }
-
-    // If the event is from a remote site, apply it to the session
-    Object callbackArgument = eventImpl.getRawCallbackArgument();
-    System.out.println("GatewayDeltaApplierCacheListener callbackArgument: " + callbackArgument);
-    if (callbackArgument instanceof GatewayEventCallbackArgument) {
-      GatewayDeltaEvent delta = event.getNewValue();
-      delta.apply(this.cache);
-      System.out.println("Applied " + delta);
-      if (this.cache.getLogger().fineEnabled()) {
-        StringBuilder builder = new StringBuilder();
-        builder
-          .append("GatewayDeltaApplierCacheListener: Applied ")
-          .append(delta);
-        this.cache.getLogger().fine(builder.toString());
-      }
-    }
-  }
-
-  public void init(Properties p) {}
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaForwarderCacheListener.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaForwarderCacheListener.java b/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaForwarderCacheListener.java
deleted file mode 100644
index f3e08f7..0000000
--- a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/gatewaydelta/GatewayDeltaForwarderCacheListener.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-package com.gemstone.gemfire.modules.gatewaydelta;
-
-import java.util.Properties;
-
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.CacheFactory;
-import com.gemstone.gemfire.cache.DataPolicy;
-import com.gemstone.gemfire.cache.Declarable;
-import com.gemstone.gemfire.cache.EntryEvent;
-import com.gemstone.gemfire.cache.InterestPolicy;
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.RegionFactory;
-import com.gemstone.gemfire.cache.Scope;
-import com.gemstone.gemfire.cache.SerializedCacheValue;
-import com.gemstone.gemfire.cache.SubscriptionAttributes;
-import com.gemstone.gemfire.cache.util.CacheListenerAdapter;
-import com.gemstone.gemfire.internal.cache.EntryEventImpl;
-import com.gemstone.gemfire.internal.cache.LocalRegion;
-
-public class GatewayDeltaForwarderCacheListener extends CacheListenerAdapter<String,GatewayDelta> implements Declarable {
-
-  private final Cache cache;
-   
-  private LocalRegion gatewayDeltaRegion;
-  
-  public GatewayDeltaForwarderCacheListener() {
-    this(CacheFactory.getAnyInstance());
-  }
-  
-  public GatewayDeltaForwarderCacheListener(Cache cache) {
-    this.cache = cache;
-  }
-  
-  @SuppressWarnings("unchecked")
-  public void afterCreate(EntryEvent<String,GatewayDelta> event) {
-    // If the event is from the local site, create a 'create' event and send it to the
-    // gateway delta region
-    if (event.getCallbackArgument() == null) {
-      if (this.cache.getLogger().fineEnabled()) {
-        StringBuilder builder = new StringBuilder();
-        builder
-          .append("GatewayDeltaForwarderCacheListener: Received create event for ")
-          .append(event.getKey())
-          .append("->")
-          .append(event.getNewValue())
-          .append(" that originated in the local site. Sending it to the remote site.");
-        this.cache.getLogger().fine(builder.toString());
-      }
-      
-      // Distribute the create event to the gateway hub(s)
-      String regionName = event.getRegion().getFullPath();
-      String sessionId = event.getKey();
-      SerializedCacheValue scv = event.getSerializedNewValue();
-      if (scv == null) {
-        getGatewayDeltaRegion().put(sessionId, new GatewayDeltaCreateEvent(regionName, sessionId, EntryEventImpl.serialize(event.getNewValue())));
-      } else {
-        System.out.println("GatewayDeltaForwarderCacheListener event.getSerializedNewValue().getSerializedValue(): " + event.getSerializedNewValue().getSerializedValue());
-        getGatewayDeltaRegion().put(sessionId, new GatewayDeltaCreateEvent(regionName, sessionId, scv.getSerializedValue()));
-      }
-    } else {
-      if (this.cache.getLogger().fineEnabled()) {
-        StringBuilder builder = new StringBuilder();
-        builder
-          .append("GatewayDeltaForwarderCacheListener: Received create event for ")
-          .append(event.getKey())
-          .append("->")
-          .append(event.getNewValue())
-          .append(" that originated in the remote site.");
-        this.cache.getLogger().fine(builder.toString());
-      }
-    }
-  }
-  
-  public void afterUpdate(EntryEvent<String,GatewayDelta> event) {
-    //System.out.println("GatewayDeltaForwarderCacheListener.afterUpdate: " + event);
-    // If the event is from the local site, create an 'update' event and send it to the
-    // gateway delta region
-    if (event.getCallbackArgument() == null) {
-      if (this.cache.getLogger().fineEnabled()) {
-        StringBuilder builder = new StringBuilder();
-        builder
-          .append("GatewayDeltaForwarderCacheListener: Received update event for ")
-          .append(event.getKey())
-          .append("->")
-          .append(event.getNewValue())
-          .append(" that originated in the local site. Sending it to the remote site.");
-        this.cache.getLogger().fine(builder.toString());
-      }
-      
-      // Distribute the update event to the gateway hub(s)
-      GatewayDelta session = event.getNewValue();
-      getGatewayDeltaRegion().put(event.getKey(), session.getCurrentGatewayDeltaEvent());
-      
-      // Reset the current delta
-      session.setCurrentGatewayDeltaEvent(null);
-    } else {
-      if (this.cache.getLogger().fineEnabled()) {
-        StringBuilder builder = new StringBuilder();
-        builder
-          .append("GatewayDeltaForwarderCacheListener: Received update event for ")
-          .append(event.getKey())
-          .append("->")
-          .append(event.getNewValue())
-          .append(" that originated in the remote site.");
-        this.cache.getLogger().fine(builder.toString());
-      }
-    }
-  }
-  
-  public void afterDestroy(EntryEvent<String,GatewayDelta> event) {
-    // If the event is from the local site, create a 'destroy' event and send it to the
-    // gateway delta region
-    if (event.getCallbackArgument() != null) {
-      if (this.cache.getLogger().fineEnabled()) {
-        StringBuilder builder = new StringBuilder();
-        builder
-          .append("GatewayDeltaForwarderCacheListener: Received destroy event for ")
-          .append(event.getKey())
-          .append("->")
-          .append(event.getNewValue())
-          .append(" that originated in the local site. Sending it to the remote site.");
-        this.cache.getLogger().fine(builder.toString());
-      }
-      
-      // Distribute the destroy event to the gateway hub(s)
-      String sessionId = event.getKey();
-      getGatewayDeltaRegion().put(sessionId, new GatewayDeltaDestroyEvent(event.getRegion().getFullPath(), sessionId));
-    } else {
-      if (this.cache.getLogger().fineEnabled()) {
-        StringBuilder builder = new StringBuilder();
-        builder
-          .append("GatewayDeltaForwarderCacheListener: Received destroy event for session ")
-          .append(event.getKey())
-          .append(" that either expired or originated in the remote site.");
-        this.cache.getLogger().fine(builder.toString());
-      }
-    }
-  }
-
-  public void init(Properties p) {
-  }
-  
-  private LocalRegion getGatewayDeltaRegion() {
-    if (this.gatewayDeltaRegion == null) {
-      this.gatewayDeltaRegion = createOrRetrieveGatewayDeltaRegion();
-    }
-    return this.gatewayDeltaRegion;
-  }
-  
-  @SuppressWarnings("unchecked")
-  private LocalRegion createOrRetrieveGatewayDeltaRegion() {
-    Region region = this.cache.getRegion(GatewayDelta.GATEWAY_DELTA_REGION_NAME);
-    if (region == null) {
-      region = new RegionFactory()
-        .setScope(Scope.LOCAL)
-        .setDataPolicy(DataPolicy.EMPTY)
-        .setSubscriptionAttributes(new SubscriptionAttributes(InterestPolicy.ALL))
-        .setEnableGateway(true)
-        .addCacheListener(new GatewayDeltaEventApplicationCacheListener())
-        .create(GatewayDelta.GATEWAY_DELTA_REGION_NAME);
-    }
-    if (this.cache.getLogger().fineEnabled()) {
-      StringBuilder builder = new StringBuilder();
-      builder
-        .append("GatewayDeltaForwarderCacheListener: Created gateway delta region: ")
-        .append(region);
-      this.cache.getLogger().fine(builder.toString());
-    }
-    return (LocalRegion) region;
-  }
-  
-  public boolean equals(Object obj) {
-    // This method is only implemented so that RegionCreator.validateRegion works properly.
-    // The CacheListener comparison fails because two of these instances are not equal.
-    if (this == obj) {
-      return true;
-    }
-
-    if (obj == null || !(obj instanceof GatewayDeltaForwarderCacheListener)) {
-      return false;
-    }
-    
-    return true;
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/AbstractCache.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/AbstractCache.java b/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/AbstractCache.java
deleted file mode 100644
index c902b0b..0000000
--- a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/AbstractCache.java
+++ /dev/null
@@ -1,399 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-package com.gemstone.gemfire.modules.session.bootstrap;
-
-import java.io.File;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.ConcurrentHashMap;
-
-import com.gemstone.gemfire.cache.GemFireCache;
-import com.gemstone.gemfire.cache.control.ResourceManager;
-import com.gemstone.gemfire.distributed.internal.AbstractDistributionConfig;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.internal.cache.LocalRegion;
-import com.gemstone.gemfire.modules.util.Banner;
-import com.gemstone.gemfire.modules.util.RegionHelper;
-import com.gemstone.gemfire.modules.util.ResourceManagerValidator;
-import java.util.concurrent.atomic.AtomicBoolean;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public abstract class AbstractCache {
-  
-  protected GemFireCache cache;
-  
-  private static final DateFormat FORMAT = new SimpleDateFormat("yyyy-MM-dd");
-  
-  protected static final String DEFAULT_LOG_FILE_NAME = RegionHelper.NAME + "." + FORMAT.format(new Date()) + ".log";
-  
-  protected static final String DEFAULT_STATISTIC_ARCHIVE_FILE_NAME = RegionHelper.NAME + ".gfs";
-  
-  protected static final float DEFAULT_EVICTION_HEAP_PERCENTAGE = LocalRegion.DEFAULT_HEAPLRU_EVICTION_HEAP_PERCENTAGE;
-  
-  protected static final float DEFAULT_CRITICAL_HEAP_PERCENTAGE = ResourceManager.DEFAULT_CRITICAL_HEAP_PERCENTAGE;
-  
-  protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractCache.class);
-  
-  protected float evictionHeapPercentage = DEFAULT_EVICTION_HEAP_PERCENTAGE;
-  
-  protected float criticalHeapPercentage = DEFAULT_CRITICAL_HEAP_PERCENTAGE;
-  
-  protected boolean rebalance = false;
-
-  protected final Map<String,String> gemfireProperties;
-
-  private final AtomicBoolean started = new AtomicBoolean(false);
-
-  /**
-   * Instance reference which is set in static initialization blocks of any
-   * subclasses.
-   */
-  protected static AbstractCache instance = null;
-
-  public AbstractCache() {
-    this.gemfireProperties = new ConcurrentHashMap<String,String>();
-  }
-
-  public void lifecycleEvent(LifecycleTypeAdapter eventType) {
-    if (getLogger().isDebugEnabled()) {
-      getLogger().debug("Received " + eventType + " event");
-    }
-
-    if (eventType.equals(LifecycleTypeAdapter.START) && 
-            started.compareAndSet(false, true)) {
-      // Create or retrieve the cache
-      getLogger().info("Initializing " + Banner.getString());
-      createOrRetrieveCache();
-
-      // Initialize the resource manager
-      initializeResourceManager();
-    } else if (eventType.equals(LifecycleTypeAdapter.AFTER_START)) {
-      if (getRebalance()) {
-        rebalanceCache();
-      }
-    } else if (eventType.equals(LifecycleTypeAdapter.STOP)) {
-      // Close the cache
-//      closeCache();
-      // TODO: Do we need to reset the started flag here?
-    }
-  }
-
-  public boolean isStarted() {
-    return started.get();
-  }
-
-  public void close() {
-    getCache().close();
-    while (! getCache().isClosed()) {
-    }
-
-    started.set(false);
-  }
-
-  public GemFireCache getCache() {
-    return this.cache;
-  }
-  
-  public String getLogFileName() {
-    String logFileName = getGemFireProperties().get(DistributionConfig.LOG_FILE_NAME);
-    if (logFileName == null) {
-      logFileName = DEFAULT_LOG_FILE_NAME;
-    }
-    return logFileName;
-  }
-  
-  public String getStatisticArchiveFileName() {
-    String statisticsArchiveFileName = getGemFireProperties().get(DistributionConfig.STATISTIC_ARCHIVE_FILE_NAME);
-    if (statisticsArchiveFileName == null) {
-      statisticsArchiveFileName = DEFAULT_STATISTIC_ARCHIVE_FILE_NAME;
-    }
-    return statisticsArchiveFileName;
-  }
-
-  public String getCacheXmlFileName() {
-    String cacheXmlFileName = getGemFireProperties().get(DistributionConfig.CACHE_XML_FILE_NAME);
-    if (cacheXmlFileName == null) {
-      cacheXmlFileName = getDefaultCacheXmlFileName();
-    }
-    return cacheXmlFileName;
-  }
-
-  protected File getCacheXmlFile() {
-    String cacheXmlFileName = getCacheXmlFileName();
-    File cacheXmlFile = new File(cacheXmlFileName);
-    // If the cache xml file is not absolute, point it at the conf directory.
-    if (!cacheXmlFile.isAbsolute()) {
-      if (System.getProperty("catalina.base") != null) {
-        cacheXmlFile = new File(System.getProperty("catalina.base") + "/conf/", cacheXmlFileName);
-      }
-    }
-    return cacheXmlFile;
-  }
-
-  public float getEvictionHeapPercentage() {
-    return this.evictionHeapPercentage;
-  }
-
-  public void setEvictionHeapPercentage(String evictionHeapPercentage) {
-    this.evictionHeapPercentage = Float.valueOf(evictionHeapPercentage);
-  }
-
-  public float getCriticalHeapPercentage() {
-    return this.criticalHeapPercentage;
-  }
-
-  public void setCriticalHeapPercentage(String criticalHeapPercentage) {
-    this.criticalHeapPercentage = Float.valueOf(criticalHeapPercentage);
-  }
-  
-  public void setRebalance(boolean rebalance) {
-    this.rebalance = rebalance;
-  }
-  
-  public boolean getRebalance() {
-    return this.rebalance;
-  }
-
-  public Map<String,String> getGemFireProperties() {
-    return this.gemfireProperties;
-  }
-  
-  public void setProperty(String name, String value) {
-    //TODO Look at fake attributes
-    if (name.equals("className")) {
-      return;
-    }
-    
-    // Determine the validity of the input property
-    boolean validProperty = false;
-    for (String gemfireProperty : AbstractDistributionConfig._getAttNames()) {
-      if (name.equals(gemfireProperty)) {
-        validProperty = true;
-        break;
-      }
-    }
-    
-    // If it is a valid GemFire property, add it to the the GemFire properties.
-    // Otherwise, log a warning.
-    if (validProperty) {
-      this.gemfireProperties.put(name, value);
-    } else {
-      getLogger().warn("The input property named " + name + " is not a valid GemFire property. It is being ignored.");
-    }
-  }
-  
-  public Logger getLogger() {
-    return LOGGER;
-  }
-  
-  protected Properties createDistributedSystemProperties() {
-    Properties properties = new Properties();
-    
-    // Add any additional gemfire properties
-    for (Map.Entry<String,String> entry : this.gemfireProperties.entrySet()) {
-      properties.put(entry.getKey(), entry.getValue());
-    }
-    
-    // Replace the cache xml file in the properties
-    File cacheXmlFile = getCacheXmlFile();
-    String absoluteCacheXmlFileName = cacheXmlFile.getAbsolutePath();
-    // If the file doesn't exist and the name is the default, set cache-xml-file
-    // to the GemFire default. This is for the case where only the jars have been
-    // installed and no default cache.xml exists in the conf directory.
-    if (getCacheXmlFileName().equals(getDefaultCacheXmlFileName()) && !cacheXmlFile.exists()) {
-      absoluteCacheXmlFileName = DistributionConfig.DEFAULT_CACHE_XML_FILE.getName();
-    }
-    properties.put(DistributionConfig.CACHE_XML_FILE_NAME, absoluteCacheXmlFileName);
-
-    // Replace the log file in the properties
-    properties.put(DistributionConfig.LOG_FILE_NAME, getLogFile().getAbsolutePath());
-    
-    // Replace the statistics archive file in the properties
-    File statisticArchiveFile = getStatisticArchiveFile();
-    if (statisticArchiveFile == null) {
-        // Remove the statistics archive file name since statistic sampling is disabled
-        properties.remove(DistributionConfig.STATISTIC_ARCHIVE_FILE_NAME);
-        properties.remove(DistributionConfig.STATISTIC_SAMPLING_ENABLED_NAME);
-    } else {
-      properties.put(DistributionConfig.STATISTIC_ARCHIVE_FILE_NAME, statisticArchiveFile.getAbsolutePath());
-    }
-    getLogger().info("Creating distributed system from: " + properties);
-
-    return properties;
-  }
-  
-  protected void closeCache() {
-    if (getLogger().isDebugEnabled()) {
-      getLogger().debug("Closing " + this.cache);
-    }
-    if (getCache() != null) {
-      getCache().close();
-    }
-    getLogger().info("Closed " + this.cache);
-  }
-  
-  protected File getLogFile() {
-    String logFileName = getLogFileName();
-    File logFile = new File(logFileName);
-    // If the log file is not absolute, point it at the logs directory.
-    if (!logFile.isAbsolute()) {
-      if (System.getProperty("catalina.base") != null) {
-          logFile = new File(System.getProperty("catalina.base") + "/logs/", logFileName);
-      } else if (System.getProperty("weblogic.Name") != null) {
-        String weblogicName = System.getProperty("weblogic.Name");
-        String separator = System.getProperty("file.separator");
-        logFile = new File("servers" + separator + weblogicName + separator + 
-                "logs" + separator + logFileName);
-      } else {
-        logFile = new File(System.getProperty("gemfire.logdir"), logFileName);
-      }
-    }
-    return logFile;
-  }
-  
-  protected File getStatisticArchiveFile() {
-    File statisticsArchiveFile = null;
-    String statisticSamplingEnabled = getGemFireProperties().get(DistributionConfig.STATISTIC_SAMPLING_ENABLED_NAME);
-    if (statisticSamplingEnabled != null && statisticSamplingEnabled.equals("true")) {
-      String statisticsArchiveFileName = getStatisticArchiveFileName();
-      statisticsArchiveFile = new File(statisticsArchiveFileName);
-      // If the statistics archive file is not absolute, point it at the logs directory.
-      if (!statisticsArchiveFile.isAbsolute()) {
-        if (System.getProperty("catalina.base") != null) {
-          statisticsArchiveFile = new File(System.getProperty("catalina.base") + 
-              "/logs/", statisticsArchiveFileName);
-        } else if (System.getProperty("weblogic.Name") != null) {
-          String weblogicName = System.getProperty("weblogic.Name");
-          String separator = System.getProperty("file.separator");
-          statisticsArchiveFile = new File("servers" + separator + weblogicName + separator + 
-              "logs" + separator + statisticsArchiveFileName);
-        } else {
-          statisticsArchiveFile = new File(System.getProperty("gemfire.statisticsdir"),
-              statisticsArchiveFileName);
-        }
-      }
-    }
-    return statisticsArchiveFile;
-  }
-
-  protected void initializeResourceManager() {
-    // Get current eviction and critical heap percentages
-    ResourceManager rm = getCache().getResourceManager();
-    float currentEvictionHeapPercentage = rm.getEvictionHeapPercentage();
-    float currentCriticalHeapPercentage = rm.getCriticalHeapPercentage();
-    
-    // Set new eviction and critical heap percentages if necessary
-    if (getEvictionHeapPercentage() != currentEvictionHeapPercentage
-        || getCriticalHeapPercentage() != currentCriticalHeapPercentage) {
-      if (getLogger().isDebugEnabled()) {
-        StringBuilder builder = new StringBuilder();
-        builder
-          .append("Previous eviction heap percentage=")
-          .append(currentEvictionHeapPercentage)
-          .append("; critical heap percentage=")
-          .append(currentCriticalHeapPercentage);
-        getLogger().debug(builder.toString());
-        builder.setLength(0);
-        builder
-          .append("Requested eviction heap percentage=")
-          .append(getEvictionHeapPercentage())
-          .append("; critical heap percentage=")
-          .append(getCriticalHeapPercentage());
-        getLogger().debug(builder.toString());
-      }
-      if (currentCriticalHeapPercentage == 0.0f) {
-        // If the current critical heap percentage is 0 (disabled), set eviction
-        // heap percentage first, then set the critical heap percentage. At this
-        // point, the eviction heap percentage can be set to anything.
-        try {
-          rm.setEvictionHeapPercentage(getEvictionHeapPercentage());
-          rm.setCriticalHeapPercentage(getCriticalHeapPercentage());
-        } catch (IllegalArgumentException e) {
-          handleResourceManagerException(e, currentEvictionHeapPercentage, currentCriticalHeapPercentage);
-          rm.setEvictionHeapPercentage(currentEvictionHeapPercentage);
-          rm.setCriticalHeapPercentage(currentCriticalHeapPercentage);
-        }
-      } else if (getCriticalHeapPercentage() >= currentCriticalHeapPercentage) {
-        // If the requested critical heap percentage is >= the current critical
-        // heap percentage, then set the critical heap percentage first since it
-        // can safely be slid up. Then, set the eviction heap percentage.
-        try {
-          rm.setCriticalHeapPercentage(getCriticalHeapPercentage());
-          rm.setEvictionHeapPercentage(getEvictionHeapPercentage());
-        } catch (IllegalArgumentException e) {
-          handleResourceManagerException(e, currentEvictionHeapPercentage, currentCriticalHeapPercentage);
-          rm.setCriticalHeapPercentage(currentCriticalHeapPercentage);
-          rm.setEvictionHeapPercentage(currentEvictionHeapPercentage);
-        }
-      } else {
-        // If the requested critical heap percentage is < the current critical
-        // heap percentage, then set the eviction heap percentage first since it
-        // can safely be slid down. Then, set the critical heap percentage.
-        try {
-          rm.setEvictionHeapPercentage(getEvictionHeapPercentage());
-          rm.setCriticalHeapPercentage(getCriticalHeapPercentage());
-        } catch (IllegalArgumentException e) {
-          handleResourceManagerException(e, currentEvictionHeapPercentage, currentCriticalHeapPercentage);
-          rm.setEvictionHeapPercentage(currentEvictionHeapPercentage);
-          rm.setCriticalHeapPercentage(currentCriticalHeapPercentage);
-        }
-      }
-      if (getLogger().isDebugEnabled()) {
-        StringBuilder builder = new StringBuilder();
-        builder
-          .append("Actual eviction heap percentage=")
-          .append(rm.getEvictionHeapPercentage())
-          .append("; critical heap percentage=")
-          .append(rm.getCriticalHeapPercentage());
-        getLogger().debug(builder.toString());
-      }
-    }
-    
-    // Validate java startup parameters (done after setting the eviction and
-    // critical heap percentages so that the CMSInitiatingOccupancyFraction can
-    // be compared against them.
-    ResourceManagerValidator.validateJavaStartupParameters(getCache());
-  }
-  
-  private void handleResourceManagerException(IllegalArgumentException e,
-      float currentEvictionHeapPercentage, float currentCriticalHeapPercentage) {
-    StringBuilder builder = new StringBuilder();
-    builder
-      .append("Caught exception attempting to set eviction heap percentage=")
-      .append(getEvictionHeapPercentage())
-      .append(" and critical heap percentage=")
-      .append(getCriticalHeapPercentage())
-      .append(". The percentages will be set back to their previous values (eviction heap percentage=")
-      .append(currentEvictionHeapPercentage)
-      .append(" and critical heap percentage=")
-      .append(currentCriticalHeapPercentage)
-      .append(").");
-    getLogger().warn(builder.toString(), e);  
-  }
-
-  @Override
-  public String toString() {
-    return new StringBuilder()
-      .append(getClass().getSimpleName())
-      .append("[")
-      .append("cache=")
-      .append(this.cache)
-      .append("]")
-      .toString();
-  }
-
-  protected abstract void createOrRetrieveCache();
-  
-  protected abstract void rebalanceCache();
-  
-  protected abstract String getDefaultCacheXmlFileName();
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/ClientServerCache.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/ClientServerCache.java b/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/ClientServerCache.java
deleted file mode 100644
index f49fac4..0000000
--- a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/ClientServerCache.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-package com.gemstone.gemfire.modules.session.bootstrap;
-
-import com.gemstone.gemfire.cache.CacheClosedException;
-import com.gemstone.gemfire.cache.client.ClientCacheFactory;
-
-/**
- * This is a singleton class which maintains configuration properties as well
- * as starting a Client-Server cache.
- */
-public class ClientServerCache extends AbstractCache {
-
-  protected static final String DEFAULT_CACHE_XML_FILE_NAME = "cache-client.xml";
-
-  static {
-    instance = new ClientServerCache();
-  }
-
-  private ClientServerCache() {
-      // Singleton
-      super();
-  }
-
-  public static AbstractCache getInstance() {
-      return instance;
-  }
-
-  @Override
-  protected void createOrRetrieveCache() {
-    if (getLogger().isDebugEnabled()) {
-      getLogger().debug(this + ": Creating cache");
-    }
-    // Get the existing cache if any
-    try {
-      this.cache = ClientCacheFactory.getAnyInstance();
-    } catch (CacheClosedException e) {}
-    
-    // If no cache exists, create one
-    String message = null;
-    if (this.cache == null) {
-      // enable pool subscription so that default cache can be used by hibernate module
-      this.cache = new ClientCacheFactory(createDistributedSystemProperties()).create();
-      message = "Created ";
-    } else {
-      message = "Retrieved ";
-    }
-    getLogger().info(message + this.cache);
-  }
-  
-  @Override
-  protected void rebalanceCache() {
-    getLogger().warn("The client cannot rebalance the server's cache.");
-  }
-  
-  @Override
-  protected String getDefaultCacheXmlFileName() {
-    return DEFAULT_CACHE_XML_FILE_NAME;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/63bc5f03/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/LifecycleTypeAdapter.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/LifecycleTypeAdapter.java b/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/LifecycleTypeAdapter.java
deleted file mode 100644
index 158d8fc..0000000
--- a/modules/gemfire-modules/src/main/java/com/gemstone/gemfire/modules/session/bootstrap/LifecycleTypeAdapter.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-package com.gemstone.gemfire.modules.session.bootstrap;
-
-/**
- * Adapter for the Catalina Lifecycle event types
- */
-public enum LifecycleTypeAdapter {
-
-  CONFIGURE_START,
-
-  CONFIGURE_STOP,
-
-  AFTER_DESTROY,
-
-  AFTER_INIT,
-
-  AFTER_START,
-
-  AFTER_STOP,
-
-  BEFORE_DESTROY,
-
-  BEFORE_INIT,
-
-  BEFORE_START,
-
-  BEFORE_STOP,
-
-  DESTROY,
-
-  INIT,
-
-  PERIODIC,
-
-  START,
-
-  STOP;
-
-}