geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jensde...@apache.org
Subject [2/3] incubator-geode git commit: GEODE-1410: Fix artifacts published for modules
Date Tue, 24 May 2016 21:30:36 GMT
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/46eeb39c/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/AbstractSessionAttributes.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/AbstractSessionAttributes.java b/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/AbstractSessionAttributes.java
new file mode 100644
index 0000000..c4af041
--- /dev/null
+++ b/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/AbstractSessionAttributes.java
@@ -0,0 +1,188 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package com.gemstone.gemfire.modules.session.internal.filter.attributes;
+
+import com.gemstone.gemfire.DataSerializer;
+import com.gemstone.gemfire.internal.util.BlobHelper;
+import com.gemstone.gemfire.modules.session.internal.filter.GemfireHttpSession;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Abstract implementation for attributes. Should be sub-classed to provide
+ * differing implementations for synchronous or delta propagation. The backing
+ * store used is defined by the session manager.
+ */
+public abstract class AbstractSessionAttributes implements SessionAttributes {
+
+  private static final Logger LOG =
+      LoggerFactory.getLogger(AbstractSessionAttributes.class.getName());
+
+  /**
+   * Internal attribute store.
+   */
+  protected Map<String, Object> attributes =
+      Collections.synchronizedMap(new HashMap<String, Object>());
+
+  /**
+   * The session to which these attributes belong
+   */
+  protected transient GemfireHttpSession session;
+
+  /**
+   * The last accessed time
+   */
+  protected long lastAccessedTime;
+
+  /**
+   * The maximum inactive interval. Default is 1800 seconds.
+   */
+  protected int maxInactiveInterval = 60 * 30;
+
+  /**
+   * The JVM Id who last committed these attributes
+   */
+  protected String jvmOwnerId;
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public void setSession(GemfireHttpSession session) {
+    this.session = session;
+  }
+
+  /**
+   * {@inheritDoc} The actual de-serialization of any domain objects is deferred
+   * until the point at which they are actually retrieved by the application
+   * layer.
+   */
+  @Override
+  public Object getAttribute(String name) {
+    Object value = attributes.get(name);
+
+    // If the value is a byte[] (meaning it came from the server),
+    // deserialize it and re-add it to attributes map before returning it.
+    if (value instanceof byte[]) {
+      try {
+        value = BlobHelper.deserializeBlob((byte[]) value);
+        attributes.put(name, value);
+      } catch (Exception iox) {
+        LOG.error("Attribute '" + name +
+            " contains a byte[] that cannot be deserialized due "
+            + "to the following exception", iox);
+      }
+    }
+
+    return value;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public Set<String> getAttributeNames() {
+    return attributes.keySet();
+  }
+
+  /**
+   * {@inheritDoc} +
+   */
+  @Override
+  public void setMaxInactiveInterval(int interval) {
+    maxInactiveInterval = interval;
+  }
+
+  @Override
+  public int getMaxIntactiveInterval() {
+    return maxInactiveInterval;
+  }
+
+  @Override
+  public void setLastAccessedTime(long time) {
+    lastAccessedTime = time;
+  }
+
+  @Override
+  public long getLastAccessedTime() {
+    return lastAccessedTime;
+  }
+
+  /**
+   * {@inheritDoc} This method calls back into the session to flush the whole
+   * session including its attributes.
+   */
+  @Override
+  public void flush() {
+    session.putInRegion();
+  }
+
+  /**
+   * Use DeltaEvents to propagate the actual attribute data - DeltaEvents turn
+   * the values into byte arrays which means that the actual domain classes are
+   * not required on the server.
+   */
+  @Override
+  public void toData(DataOutput out) throws IOException {
+    out.writeInt(maxInactiveInterval);
+    out.writeLong(lastAccessedTime);
+
+    synchronized (attributes) {
+      out.writeInt(attributes.size());
+      for (Map.Entry<String, Object> entry : attributes.entrySet()) {
+        DeltaEvent delta = new DeltaEvent(true, entry.getKey(),
+            entry.getValue());
+        DataSerializer.writeObject(delta, out);
+      }
+    }
+
+    out.writeUTF(jvmOwnerId);
+  }
+
+  @Override
+  public void fromData(
+      DataInput in) throws IOException, ClassNotFoundException {
+    maxInactiveInterval = in.readInt();
+    lastAccessedTime = in.readLong();
+    int size = in.readInt();
+    while (size-- > 0) {
+      DeltaEvent event = DataSerializer.readObject(in);
+      attributes.put(event.getName(), event.getValue());
+    }
+    jvmOwnerId = in.readUTF();
+  }
+
+  @Override
+  public void setJvmOwnerId(String jvmId) {
+    this.jvmOwnerId = jvmId;
+  }
+
+  @Override
+  public String getJvmOwnerId() {
+    return jvmOwnerId;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/46eeb39c/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/DeltaEvent.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/DeltaEvent.java b/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/DeltaEvent.java
new file mode 100644
index 0000000..4c248dd
--- /dev/null
+++ b/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/DeltaEvent.java
@@ -0,0 +1,119 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package com.gemstone.gemfire.modules.session.internal.filter.attributes;
+
+import com.gemstone.gemfire.DataSerializable;
+import com.gemstone.gemfire.DataSerializer;
+import com.gemstone.gemfire.internal.util.BlobHelper;
+import com.gemstone.gemfire.modules.session.internal.filter.GemfireHttpSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+/**
+ * Capture the update to a particular name
+ */
+public class DeltaEvent implements DataSerializable {
+
+  private static final Logger LOG =
+      LoggerFactory.getLogger(DeltaEvent.class.getName());
+  /**
+   * The event is either an update (true) or a remove (false)
+   */
+  private boolean update;
+
+  private String name;
+
+  private Object value = null;
+
+  private GemfireHttpSession session = null;
+
+  /**
+   * Constructor for de-serialization only
+   */
+  public DeltaEvent() {
+  }
+
+  /**
+   * Constructor which creates a 'deferred' event. This is used when the value
+   * should only be applied when the object is serialized.
+   *
+   * @param session   the session from which the value ultimately will be
+   *                  retrieved
+   * @param attribute the name of the attribute
+   */
+  public DeltaEvent(GemfireHttpSession session, String attribute) {
+    this.session = session;
+    this.name = attribute;
+    this.update = true;
+  }
+
+  public DeltaEvent(boolean update, String attribute, Object value) {
+    this.update = update;
+    this.name = attribute;
+    this.value = value;
+    blobifyValue();
+  }
+
+  private void blobifyValue() {
+    if (value instanceof byte[]) {
+      LOG.warn("Session attribute is already a byte[] - problems may "
+          + "occur transmitting this delta.");
+    }
+    try {
+      value = BlobHelper.serializeToBlob(value);
+    } catch (IOException iox) {
+      LOG.error("Attribute '" + name + "' value: " + value
+          + " cannot be serialized due to the following exception", iox);
+    }
+  }
+
+  public boolean isUpdate() {
+    return update;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public Object getValue() {
+    return value;
+  }
+
+  @Override
+  public void toData(DataOutput out) throws IOException {
+    if (session != null) {
+      value = session.getNativeSession().getAttribute(name);
+      blobifyValue();
+    }
+    out.writeBoolean(update);
+    DataSerializer.writeString(name, out);
+    DataSerializer.writeObject(value, out);
+  }
+
+  @Override
+  public void fromData(
+      DataInput in) throws IOException, ClassNotFoundException {
+    update = in.readBoolean();
+    name = DataSerializer.readString(in);
+    value = DataSerializer.readObject(in);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/46eeb39c/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/DeltaQueuedSessionAttributes.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/DeltaQueuedSessionAttributes.java b/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/DeltaQueuedSessionAttributes.java
new file mode 100644
index 0000000..cb4f673
--- /dev/null
+++ b/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/DeltaQueuedSessionAttributes.java
@@ -0,0 +1,94 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package com.gemstone.gemfire.modules.session.internal.filter.attributes;
+
+import com.gemstone.gemfire.DataSerializable;
+import com.gemstone.gemfire.Instantiator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class implements delayed attribute delta propagation. Updates to
+ * attributes are only propagated once the session goes out of scope - i.e. as
+ * the request is done being processed.
+ */
+public class DeltaQueuedSessionAttributes extends AbstractDeltaSessionAttributes {
+
+  private static final Logger LOG =
+      LoggerFactory.getLogger(DeltaQueuedSessionAttributes.class.getName());
+
+  private Trigger trigger = Trigger.SET;
+
+  private enum Trigger {
+    SET,
+    SET_AND_GET;
+  }
+
+  /**
+   * Register ourselves for de-serialization
+   */
+  static {
+    Instantiator.register(
+        new Instantiator(DeltaQueuedSessionAttributes.class, 3479) {
+          @Override
+          public DataSerializable newInstance() {
+            return new DeltaQueuedSessionAttributes();
+          }
+        });
+  }
+
+  /**
+   * Default constructor
+   */
+  public DeltaQueuedSessionAttributes() {
+  }
+
+  public void setReplicationTrigger(String trigger) {
+    this.trigger = Trigger.valueOf(trigger.toUpperCase());
+  }
+
+  @Override
+  public Object getAttribute(String attr) {
+    if (trigger == Trigger.SET_AND_GET) {
+      deltas.put(attr, new DeltaEvent(session, attr));
+    }
+    return super.getAttribute(attr);
+  }
+
+  /**
+   * {@inheritDoc} Put an attribute, setting the dirty flag. The changes are
+   * flushed at the end of filter processing.
+   */
+  @Override
+  public Object putAttribute(String attr, Object value) {
+    Object obj = attributes.put(attr, value);
+    deltas.put(attr, new DeltaEvent(true, attr, value));
+    return obj;
+  }
+
+  /**
+   * {@inheritDoc} Remove an attribute, setting the dirty flag. The changes are
+   * flushed at the end of filter processing.
+   */
+  @Override
+  public Object removeAttribute(String attr) {
+    Object obj = attributes.remove(attr);
+    deltas.put(attr, new DeltaEvent(false, attr, null));
+    return obj;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/46eeb39c/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/DeltaSessionAttributes.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/DeltaSessionAttributes.java b/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/DeltaSessionAttributes.java
new file mode 100644
index 0000000..8cc9866
--- /dev/null
+++ b/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/DeltaSessionAttributes.java
@@ -0,0 +1,75 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package com.gemstone.gemfire.modules.session.internal.filter.attributes;
+
+import com.gemstone.gemfire.DataSerializable;
+import com.gemstone.gemfire.Instantiator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class implements synchronous attribute delta propagation. Updates to
+ * attributes are immediately propagated.
+ */
+public class DeltaSessionAttributes extends AbstractDeltaSessionAttributes {
+
+  private static final Logger LOG =
+      LoggerFactory.getLogger(DeltaSessionAttributes.class.getName());
+
+  /**
+   * Register ourselves for de-serialization
+   */
+  static {
+    Instantiator.register(new Instantiator(DeltaSessionAttributes.class, 347) {
+      @Override
+      public DataSerializable newInstance() {
+        return new DeltaSessionAttributes();
+      }
+    });
+  }
+
+  /**
+   * Default constructor
+   */
+  public DeltaSessionAttributes() {
+  }
+
+  /**
+   * {@inheritDoc} Put an attribute, setting the dirty flag and immediately
+   * flushing the delta queue.
+   */
+  @Override
+  public Object putAttribute(String attr, Object value) {
+    Object obj = attributes.put(attr, value);
+    deltas.put(attr, new DeltaEvent(true, attr, value));
+    flush();
+    return obj;
+  }
+
+  /**
+   * {@inheritDoc} Remove an attribute, setting the dirty flag and immediately
+   * flushing the delta queue.
+   */
+  @Override
+  public Object removeAttribute(String attr) {
+    Object obj = attributes.remove(attr);
+    deltas.put(attr, new DeltaEvent(false, attr, null));
+    flush();
+    return obj;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/46eeb39c/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/ImmediateSessionAttributes.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/ImmediateSessionAttributes.java b/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/ImmediateSessionAttributes.java
new file mode 100644
index 0000000..15936ba
--- /dev/null
+++ b/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/ImmediateSessionAttributes.java
@@ -0,0 +1,68 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package com.gemstone.gemfire.modules.session.internal.filter.attributes;
+
+import com.gemstone.gemfire.DataSerializable;
+import com.gemstone.gemfire.Instantiator;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class implements immediately transmitted attributes. All attributes are
+ * transmitted for every attribute update. This is bound to be a performance hit
+ * in some cases but ensures much higher data availability.
+ */
+public class ImmediateSessionAttributes extends AbstractSessionAttributes {
+
+  private static final Logger LOG =
+      LoggerFactory.getLogger(ImmediateSessionAttributes.class.getName());
+
+  /**
+   * Register ourselves for de-serialization
+   */
+  static {
+    Instantiator.register(
+        new Instantiator(ImmediateSessionAttributes.class, 347) {
+          @Override
+          public DataSerializable newInstance() {
+            return new ImmediateSessionAttributes();
+          }
+        });
+  }
+
+  /**
+   * Default constructor
+   */
+  public ImmediateSessionAttributes() {
+  }
+
+  @Override
+  public Object putAttribute(String attr, Object value) {
+    Object obj = attributes.put(attr, value);
+    flush();
+    return obj;
+  }
+
+  @Override
+  public Object removeAttribute(String attr) {
+    Object obj = attributes.remove(attr);
+    flush();
+    return obj;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/46eeb39c/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/QueuedSessionAttributes.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/QueuedSessionAttributes.java b/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/QueuedSessionAttributes.java
new file mode 100644
index 0000000..8d20b43
--- /dev/null
+++ b/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/QueuedSessionAttributes.java
@@ -0,0 +1,65 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package com.gemstone.gemfire.modules.session.internal.filter.attributes;
+
+import com.gemstone.gemfire.DataSerializable;
+import com.gemstone.gemfire.Instantiator;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class implements an attribute container which delays sending updates
+ * until the session goes out of scope. All attributes are transmitted during
+ * the update.
+ */
+public class QueuedSessionAttributes extends AbstractSessionAttributes {
+
+  private static final Logger LOG =
+      LoggerFactory.getLogger(QueuedSessionAttributes.class.getName());
+
+  /**
+   * Register ourselves for de-serialization
+   */
+  static {
+    Instantiator.register(new Instantiator(QueuedSessionAttributes.class, 347) {
+      @Override
+      public DataSerializable newInstance() {
+        return new QueuedSessionAttributes();
+      }
+    });
+  }
+
+  /**
+   * Default constructor
+   */
+  public QueuedSessionAttributes() {
+  }
+
+  @Override
+  public Object putAttribute(String attr, Object value) {
+    Object obj = attributes.put(attr, value);
+    return obj;
+  }
+
+  @Override
+  public Object removeAttribute(String attr) {
+    Object obj = attributes.remove(attr);
+    return obj;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/46eeb39c/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/SessionAttributes.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/SessionAttributes.java b/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/SessionAttributes.java
new file mode 100644
index 0000000..b3b0cef
--- /dev/null
+++ b/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/SessionAttributes.java
@@ -0,0 +1,120 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package com.gemstone.gemfire.modules.session.internal.filter.attributes;
+
+import com.gemstone.gemfire.DataSerializable;
+import com.gemstone.gemfire.modules.session.internal.filter.GemfireHttpSession;
+
+import java.util.Set;
+
+/**
+ * Interface for session attribute storage. In reality, this interface is
+ * responsible for anything, in the session which needs to be propagated for
+ * caching - as such it also includes other 'attributes' such as
+ * maxInactiveInterval and lastAccessedTime
+ */
+public interface SessionAttributes extends DataSerializable {
+
+  /**
+   * Set the session to which these attributes belong.
+   *
+   * @param session the session to set
+   */
+  public void setSession(GemfireHttpSession session);
+
+  /**
+   * Set an attribute value.
+   *
+   * @param attr  the name of the attribute to set
+   * @param value the value for the attribute
+   * @return the value object
+   */
+  public Object putAttribute(String attr, Object value);
+
+  /**
+   * Retrieve an attribute's value.
+   *
+   * @param attr the name of the attribute
+   * @return the object associated with the attribute or null if none exists.
+   */
+  public Object getAttribute(String attr);
+
+  /**
+   * Remove the named attribute.
+   *
+   * @param attr the name of the attribute to remove
+   * @return the value of the attribute removed or null if the named attribute
+   * did not exist.
+   */
+  public Object removeAttribute(String attr);
+
+  /**
+   * Return a set of all attribute names.
+   *
+   * @return a set of all attribute names
+   */
+  public Set<String> getAttributeNames();
+
+  /**
+   * Set the max inactive interval for replication to other systems
+   *
+   * @param interval the time interval in seconds
+   */
+  public void setMaxInactiveInterval(int interval);
+
+  /**
+   * Retrieve the max inactive interval
+   *
+   * @return the max inactive interval in seconds
+   */
+  public int getMaxIntactiveInterval();
+
+  /**
+   * Set the last accessed time for replication to other systems
+   *
+   * @param time the last accessed time in milliseconds
+   */
+  public void setLastAccessedTime(long time);
+
+  /**
+   * Return the last accessed time in milliseconds
+   *
+   * @return the last accessed time
+   */
+  public long getLastAccessedTime();
+
+  /**
+   * Explicitly flush the attributes to backing store.
+   */
+  public void flush();
+
+  /**
+   * Return the last jvm which 'owned' these attributes
+   *
+   * @return the jvmId
+   */
+  public String getJvmOwnerId();
+
+  /**
+   * Set the jvmId. This is set every time the attributes are flushed to the
+   * cache.
+   *
+   * @param jvmId
+   */
+  public void setJvmOwnerId(String jvmId);
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/46eeb39c/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/util/NamedThreadFactory.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/util/NamedThreadFactory.java b/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/util/NamedThreadFactory.java
new file mode 100644
index 0000000..7491cf0
--- /dev/null
+++ b/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/util/NamedThreadFactory.java
@@ -0,0 +1,68 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package com.gemstone.gemfire.modules.session.internal.filter.util;
+
+import java.lang.Thread.UncaughtExceptionHandler;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Factory to create named threads for easy identification at runtime.
+ */
+public class NamedThreadFactory implements ThreadFactory {
+
+  private static final Logger LOG = Logger.getLogger(
+      NamedThreadFactory.class.getName());
+
+  private final String id;
+
+  private final AtomicLong serial = new AtomicLong();
+
+  /**
+   * Create a new thread factory, using the specified pool ID as a basis for
+   * naming each thread.
+   *
+   * @param poolID pool name/ID
+   */
+  public NamedThreadFactory(final String poolID) {
+    id = poolID;
+  }
+
+  /**
+   * {@inheritDoc}
+   * <p/>
+   * This implementation sets the name of the thread, sets the thread to be a
+   * daemon thread, and adds an uncaught exception handler.
+   */
+  @Override
+  public Thread newThread(Runnable r) {
+    Thread thr = new Thread(r);
+    thr.setDaemon(true);
+    thr.setName(id + " - " + serial.incrementAndGet());
+    thr.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
+      @Override
+      public void uncaughtException(Thread t, Throwable e) {
+        LOG.log(Level.WARNING,
+            "Uncaught Exception in thread: " + t.getName(), e);
+      }
+    });
+    return thr;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/46eeb39c/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/util/ThreadLocalSession.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/util/ThreadLocalSession.java b/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/util/ThreadLocalSession.java
new file mode 100644
index 0000000..996b1fd
--- /dev/null
+++ b/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/util/ThreadLocalSession.java
@@ -0,0 +1,39 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package com.gemstone.gemfire.modules.session.internal.filter.util;
+
+import javax.servlet.http.HttpSession;
+
+/**
+ */
+public class ThreadLocalSession {
+  private static ThreadLocal<HttpSession> threadLocal =
+      new ThreadLocal<HttpSession>();
+
+  public static HttpSession get() {
+    return threadLocal.get();
+  }
+
+  public static void set(HttpSession session) {
+    threadLocal.set(session);
+  }
+
+  public static void remove() {
+    threadLocal.remove();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/46eeb39c/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/util/TypeAwareMap.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/util/TypeAwareMap.java b/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/util/TypeAwareMap.java
new file mode 100644
index 0000000..705bafd
--- /dev/null
+++ b/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/util/TypeAwareMap.java
@@ -0,0 +1,50 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package com.gemstone.gemfire.modules.session.internal.filter.util;
+
+import com.gemstone.gemfire.modules.session.internal.common.CacheProperty;
+
+import java.util.HashMap;
+
+/**
+ *
+ */
+public class TypeAwareMap<K extends CacheProperty, Object> extends HashMap {
+
+  private Class<K> keyType;
+
+  public TypeAwareMap(Class<K> keyType) {
+    super();
+    this.keyType = keyType;
+  }
+
+  public Object put(K key, Object value) {
+    if (!key.getClazz().isAssignableFrom(value.getClass())) {
+      if (key.getClazz() == Boolean.class) {
+        return (Object) super.put(key, Boolean.valueOf((String) value));
+      } else if (key.getClazz() == Integer.class) {
+        return (Object) super.put(key, Integer.valueOf((String) value));
+      } else {
+        throw new IllegalArgumentException("Value is not of type " +
+            key.getClazz().getName());
+      }
+    }
+
+    return (Object) super.put(key, value);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/46eeb39c/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/jmx/SessionStatistics.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/jmx/SessionStatistics.java b/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/jmx/SessionStatistics.java
new file mode 100644
index 0000000..9f945da
--- /dev/null
+++ b/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/jmx/SessionStatistics.java
@@ -0,0 +1,78 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package com.gemstone.gemfire.modules.session.internal.jmx;
+
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * Class to manage session statistics
+ */
+public class SessionStatistics implements SessionStatisticsMXBean {
+
+  private AtomicInteger activeSessions = new AtomicInteger(0);
+
+  private AtomicInteger totalSessions = new AtomicInteger(0);
+
+  private AtomicLong regionUpdates = new AtomicLong(0);
+
+  @Override
+  public int getActiveSessions() {
+    return activeSessions.get();
+  }
+
+  @Override
+  public int getTotalSessions() {
+    return totalSessions.get();
+  }
+
+  @Override
+  public long getRegionUpdates() {
+    return regionUpdates.get();
+  }
+
+  public void setActiveSessions(int sessions) {
+    activeSessions.set(sessions);
+  }
+
+  public void setTotalSessions(int sessions) {
+    totalSessions.set(sessions);
+  }
+
+  public void incActiveSessions() {
+    activeSessions.incrementAndGet();
+    totalSessions.incrementAndGet();
+  }
+
+  public void decActiveSessions() {
+    activeSessions.decrementAndGet();
+  }
+
+  public void incTotalSessions() {
+    totalSessions.incrementAndGet();
+  }
+
+  public void decTotalSessions() {
+    totalSessions.decrementAndGet();
+  }
+
+  public void incRegionUpdates() {
+    regionUpdates.incrementAndGet();
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/46eeb39c/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/jmx/SessionStatisticsMXBean.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/jmx/SessionStatisticsMXBean.java b/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/jmx/SessionStatisticsMXBean.java
new file mode 100644
index 0000000..33cfc3e
--- /dev/null
+++ b/extensions/geode-modules-session-internal/src/main/java/com/gemstone/gemfire/modules/session/internal/jmx/SessionStatisticsMXBean.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.gemstone.gemfire.modules.session.internal.jmx;
+
+/**
+ * MXBean interface to retrieve Session statistics
+ */
+public interface SessionStatisticsMXBean {
+
+  public int getActiveSessions();
+
+  public int getTotalSessions();
+
+  public long getRegionUpdates();
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/46eeb39c/extensions/geode-modules-session/build.gradle
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session/build.gradle b/extensions/geode-modules-session/build.gradle
index 5f25d97..4045a69 100644
--- a/extensions/geode-modules-session/build.gradle
+++ b/extensions/geode-modules-session/build.gradle
@@ -16,7 +16,7 @@
  */
 
 dependencies {
-  compile project(':extensions/geode-modules')
+  compile project(':extensions/geode-modules-session-internal')
   compile project(':geode-core')
 
   testCompile 'javax.servlet:javax.servlet-api:' + project.'javax.servlet-api.version'
@@ -31,24 +31,8 @@ dependencies {
 }
 
 jar {
-  include '**/session/filter/**/*'
-  include '**/session/installer/**/*'
-  includeEmptyDirs = false
-
   manifest {
     attributes 'Main-Class': 'com.gemstone.gemfire.modules.session.installer.Installer'
   }
   baseName = 'geode-modules-session'
 }
-
-task internalJar(type: Jar) {
-  from sourceSets.main.output
-  include '**/internal/**/*'
-  includeEmptyDirs = false
-  classifier = 'internal'
-  baseName = 'geode-modules-session-internal'
-}
-
-artifacts {
-  archives internalJar
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/46eeb39c/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/common/AbstractSessionCache.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/common/AbstractSessionCache.java b/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/common/AbstractSessionCache.java
deleted file mode 100644
index 965a97f..0000000
--- a/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/common/AbstractSessionCache.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*      http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-package com.gemstone.gemfire.modules.session.internal.common;
-
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.modules.session.catalina.internal.DeltaSessionStatistics;
-import com.gemstone.gemfire.modules.session.internal.filter.util.TypeAwareMap;
-import com.gemstone.gemfire.modules.util.RegionConfiguration;
-
-import java.util.Map;
-import javax.servlet.http.HttpSession;
-
-public abstract class AbstractSessionCache implements SessionCache {
-
-  /**
-   * The sessionRegion is the <code>Region</code> that actually stores and
-   * replicates the <code>Session</code>s.
-   */
-  protected Region<String, HttpSession> sessionRegion;
-
-  /**
-   * The operatingRegion is the <code>Region</code> used to do HTTP operations.
-   * if local cache is enabled, then this will be the local <code>Region</code>;
-   * otherwise, it will be the session <code>Region</code>.
-   */
-  protected Region<String, HttpSession> operatingRegion;
-
-  protected Map<CacheProperty, Object> properties =
-      new TypeAwareMap<CacheProperty, Object>(CacheProperty.class);
-
-  protected DeltaSessionStatistics statistics;
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public void stop() {
-    sessionRegion.close();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public Region<String, HttpSession> getOperatingRegion() {
-    return this.operatingRegion;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public Region<String, HttpSession> getSessionRegion() {
-    return this.sessionRegion;
-  }
-
-  protected void createStatistics() {
-    this.statistics =
-        new DeltaSessionStatistics(getCache().getDistributedSystem(),
-            (String) properties.get(CacheProperty.STATISTICS_NAME));
-  }
-
-  /**
-   * Build up a {@code RegionConfiguraton} object from parameters originally
-   * passed in as filter initialization parameters.
-   *
-   * @return a {@code RegionConfiguration} object
-   */
-  protected RegionConfiguration createRegionConfiguration() {
-    RegionConfiguration configuration = new RegionConfiguration();
-
-    configuration.setRegionName(
-        (String) properties.get(CacheProperty.REGION_NAME));
-    configuration.setRegionAttributesId(
-        (String) properties.get(CacheProperty.REGION_ATTRIBUTES_ID));
-
-    configuration.setEnableGatewayDeltaReplication(
-        (Boolean) properties.get(
-            CacheProperty.ENABLE_GATEWAY_DELTA_REPLICATION));
-    configuration.setEnableGatewayReplication(
-        (Boolean) properties.get(CacheProperty.ENABLE_GATEWAY_REPLICATION));
-    configuration.setEnableDebugListener(
-        (Boolean) properties.get(CacheProperty.ENABLE_DEBUG_LISTENER));
-
-    return configuration;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/46eeb39c/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/common/CacheProperty.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/common/CacheProperty.java b/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/common/CacheProperty.java
deleted file mode 100644
index e26281e..0000000
--- a/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/common/CacheProperty.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*      http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-package com.gemstone.gemfire.modules.session.internal.common;
-
-/**
- * Used to define cache properties
- */
-public enum CacheProperty {
-
-  ENABLE_DEBUG_LISTENER(Boolean.class),
-
-  ENABLE_GATEWAY_REPLICATION(Boolean.class),
-
-  ENABLE_GATEWAY_DELTA_REPLICATION(Boolean.class),
-
-  ENABLE_LOCAL_CACHE(Boolean.class),
-
-  REGION_NAME(String.class),
-
-  REGION_ATTRIBUTES_ID(String.class),
-
-  STATISTICS_NAME(String.class),
-
-  /**
-   * This parameter can take the following values which match the respective
-   * attribute container classes
-   * <p/>
-   * delta_queued     : QueuedDeltaSessionAttributes delta_immediate  :
-   * DeltaSessionAttributes immediate        : ImmediateSessionAttributes queued
-   * : QueuedSessionAttributes
-   */
-  SESSION_DELTA_POLICY(String.class),
-
-  /**
-   * This parameter can take the following values:
-   * <p/>
-   * set (default) set_and_get
-   */
-  REPLICATION_TRIGGER(String.class);
-
-  Class clazz;
-
-  CacheProperty(Class clazz) {
-    this.clazz = clazz;
-  }
-
-  public Class getClazz() {
-    return clazz;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/46eeb39c/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/common/ClientServerSessionCache.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/common/ClientServerSessionCache.java b/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/common/ClientServerSessionCache.java
deleted file mode 100644
index a23888c..0000000
--- a/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/common/ClientServerSessionCache.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*      http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-package com.gemstone.gemfire.modules.session.internal.common;
-
-import com.gemstone.gemfire.cache.GemFireCache;
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.RegionShortcut;
-import com.gemstone.gemfire.cache.client.ClientCache;
-import com.gemstone.gemfire.cache.client.ClientRegionFactory;
-import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
-import com.gemstone.gemfire.cache.execute.Execution;
-import com.gemstone.gemfire.cache.execute.FunctionService;
-import com.gemstone.gemfire.cache.execute.ResultCollector;
-import com.gemstone.gemfire.modules.util.BootstrappingFunction;
-import com.gemstone.gemfire.modules.util.CreateRegionFunction;
-import com.gemstone.gemfire.modules.util.RegionConfiguration;
-import com.gemstone.gemfire.modules.util.RegionStatus;
-
-import java.util.List;
-import java.util.Map;
-import javax.servlet.http.HttpSession;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Class which defines a client/server cache.
- */
-public class ClientServerSessionCache extends AbstractSessionCache {
-
-  private static final Logger LOG =
-      LoggerFactory.getLogger(PeerToPeerSessionCache.class.getName());
-
-  private ClientCache cache;
-
-  protected static final String DEFAULT_REGION_ATTRIBUTES_ID =
-      RegionShortcut.PARTITION_REDUNDANT.toString();
-
-  protected static final Boolean DEFAULT_ENABLE_LOCAL_CACHE = true;
-
-  /**
-   * Constructor
-   *
-   * @param cache
-   * @param properties
-   */
-  public ClientServerSessionCache(ClientCache cache,
-      Map<CacheProperty, Object> properties) {
-    super();
-    this.cache = cache;
-
-    /**
-     * Set some default properties for this cache if they haven't already
-     * been set
-     */
-    this.properties.put(CacheProperty.REGION_ATTRIBUTES_ID,
-        DEFAULT_REGION_ATTRIBUTES_ID);
-    this.properties.put(CacheProperty.ENABLE_LOCAL_CACHE,
-        DEFAULT_ENABLE_LOCAL_CACHE);
-    this.properties.putAll(properties);
-  }
-
-  @Override
-  public void initialize() {
-    // Bootstrap the servers
-    bootstrapServers();
-
-    // Create or retrieve the region
-    createOrRetrieveRegion();
-
-    // Set the session region directly as the operating region since there is no difference
-    // between the local cache region and the session region.
-    operatingRegion = sessionRegion;
-
-    // Create or retrieve the statistics
-    createStatistics();
-  }
-
-  @Override
-  public GemFireCache getCache() {
-    return cache;
-  }
-
-  @Override
-  public boolean isClientServer() {
-    return true;
-  }
-
-
-  ////////////////////////////////////////////////////////////////////////
-  // Private methods
-
-  private void bootstrapServers() {
-    Execution execution = FunctionService.onServers(this.cache);
-    ResultCollector collector = execution.execute(new BootstrappingFunction());
-    // Get the result. Nothing is being done with it.
-    try {
-      collector.getResult();
-    } catch (Exception e) {
-      // If an exception occurs in the function, log it.
-      LOG.warn("Caught unexpected exception:", e);
-    }
-  }
-
-  private void createOrRetrieveRegion() {
-    // Retrieve the local session region
-    this.sessionRegion =
-        this.cache.getRegion(
-            (String) properties.get(CacheProperty.REGION_NAME));
-
-    // If necessary, create the regions on the server and client
-    if (this.sessionRegion == null) {
-      // Create the PR on the servers
-      createSessionRegionOnServers();
-
-      // Create the region on the client
-      this.sessionRegion = createLocalSessionRegion();
-      LOG.debug("Created session region: " + this.sessionRegion);
-    } else {
-      LOG.debug("Retrieved session region: " + this.sessionRegion);
-    }
-  }
-
-  private void createSessionRegionOnServers() {
-    // Create the RegionConfiguration
-    RegionConfiguration configuration = createRegionConfiguration();
-
-    // Send it to the server tier
-    Execution execution = FunctionService.onServer(this.cache).withArgs(
-        configuration);
-    ResultCollector collector = execution.execute(CreateRegionFunction.ID);
-
-    // Verify the region was successfully created on the servers
-    List<RegionStatus> results = (List<RegionStatus>) collector.getResult();
-    for (RegionStatus status : results) {
-      if (status == RegionStatus.INVALID) {
-        StringBuilder builder = new StringBuilder();
-        builder.append(
-            "An exception occurred on the server while attempting to create or validate region named ");
-        builder.append(properties.get(CacheProperty.REGION_NAME));
-        builder.append(". See the server log for additional details.");
-        throw new IllegalStateException(builder.toString());
-      }
-    }
-  }
-
-  private Region<String, HttpSession> createLocalSessionRegion() {
-    ClientRegionFactory<String, HttpSession> factory = null;
-    boolean enableLocalCache =
-        (Boolean) properties.get(CacheProperty.ENABLE_LOCAL_CACHE);
-
-    String regionName = (String) properties.get(CacheProperty.REGION_NAME);
-    if (enableLocalCache) {
-      // Create the region factory with caching and heap LRU enabled
-      factory = ((ClientCache) this.cache).
-          createClientRegionFactory(
-              ClientRegionShortcut.CACHING_PROXY_HEAP_LRU);
-      LOG.info("Created new local client session region: {}", regionName);
-    } else {
-      // Create the region factory without caching enabled
-      factory = ((ClientCache) this.cache).createClientRegionFactory(
-          ClientRegionShortcut.PROXY);
-      LOG.info(
-          "Created new local client (uncached) session region: {} without any session expiry",
-          regionName);
-    }
-
-    // Create the region
-    return factory.create(regionName);
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/46eeb39c/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/common/PeerToPeerSessionCache.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/common/PeerToPeerSessionCache.java b/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/common/PeerToPeerSessionCache.java
deleted file mode 100644
index 878adaa..0000000
--- a/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/common/PeerToPeerSessionCache.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*      http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-package com.gemstone.gemfire.modules.session.internal.common;
-
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.GemFireCache;
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.RegionFactory;
-import com.gemstone.gemfire.cache.RegionShortcut;
-import com.gemstone.gemfire.cache.execute.FunctionService;
-import com.gemstone.gemfire.modules.session.catalina.callback.LocalSessionCacheLoader;
-import com.gemstone.gemfire.modules.session.catalina.callback.LocalSessionCacheWriter;
-import com.gemstone.gemfire.modules.util.RegionConfiguration;
-import com.gemstone.gemfire.modules.util.RegionHelper;
-import com.gemstone.gemfire.modules.util.TouchPartitionedRegionEntriesFunction;
-import com.gemstone.gemfire.modules.util.TouchReplicatedRegionEntriesFunction;
-
-import java.util.Map;
-import javax.servlet.http.HttpSession;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Class which defines a peer-to-peer cache
- */
-public class PeerToPeerSessionCache extends AbstractSessionCache {
-
-  private static final Logger LOG =
-      LoggerFactory.getLogger(PeerToPeerSessionCache.class.getName());
-
-  private Cache cache;
-
-  private static final String DEFAULT_REGION_ATTRIBUTES_ID =
-      RegionShortcut.REPLICATE.toString();
-
-  private static final Boolean DEFAULT_ENABLE_LOCAL_CACHE = false;
-
-  /**
-   * Constructor
-   *
-   * @param cache
-   * @param properties
-   */
-  public PeerToPeerSessionCache(Cache cache,
-      Map<CacheProperty, Object> properties) {
-    super();
-    this.cache = cache;
-
-    /**
-     * Set some default properties for this cache if they haven't already
-     * been set
-     */
-    this.properties.put(CacheProperty.REGION_ATTRIBUTES_ID,
-        DEFAULT_REGION_ATTRIBUTES_ID);
-    this.properties.put(CacheProperty.ENABLE_LOCAL_CACHE,
-        DEFAULT_ENABLE_LOCAL_CACHE);
-    this.properties.putAll(properties);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public void initialize() {
-    // Register Functions
-    registerFunctions();
-
-    // Create or retrieve the region
-    createOrRetrieveRegion();
-
-    /**
-     * If local cache is enabled, create the local region fronting the
-     * session region and set it as the operating region; otherwise, use
-     * the session region directly as the operating region.
-     */
-    boolean enableLocalCache =
-        (Boolean) properties.get(CacheProperty.ENABLE_LOCAL_CACHE);
-    operatingRegion = enableLocalCache
-        ? createOrRetrieveLocalRegion()
-        : this.sessionRegion;
-
-    // Create or retrieve the statistics
-    createStatistics();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public GemFireCache getCache() {
-    return cache;
-  }
-
-  @Override
-  public boolean isClientServer() {
-    return false;
-  }
-
-  private void registerFunctions() {
-    // Register the touch partitioned region entries function if it is not already registered
-    if (!FunctionService.isRegistered(
-        TouchPartitionedRegionEntriesFunction.ID)) {
-      FunctionService.registerFunction(
-          new TouchPartitionedRegionEntriesFunction());
-    }
-
-    // Register the touch replicated region entries function if it is not already registered
-    if (!FunctionService.isRegistered(
-        TouchReplicatedRegionEntriesFunction.ID)) {
-      FunctionService.registerFunction(
-          new TouchReplicatedRegionEntriesFunction());
-    }
-  }
-
-  private void createOrRetrieveRegion() {
-    // Create the RegionConfiguration
-    RegionConfiguration configuration = createRegionConfiguration();
-
-    // Attempt to retrieve the region
-    // If it already exists, validate it
-    // If it doesn't already exist, create it
-    Region region = this.cache.getRegion(
-        (String) properties.get(CacheProperty.REGION_NAME));
-    if (region == null) {
-      // Create the region
-      region = RegionHelper.createRegion(cache, configuration);
-      LOG.info("Created new session region: {}", region);
-    } else {
-      // Validate the existing region
-      LOG.info("Retrieved existing session region: {}", region);
-      RegionHelper.validateRegion(cache, configuration, region);
-    }
-
-    // Set the session region
-    this.sessionRegion = region;
-  }
-
-  /**
-   * Create a local region fronting the main region.
-   *
-   * @return
-   */
-  private Region<String, HttpSession> createOrRetrieveLocalRegion() {
-    // Attempt to retrieve the fronting region
-    String frontingRegionName = this.sessionRegion.getName() + "_local";
-    Region<String, HttpSession> frontingRegion =
-        this.cache.getRegion(frontingRegionName);
-
-    if (frontingRegion == null) {
-      // Create the region factory
-      RegionFactory<String, HttpSession> factory =
-          this.cache.createRegionFactory(RegionShortcut.LOCAL_HEAP_LRU);
-
-      // Add the cache loader and writer
-      factory.setCacheLoader(new LocalSessionCacheLoader(this.sessionRegion));
-      factory.setCacheWriter(new LocalSessionCacheWriter(this.sessionRegion));
-
-      // Create the region
-      frontingRegion = factory.create(frontingRegionName);
-      LOG.info("Created new local session region: {}", frontingRegion);
-    } else {
-      LOG.info("Retrieved existing local session region: {}",
-          frontingRegion);
-    }
-
-    return frontingRegion;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/46eeb39c/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/common/SessionCache.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/common/SessionCache.java b/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/common/SessionCache.java
deleted file mode 100644
index 7562dff..0000000
--- a/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/common/SessionCache.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*      http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-package com.gemstone.gemfire.modules.session.internal.common;
-
-import com.gemstone.gemfire.cache.GemFireCache;
-import com.gemstone.gemfire.cache.Region;
-
-import javax.servlet.http.HttpSession;
-
-/**
- * Interface to basic cache operations.
- */
-public interface SessionCache {
-
-  /**
-   * Initialize the cache and create the appropriate region.
-   */
-  public void initialize();
-
-  /**
-   * Stop the cache.
-   */
-  public void stop();
-
-  /**
-   * Retrieve the cache reference.
-   *
-   * @return a {@code GemFireCache} reference
-   */
-  public GemFireCache getCache();
-
-  /**
-   * Get the {@code Region} being used by client code to put attributes.
-   *
-   * @return a {@code Region<String, HttpSession>} reference
-   */
-  public Region<String, HttpSession> getOperatingRegion();
-
-  /**
-   * Get the backing {@code Region} being used. This may not be the same as the
-   * region being used by client code to put attributes.
-   *
-   * @return a {@code Region<String, HttpSession>} reference
-   */
-  public Region<String, HttpSession> getSessionRegion();
-
-  /**
-   * Is this cache client-server? The only other alternative is peer-to-peer.
-   *
-   * @return true if this cache is client-server.
-   */
-  public boolean isClientServer();
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/46eeb39c/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/common/SessionExpirationCacheListener.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/common/SessionExpirationCacheListener.java b/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/common/SessionExpirationCacheListener.java
deleted file mode 100644
index 648e711..0000000
--- a/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/common/SessionExpirationCacheListener.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*      http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-package com.gemstone.gemfire.modules.session.internal.common;
-
-import com.gemstone.gemfire.cache.Declarable;
-import com.gemstone.gemfire.cache.EntryEvent;
-import com.gemstone.gemfire.cache.Operation;
-import com.gemstone.gemfire.cache.util.CacheListenerAdapter;
-
-import java.util.Properties;
-import javax.servlet.http.HttpSession;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SessionExpirationCacheListener extends
-    CacheListenerAdapter<String, HttpSession> implements Declarable {
-
-  private static final Logger LOG =
-      LoggerFactory.getLogger(SessionExpirationCacheListener.class.getName());
-
-  @Override
-  public void afterDestroy(EntryEvent<String, HttpSession> event) {
-    /**
-     * A Session expired. If it was destroyed by GemFire expiration,
-     * process it. If it was destroyed via Session.invalidate, ignore it
-     * since it has already been processed.
-     */
-    if (event.getOperation() == Operation.EXPIRE_DESTROY) {
-      HttpSession session = (HttpSession) event.getOldValue();
-      session.invalidate();
-    }
-  }
-
-  @Override
-  public void init(Properties p) {
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/46eeb39c/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/Constants.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/Constants.java b/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/Constants.java
deleted file mode 100644
index 4ce8733..0000000
--- a/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/Constants.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.gemstone.gemfire.modules.session.internal.filter;
-
-/**
- * Various constant values used through the app
- */
-public class Constants {
-
-  public static String GEMFIRE_SESSION_REQUEST = "_gemfire_session_request_";
-
-  public static String SESSION_STATISTICS_MBEAN_NAME =
-      "com.gemstone:type=SessionStatistics,name=sessionStatistics";
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/46eeb39c/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/DummySessionManager.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/DummySessionManager.java b/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/DummySessionManager.java
deleted file mode 100644
index 9628912..0000000
--- a/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/DummySessionManager.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*      http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-package com.gemstone.gemfire.modules.session.internal.filter;
-
-import com.gemstone.gemfire.modules.session.internal.filter.attributes.AbstractSessionAttributes;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-import javax.servlet.http.HttpSession;
-
-/**
- * Class which fakes an in-memory basic session manager for testing purposes.
- */
-public class DummySessionManager implements SessionManager {
-
-  /**
-   * Map of sessions
-   */
-  private final Map<String, HttpSession> sessions =
-      new HashMap<String, HttpSession>();
-
-  private class Attributes extends AbstractSessionAttributes {
-
-    @Override
-    public Object putAttribute(String attr, Object value) {
-      return attributes.put(attr, value);
-    }
-
-    @Override
-    public Object removeAttribute(String attr) {
-      return attributes.remove(attr);
-    }
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public void start(Object config, ClassLoader loader) {
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public void stop() {
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public HttpSession getSession(String id) {
-    return sessions.get(id);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public HttpSession wrapSession(HttpSession nativeSession) {
-    String id = generateId();
-    AbstractSessionAttributes attributes = new Attributes();
-    GemfireHttpSession session = new GemfireHttpSession(id, nativeSession);
-    session.setManager(this);
-    session.setAttributes(attributes);
-    sessions.put(id, session);
-
-    return session;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public HttpSession getWrappingSession(String nativeId) {
-    return sessions.get(nativeId);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public void putSession(HttpSession session) {
-    // shouldn't ever get called
-    throw new UnsupportedOperationException("Not supported yet.");
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public void destroySession(String id) {
-    sessions.remove(id);
-  }
-
-  @Override
-  public String destroyNativeSession(String id) {
-    return null;
-  }
-
-  public String getSessionCookieName() {
-    return "JSESSIONID";
-  }
-
-  public String getJvmId() {
-    return "jvm-id";
-  }
-
-  /**
-   * Generate an ID string
-   */
-  private String generateId() {
-    return UUID.randomUUID().toString().toUpperCase() + "-GF";
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/46eeb39c/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/GemfireHttpSession.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/GemfireHttpSession.java b/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/GemfireHttpSession.java
deleted file mode 100644
index 695a03b..0000000
--- a/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/GemfireHttpSession.java
+++ /dev/null
@@ -1,526 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*      http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-package com.gemstone.gemfire.modules.session.internal.filter;
-
-import com.gemstone.gemfire.DataSerializable;
-import com.gemstone.gemfire.DataSerializer;
-import com.gemstone.gemfire.Delta;
-import com.gemstone.gemfire.Instantiator;
-import com.gemstone.gemfire.InvalidDeltaException;
-import com.gemstone.gemfire.modules.session.internal.filter.attributes.AbstractSessionAttributes;
-import com.gemstone.gemfire.modules.session.internal.filter.attributes.SessionAttributes;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.concurrent.atomic.AtomicBoolean;
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpSession;
-import javax.servlet.http.HttpSessionContext;
-
-import com.gemstone.gemfire.modules.util.ClassLoaderObjectInputStream;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Class which implements a Gemfire persisted {@code HttpSession}
- */
-public class GemfireHttpSession implements
-    HttpSession, DataSerializable, Delta {
-
-  private static transient final Logger LOG =
-      LoggerFactory.getLogger(GemfireHttpSession.class.getName());
-
-  /**
-   * Serial id
-   */
-  private static final long serialVersionUID = 238915238964017823L;
-
-  /**
-   * Id for the session
-   */
-  private String id;
-
-  /**
-   * Attributes really hold the essence of persistence.
-   */
-  private SessionAttributes attributes;
-
-  private transient SessionManager manager;
-
-  private HttpSession nativeSession = null;
-
-  /**
-   * A session becomes invalid if it is explicitly invalidated or if it
-   * expires.
-   */
-  private boolean isValid = true;
-
-  private boolean isNew = true;
-
-  private boolean isDirty = false;
-
-  /**
-   * This is set during serialization and then reset by the SessionManager when
-   * it is retrieved from the attributes.
-   */
-  private AtomicBoolean serialized = new AtomicBoolean(false);
-
-  /**
-   * Register ourselves for de-serialization
-   */
-  static {
-    Instantiator.register(new Instantiator(GemfireHttpSession.class, 27315) {
-      @Override
-      public DataSerializable newInstance() {
-        return new GemfireHttpSession();
-      }
-    });
-  }
-
-  /**
-   * Constructor used for de-serialization
-   */
-  private GemfireHttpSession() {
-  }
-
-  /**
-   * Constructor
-   */
-  public GemfireHttpSession(String id, HttpSession nativeSession) {
-    this();
-    this.id = id;
-    this.nativeSession = nativeSession;
-    if (nativeSession != null) {
-      attributes.setMaxInactiveInterval(nativeSession.getMaxInactiveInterval());
-    }
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public Object getAttribute(String name) {
-    if (!isValid) {
-      throw new IllegalStateException("Session is already invalidated");
-    }
-    Object obj = attributes.getAttribute(name);
-
-    if (obj != null) {
-      Object tmpObj = null;
-      ClassLoader loader = ((GemfireSessionManager) manager).getReferenceClassLoader();
-
-      if (obj.getClass().getClassLoader() != loader) {
-        LOG.debug(
-            "Attribute '{}' needs to be reconstructed with a new classloader",
-            name);
-
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        try {
-          ObjectOutputStream oos = new ObjectOutputStream(baos);
-          oos.writeObject(obj);
-          oos.close();
-
-          ObjectInputStream ois = new ClassLoaderObjectInputStream(
-              new ByteArrayInputStream(baos.toByteArray()),
-              loader);
-          tmpObj = ois.readObject();
-        } catch (IOException e) {
-          LOG.error("Exception while recreating attribute '" + name +
-              "'", e);
-        } catch (ClassNotFoundException e) {
-          LOG.error("Exception while recreating attribute '" + name +
-              "'", e);
-        }
-        if (tmpObj != null) {
-          setAttribute(name, tmpObj);
-          obj = tmpObj;
-        }
-      }
-    }
-
-    return obj;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public Enumeration getAttributeNames() {
-    if (!isValid) {
-      throw new IllegalStateException("Session is already invalidated");
-    }
-    return Collections.enumeration(attributes.getAttributeNames());
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public long getCreationTime() {
-    if (nativeSession != null) {
-      return nativeSession.getCreationTime();
-    } else {
-      return 0;
-    }
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public String getId() {
-    return id;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public long getLastAccessedTime() {
-    if (!isValid) {
-      throw new IllegalStateException("Session is already invalidated");
-    }
-    return attributes.getLastAccessedTime();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public ServletContext getServletContext() {
-    if (nativeSession != null) {
-      return nativeSession.getServletContext();
-    } else {
-      return null;
-    }
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public HttpSessionContext getSessionContext() {
-    return null;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public Object getValue(String name) {
-    return getAttribute(name);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public String[] getValueNames() {
-    return attributes.getAttributeNames().toArray(new String[0]);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public void invalidate() {
-    nativeSession.invalidate();
-    manager.destroySession(id);
-    isValid = false;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public boolean isNew() {
-    if (!isValid) {
-      throw new IllegalStateException("Session is already invalidated");
-    }
-    return isNew;
-  }
-
-  public void setIsNew(boolean isNew) {
-    this.isNew = isNew;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public void setMaxInactiveInterval(int interval) {
-    if (nativeSession != null) {
-      nativeSession.setMaxInactiveInterval(interval);
-    }
-    attributes.setMaxInactiveInterval(interval);
-    isDirty = true;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public int getMaxInactiveInterval() {
-    if (nativeSession != null) {
-      return nativeSession.getMaxInactiveInterval();
-    } else {
-      return attributes.getMaxIntactiveInterval();
-    }
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public void putValue(String name, Object value) {
-    setAttribute(name, value);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public void removeAttribute(final String name) {
-    LOG.debug("Session {} removing attribute {}", getId(), name);
-    nativeSession.removeAttribute(name);
-    attributes.removeAttribute(name);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public void removeValue(String name) {
-    removeAttribute(name);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public void setAttribute(final String name, final Object value) {
-
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("Session {} setting attribute {} = '{}'",
-          new Object[]{id, name, value});
-    }
-
-    isDirty = true;
-    nativeSession.setAttribute(name, value);
-    if (value == null) {
-      removeAttribute(name);
-    } else {
-      attributes.putAttribute(name, value);
-    }
-  }
-
-  /**
-   * Gemfire serialization {@inheritDoc}
-   */
-  @Override
-  public void toData(DataOutput out) throws IOException {
-    DataSerializer.writeString(id, out);
-    DataSerializer.writeObject(attributes, out);
-  }
-
-  /**
-   * Gemfire de-serialization {@inheritDoc}
-   */
-  @Override
-  public void fromData(DataInput in) throws IOException,
-      ClassNotFoundException {
-    id = DataSerializer.readString(in);
-    attributes = DataSerializer.readObject(in);
-    if (getNativeSession() != null) {
-      for (String s : attributes.getAttributeNames()) {
-        getNativeSession().setAttribute(s, attributes.getAttribute(s));
-      }
-    }
-
-    // Explicit sets
-    serialized.set(true);
-    attributes.setSession(this);
-  }
-
-  /**
-   * These three methods handle delta propagation and are deferred to the
-   * attribute object.
-   */
-  @Override
-  public boolean hasDelta() {
-    return isDirty;
-  }
-
-  @Override
-  public void toDelta(DataOutput out) throws IOException {
-    if (attributes instanceof Delta) {
-      ((Delta) attributes).toDelta(out);
-    } else {
-      toData(out);
-    }
-  }
-
-  @Override
-  public void fromDelta(DataInput in) throws IOException,
-      InvalidDeltaException {
-    if (attributes instanceof Delta) {
-      ((Delta) attributes).fromDelta(in);
-    } else {
-      try {
-        fromData(in);
-      } catch (ClassNotFoundException cex) {
-        throw new IOException("Unable to forward fromDelta() call "
-            + "to fromData()", cex);
-      }
-    }
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder builder = new StringBuilder();
-    builder.append("[id=").append(id)
-        .append(", isNew=").append(isNew)
-        .append(", isValid=").append(isValid)
-        .append(", hasDelta=").append(hasDelta())
-        .append(", lastAccessedTime=").append(attributes.getLastAccessedTime())
-        .append(", jvmOwnerId=").append(attributes.getJvmOwnerId());
-    builder.append("]");
-    return builder.toString();
-  }
-
-  /**
-   * Flush the session object to the region
-   */
-  public void putInRegion() {
-
-    manager.putSession(this);
-    isDirty = false;
-  }
-
-  /**
-   * Determine whether the session is still valid or whether it has expired.
-   *
-   * @return true or false
-   */
-  public boolean isValid() {
-    if (!isValid) {
-      return false;
-    }
-    if (getMaxInactiveInterval() >= 0) {
-      long now = System.currentTimeMillis();
-      if (now - attributes.getLastAccessedTime() >= getMaxInactiveInterval() * 1000) {
-        return false;
-      }
-    }
-    return true;
-  }
-
-  /**
-   * Is this session dirty and should it be written to cache
-   */
-  public boolean isDirty() {
-    return isDirty;
-  }
-
-  public void setManager(SessionManager manager) {
-    this.manager = manager;
-  }
-
-  /**
-   * For testing allow retrieval of the wrapped, native session.
-   */
-  public HttpSession getNativeSession() {
-    return nativeSession;
-  }
-
-
-  public void setNativeSession(HttpSession session) {
-    this.nativeSession = session;
-  }
-
-  /**
-   * Handle the process of failing over the session to a new native session
-   * object.
-   *
-   * @param session
-   */
-  public void failoverSession(HttpSession session) {
-    LOG.debug("Failing over session {} to {}", getId(), session.getId());
-    setNativeSession(session);
-    for (String name : attributes.getAttributeNames()) {
-      LOG.debug("Copying '{}' => {}", name, attributes.getAttribute(name));
-      session.setAttribute(name, attributes.getAttribute(name));
-    }
-    session.setMaxInactiveInterval(attributes.getMaxIntactiveInterval());
-    manager.putSession(this);
-  }
-
-
-  /**
-   * Update the last accessed time
-   */
-  public void updateAccessTime() {
-    attributes.setLastAccessedTime(System.currentTimeMillis());
-  }
-
-  /**
-   * The {@code SessionManager} injects this when creating a new session.
-   *
-   * @param attributes
-   */
-  public void setAttributes(AbstractSessionAttributes attributes) {
-    this.attributes = attributes;
-  }
-
-  /**
-   * This is called on deserialization. You can only call it once to get a
-   * meaningful value as it resets the serialized state. In other words, this
-   * call is not idempotent.
-   *
-   * @return whether this object has just been serialized
-   */
-  public boolean justSerialized() {
-    return serialized.getAndSet(false);
-  }
-
-  /**
-   * Called when the session is about to go out of scope. If the session has
-   * been defined to use async queued attributes then they will be written out
-   * at this point.
-   */
-  public void commit() {
-    attributes.setJvmOwnerId(manager.getJvmId());
-    attributes.flush();
-  }
-
-  public String getJvmOwnerId() {
-    if (attributes != null) {
-      return attributes.getJvmOwnerId();
-    }
-
-    return null;
-  }
-}
-



Mime
View raw message