Return-Path: X-Original-To: apmail-geode-commits-archive@minotaur.apache.org Delivered-To: apmail-geode-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 599921840E for ; Wed, 17 Feb 2016 18:24:37 +0000 (UTC) Received: (qmail 44289 invoked by uid 500); 17 Feb 2016 18:24:31 -0000 Delivered-To: apmail-geode-commits-archive@geode.apache.org Received: (qmail 44259 invoked by uid 500); 17 Feb 2016 18:24:31 -0000 Mailing-List: contact commits-help@geode.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.incubator.apache.org Delivered-To: mailing list commits@geode.incubator.apache.org Received: (qmail 44250 invoked by uid 99); 17 Feb 2016 18:24:31 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Feb 2016 18:24:31 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 6BB43C0D80 for ; Wed, 17 Feb 2016 18:24:30 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -3.549 X-Spam-Level: X-Spam-Status: No, score=-3.549 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.329] autolearn=disabled Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id oJ2bz81kSIJL for ; Wed, 17 Feb 2016 18:23:41 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with SMTP id 381BE60DDF for ; Wed, 17 Feb 2016 18:23:08 +0000 (UTC) Received: (qmail 32243 invoked by uid 99); 17 Feb 2016 18:23:06 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Feb 2016 18:23:06 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 6BCB9E112B; Wed, 17 Feb 2016 18:23:06 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: abaker@apache.org To: commits@geode.incubator.apache.org Date: Wed, 17 Feb 2016 18:23:50 -0000 Message-Id: <5ae96ae5adfc4cf0b18d852f143e79b8@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [46/51] [partial] incubator-geode git commit: GEODE-917: rename gemfire subprojects to geode http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/GemfireSessionException.java ---------------------------------------------------------------------- diff --git a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/GemfireSessionException.java b/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/GemfireSessionException.java deleted file mode 100644 index 3ce81be..0000000 --- a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/GemfireSessionException.java +++ /dev/null @@ -1,41 +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; - -/** - * Exception class for Gemfire Session Cache specific exceptions. - */ -public class GemfireSessionException extends Exception { - - public GemfireSessionException() { - super(); - } - - public GemfireSessionException(String message) { - super(message); - } - - public GemfireSessionException(String message, Throwable cause) { - super(message, cause); - } - - public GemfireSessionException(Throwable cause) { - super(cause); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/GemfireSessionManager.java ---------------------------------------------------------------------- diff --git a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/GemfireSessionManager.java b/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/GemfireSessionManager.java deleted file mode 100644 index a3d3c10..0000000 --- a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/GemfireSessionManager.java +++ /dev/null @@ -1,511 +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.cache.CacheClosedException; -import com.gemstone.gemfire.cache.CacheFactory; -import com.gemstone.gemfire.cache.EntryNotFoundException; -import com.gemstone.gemfire.cache.control.ResourceManager; -import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; -import com.gemstone.gemfire.modules.session.bootstrap.AbstractCache; -import com.gemstone.gemfire.modules.session.bootstrap.ClientServerCache; -import com.gemstone.gemfire.modules.session.bootstrap.LifecycleTypeAdapter; -import com.gemstone.gemfire.modules.session.bootstrap.PeerToPeerCache; -import com.gemstone.gemfire.modules.session.internal.common.CacheProperty; -import com.gemstone.gemfire.modules.session.internal.common.ClientServerSessionCache; -import com.gemstone.gemfire.modules.session.internal.common.PeerToPeerSessionCache; -import com.gemstone.gemfire.modules.session.internal.common.SessionCache; -import com.gemstone.gemfire.modules.session.internal.filter.attributes.AbstractSessionAttributes; -import com.gemstone.gemfire.modules.session.internal.filter.attributes.DeltaQueuedSessionAttributes; -import com.gemstone.gemfire.modules.session.internal.filter.attributes.DeltaSessionAttributes; -import com.gemstone.gemfire.modules.session.internal.filter.attributes.ImmediateSessionAttributes; -import com.gemstone.gemfire.modules.session.internal.filter.util.TypeAwareMap; -import com.gemstone.gemfire.modules.session.internal.jmx.SessionStatistics; -import com.gemstone.gemfire.modules.util.RegionHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.management.MBeanServer; -import javax.management.ObjectName; -import javax.naming.InitialContext; -import javax.servlet.FilterConfig; -import javax.servlet.http.HttpSession; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -/** - * This class implements the session management using a Gemfire distributedCache - * as a persistent store for the session objects - */ -public class GemfireSessionManager implements SessionManager { - - private final Logger LOG; - - /** - * Prefix of init param string used to set gemfire properties - */ - private static final String GEMFIRE_PROPERTY = "gemfire.property."; - - /** - * Prefix of init param string used to set gemfire distributedCache setting - */ - private static final String GEMFIRE_CACHE = "gemfire.cache."; - - private static final String INIT_PARAM_CACHE_TYPE = "cache-type"; - private static final String CACHE_TYPE_CLIENT_SERVER = "client-server"; - private static final String CACHE_TYPE_PEER_TO_PEER = "peer-to-peer"; - private static final String INIT_PARAM_SESSION_COOKIE_NAME = "session-cookie-name"; - private static final String INIT_PARAM_JVM_ID = "jvm-id"; - private static final String DEFAULT_JVM_ID = "default"; - - private SessionCache sessionCache = null; - - /** - * Reference to the distributed system - */ - private AbstractCache distributedCache = null; - - /** - * Boolean indicating whether the manager is shutting down - */ - private boolean isStopping = false; - - /** - * Boolean indicating whether this manager is defined in the same context (war - * / classloader) as the filter. - */ - private boolean isolated = false; - - /** - * Map of wrapping GemFire session id to native session id - */ - private Map nativeSessionMap = - new HashMap(); - - /** - * MBean for statistics - */ - private SessionStatistics mbean; - - /** - * This CL is used to compare against the class loader of attributes getting - * pulled out of the cache. This variable should be set to the CL of the - * filter running everything. - */ - private ClassLoader referenceClassLoader; - - private String sessionCookieName = "JSESSIONID"; - - /** - * Give this JVM a unique identifier. - */ - private String jvmId = "default"; - - /** - * Set up properties with default values - */ - private TypeAwareMap properties = - new TypeAwareMap(CacheProperty.class) {{ - put(CacheProperty.REGION_NAME, RegionHelper.NAME + "_sessions"); - put(CacheProperty.ENABLE_GATEWAY_DELTA_REPLICATION, Boolean.FALSE); - put(CacheProperty.ENABLE_GATEWAY_REPLICATION, Boolean.FALSE); - put(CacheProperty.ENABLE_DEBUG_LISTENER, Boolean.FALSE); - put(CacheProperty.STATISTICS_NAME, "gemfire_statistics"); - put(CacheProperty.SESSION_DELTA_POLICY, "delta_queued"); - put(CacheProperty.REPLICATION_TRIGGER, "set"); - /** - * For REGION_ATTRIBUTES_ID and ENABLE_LOCAL_CACHE the default - * is different for ClientServerCache and PeerToPeerCache - * so those values are set in the relevant constructors when - * these properties are passed in to them. - */ - }}; - - public GemfireSessionManager() { - LOG = LoggerFactory.getLogger(GemfireSessionManager.class.getName()); - } - - /** - * {@inheritDoc} - */ - @Override - public void start(Object conf, ClassLoader loader) { - this.referenceClassLoader = loader; - FilterConfig config = (FilterConfig) conf; - - startDistributedSystem(config); - initializeSessionCache(config); - - // Register MBean - registerMBean(); - - if (distributedCache.getClass().getClassLoader() == loader) { - isolated = true; - } - - String sessionCookieName = config.getInitParameter( - INIT_PARAM_SESSION_COOKIE_NAME); - if (sessionCookieName != null && !sessionCookieName.isEmpty()) { - this.sessionCookieName = sessionCookieName; - LOG.info("Session cookie name set to: {}", this.sessionCookieName); - } - - jvmId = config.getInitParameter(INIT_PARAM_JVM_ID); - if (jvmId == null || jvmId.isEmpty()) { - jvmId = DEFAULT_JVM_ID; - } - - LOG.info("Started GemfireSessionManager (isolated={}, jvmId={})", - isolated, jvmId); - } - - /** - * {@inheritDoc} - */ - @Override - public void stop() { - isStopping = true; - - if (isolated) { - if (distributedCache != null) { - LOG.info("Closing distributed cache - assuming isolated cache"); - distributedCache.close(); - } - } else { - LOG.info("Not closing distributed cache - assuming common cache"); - } - } - - /** - * {@inheritDoc} - */ - @Override - public HttpSession getSession(String id) { - GemfireHttpSession session = (GemfireHttpSession) sessionCache.getOperatingRegion().get( - id); - - if (session != null) { - if (session.justSerialized()) { - session.setManager(this); - LOG.debug("Recovered serialized session {} (jvmId={})", id, - session.getJvmOwnerId()); - } - LOG.debug("Retrieved session id {}", id); - } else { - LOG.debug("Session id {} not found", id); - } - return session; - } - - /** - * {@inheritDoc} - */ - @Override - public HttpSession wrapSession(HttpSession nativeSession) { - String id = generateId(); - GemfireHttpSession session = - new GemfireHttpSession(id, nativeSession); - - /** - * Set up the attribute container depending on how things are configured - */ - AbstractSessionAttributes attributes; - if ("delta_queued".equals( - properties.get(CacheProperty.SESSION_DELTA_POLICY))) { - attributes = new DeltaQueuedSessionAttributes(); - ((DeltaQueuedSessionAttributes) attributes).setReplicationTrigger( - (String) properties.get(CacheProperty.REPLICATION_TRIGGER)); - } else if ("delta_immediate".equals( - properties.get(CacheProperty.SESSION_DELTA_POLICY))) { - attributes = new DeltaSessionAttributes(); - } else if ("immediate".equals( - properties.get(CacheProperty.SESSION_DELTA_POLICY))) { - attributes = new ImmediateSessionAttributes(); - } else { - attributes = new DeltaSessionAttributes(); - LOG.warn( - "No session delta policy specified - using default of 'delta_immediate'"); - } - - attributes.setSession(session); - attributes.setJvmOwnerId(jvmId); - - session.setManager(this); - session.setAttributes(attributes); - - LOG.debug("Creating new session {}", id); - sessionCache.getOperatingRegion().put(id, session); - - mbean.incActiveSessions(); - - return session; - } - - /** - * {@inheritDoc} - */ - public HttpSession getWrappingSession(String nativeId) { - HttpSession session = null; - String gemfireId = getGemfireSessionIdFromNativeId(nativeId); - - if (gemfireId != null) { - session = getSession(gemfireId); - } - return session; - } - - /** - * {@inheritDoc} - */ - @Override - public void destroySession(String id) { - if (!isStopping) { - try { - GemfireHttpSession session = (GemfireHttpSession) sessionCache.getOperatingRegion().get( - id); - if (session != null && session.getJvmOwnerId().equals(jvmId)) { - LOG.debug("Destroying session {}", id); - sessionCache.getOperatingRegion().destroy(id); - mbean.decActiveSessions(); - } - } catch (EntryNotFoundException nex) { - } - } else { - if (sessionCache.isClientServer()) { - LOG.debug("Destroying session {}", id); - try { - sessionCache.getOperatingRegion().localDestroy(id); - } catch (EntryNotFoundException nex) { - // Ignored - } catch (CacheClosedException ccex) { - // Ignored - } - } else { - GemfireHttpSession session = (GemfireHttpSession) sessionCache.getOperatingRegion().get( - id); - if (session != null) { - session.setNativeSession(null); - } - } - } - - synchronized (nativeSessionMap) { - String nativeId = nativeSessionMap.remove(id); - LOG.debug("destroySession called for {} wrapping {}", id, nativeId); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void putSession(HttpSession session) { - sessionCache.getOperatingRegion().put(session.getId(), session); - mbean.incRegionUpdates(); - nativeSessionMap.put(session.getId(), - ((GemfireHttpSession) session).getNativeSession().getId()); - } - - @Override - public String destroyNativeSession(String nativeId) { - String gemfireSessionId = getGemfireSessionIdFromNativeId(nativeId); - if (gemfireSessionId != null) { - destroySession(gemfireSessionId); - } - return gemfireSessionId; - } - - public ClassLoader getReferenceClassLoader() { - return referenceClassLoader; - } - - /** - * This method is called when a native session gets destroyed. It will check - * if the GemFire session is actually still valid/not expired and will then - * attach a new, native session. - * - * @param nativeId the id of the native session - * @return the id of the newly attached native session or null if the GemFire - * session was already invalid - */ - public String refreshSession(String nativeId) { - String gemfireId = getGemfireSessionIdFromNativeId(nativeId); - if (gemfireId == null) { - return null; - } - - GemfireHttpSession session = (GemfireHttpSession) sessionCache.getOperatingRegion().get( - gemfireId); - if (session.isValid()) { - - } - - return null; - } - - public String getSessionCookieName() { - return sessionCookieName; - } - - public String getJvmId() { - return jvmId; - } - - - /////////////////////////////////////////////////////////////////////// - // Private methods - - private String getGemfireSessionIdFromNativeId(String nativeId) { - if (nativeId == null) { - return null; - } - - for (Map.Entry e : nativeSessionMap.entrySet()) { - if (nativeId.equals(e.getValue())) { - return e.getKey(); - } - } - return null; - } - - /** - * Start the underlying distributed system - * - * @param config - */ - private void startDistributedSystem(FilterConfig config) { - // Get the distributedCache type - final String cacheType = config.getInitParameter(INIT_PARAM_CACHE_TYPE); - if (CACHE_TYPE_CLIENT_SERVER.equals(cacheType)) { - distributedCache = ClientServerCache.getInstance(); - } else if (CACHE_TYPE_PEER_TO_PEER.equals(cacheType)) { - distributedCache = PeerToPeerCache.getInstance(); - } else { - LOG.error("No 'cache-type' initialization param set. " - + "Cache will not be started"); - return; - } - - if (!distributedCache.isStarted()) { - /** - * Process all the init params and see if any apply to the - * distributed system. - */ - for (Enumeration e = config.getInitParameterNames(); e.hasMoreElements(); ) { - String param = e.nextElement(); - if (!param.startsWith(GEMFIRE_PROPERTY)) { - continue; - } - - String gemfireProperty = param.substring(GEMFIRE_PROPERTY.length()); - LOG.info("Setting gemfire property: {} = {}", - gemfireProperty, config.getInitParameter(param)); - distributedCache.setProperty(gemfireProperty, - config.getInitParameter(param)); - } - - distributedCache.lifecycleEvent(LifecycleTypeAdapter.START); - } - } - - /** - * Initialize the distributedCache - */ - private void initializeSessionCache(FilterConfig config) { - // Retrieve the distributedCache - GemFireCacheImpl cache = (GemFireCacheImpl) CacheFactory.getAnyInstance(); - if (cache == null) { - throw new IllegalStateException("No cache exists. Please configure " - + "either a PeerToPeerCacheLifecycleListener or " - + "ClientServerCacheLifecycleListener in the " - + "server.xml file."); - } - - /** - * Process all the init params and see if any apply to the distributedCache - */ - ResourceManager rm = cache.getResourceManager(); - for (Enumeration e = config.getInitParameterNames(); e.hasMoreElements(); ) { - String param = e.nextElement(); - - // Uggh - don't like this non-generic stuff - if (param.equalsIgnoreCase("criticalHeapPercentage")) { - float val = Float.parseFloat(config.getInitParameter(param)); - rm.setCriticalHeapPercentage(val); - } - - if (param.equalsIgnoreCase("evictionHeapPercentage")) { - float val = Float.parseFloat(config.getInitParameter(param)); - rm.setEvictionHeapPercentage(val); - } - - - if (!param.startsWith(GEMFIRE_CACHE)) { - continue; - } - - String gemfireWebParam = param.substring(GEMFIRE_CACHE.length()); - LOG.info("Setting cache parameter: {} = {}", - gemfireWebParam, config.getInitParameter(param)); - properties.put(CacheProperty.valueOf(gemfireWebParam.toUpperCase()), - config.getInitParameter(param)); - } - - // Create the appropriate session distributedCache - sessionCache = cache.isClient() - ? new ClientServerSessionCache(cache, properties) - : new PeerToPeerSessionCache(cache, properties); - - // Initialize the session distributedCache - sessionCache.initialize(); - } - - /** - * Register a bean for statistic gathering purposes - */ - private void registerMBean() { - mbean = new SessionStatistics(); - - try { - InitialContext ctx = new InitialContext(); - MBeanServer mbs = MBeanServer.class.cast( - ctx.lookup("java:comp/env/jmx/runtime")); - ObjectName oname = new ObjectName( - Constants.SESSION_STATISTICS_MBEAN_NAME); - - mbs.registerMBean(mbean, oname); - } catch (Exception ex) { - LOG.warn("Unable to register statistics MBean. Error: {}", - ex.getMessage()); - } - } - - - /** - * Generate an ID string - */ - private String generateId() { - return UUID.randomUUID().toString().toUpperCase() + "-GF"; - } - - AbstractCache getCache() { - return distributedCache; - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/ListenerEventType.java ---------------------------------------------------------------------- diff --git a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/ListenerEventType.java b/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/ListenerEventType.java deleted file mode 100644 index b040dda..0000000 --- a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/ListenerEventType.java +++ /dev/null @@ -1,75 +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; - -/** - * Enumeration of all possible event types which can be listened for. - */ -public enum ListenerEventType { - - /** - * HttpSessionAttributeListener - */ - SESSION_ATTRIBUTE_ADDED, - SESSION_ATTRIBUTE_REMOVED, - SESSION_ATTRIBUTE_REPLACED, - - /** - * HttpSessionBindingListener - */ - SESSION_VALUE_BOUND, - SESSION_VALUE_UNBOUND, - - /** - * HttpSessionListener - */ - SESSION_CREATED, - SESSION_DESTROYED, - - /** - * HttpSessionActivationListener - */ - SESSION_WILL_ACTIVATE, - SESSION_DID_PASSIVATE, - - /** - * ServletContextListener - */ - SERVLET_CONTEXT_INITIALIZED, - SERVLET_CONTEXT_DESTROYED, - - /** - * ServletContextAttributeListener - */ - SERVLET_CONTEXT_ATTRIBUTE_ADDED, - SERVLET_CONTEXT_ATTRIBUTE_REMOVED, - SERVLET_CONTEXT_ATTRIBUTE_REPLACED, - - /** - * ServletRequestListener - */ - SERVLET_REQUEST_DESTROYED, - SERVLET_REQUEST_INITIALIZED, - - /** - * ServletRequestAttributeListener - */ - SERVLET_REQUEST_ATTRIBUTE_ADDED, - SERVLET_REQUEST_ATTRIBUTE_REMOVED, - SERVLET_REQUEST_ATTRIBUTE_REPLACED; -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/SessionManager.java ---------------------------------------------------------------------- diff --git a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/SessionManager.java b/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/SessionManager.java deleted file mode 100644 index 9d8996c..0000000 --- a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/SessionManager.java +++ /dev/null @@ -1,110 +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 javax.servlet.http.HttpSession; - -/** - * Interface to session management. This class would be responsible for creating - * new sessions. - */ -public interface SessionManager { - - /** - * Start the manager possibly using the config passed in. - * - * @param config Config object specific to individual implementations. - * @param loader This is a hack. When the manager is started it wants to be - * able to determine if the cache, which it would create, and - * the filter which starts everything, are defined by the same - * classloader. This is so that during shutdown, the manager can - * decide whether or not to also stop the cache. This option - * allows the filter's classloader to be passed in. - */ - public void start(Object config, ClassLoader loader); - - /** - * Stop the session manager and free up any resources. - */ - public void stop(); - - /** - * Write the session to the region - * - * @param session the session to write - */ - public void putSession(HttpSession session); - - /** - * Return a session if it exists or null otherwise - * - * @param id The session id to attempt to retrieve - * @return a HttpSession object if a session was found otherwise null. - */ - public HttpSession getSession(String id); - - /** - * Create a new session, wrapping a container session. - * - * @param nativeSession - * @return the HttpSession object - */ - public HttpSession wrapSession(HttpSession nativeSession); - - /** - * Get the wrapped (GemFire) session from a native session id. This method - * would typically be used from within session/http event listeners which - * receive the original session id. - * - * @param nativeId - * @return the wrapped GemFire session which maps the native session - */ - public HttpSession getWrappingSession(String nativeId); - - /** - * Destroy the session associated with the given id. - * - * @param id The id of the session to destroy. - */ - public void destroySession(String id); - - /** - * Destroy the session associated with a given native session - * - * @param id the id of the native session - * @return the corresponding Gemfire session which wrapped the native session - * and was destroyed. - */ - public String destroyNativeSession(String id); - - /** - * Returns the cookie name used to hold the session id. By default this is - * JSESSIONID. - * - * @return the name of the cookie which contains the session id - */ - public String getSessionCookieName(); - - /** - * Get the JVM Id - this is a unique string used internally to identify who - * last touched a session. - * - * @return the jvm id - */ - public String getJvmId(); -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/AbstractDeltaSessionAttributes.java ---------------------------------------------------------------------- diff --git a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/AbstractDeltaSessionAttributes.java b/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/AbstractDeltaSessionAttributes.java deleted file mode 100644 index f46495d..0000000 --- a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/AbstractDeltaSessionAttributes.java +++ /dev/null @@ -1,107 +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.attributes; - -import com.gemstone.gemfire.DataSerializer; -import com.gemstone.gemfire.Delta; -import com.gemstone.gemfire.InvalidDeltaException; - -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 org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * This abstract class contains the structures and methods to handle delta - * updates to attributes. - */ -public abstract class AbstractDeltaSessionAttributes - extends AbstractSessionAttributes implements Delta { - - private static final Logger LOG = - LoggerFactory.getLogger(AbstractDeltaSessionAttributes.class.getName()); - - /** - * This map holds the updates to attributes - */ - protected transient Map deltas = - Collections.synchronizedMap(new HashMap()); - - @Override - public boolean hasDelta() { - return true; - } - - @Override - public void toDelta(DataOutput out) throws IOException { - out.writeInt(maxInactiveInterval); - out.writeLong(lastAccessedTime); - - synchronized (deltas) { - DataSerializer.writeInteger(deltas.size(), out); - for (Map.Entry e : deltas.entrySet()) { - DataSerializer.writeString(e.getKey(), out); - DataSerializer.writeObject(e.getValue(), out); - } - deltas.clear(); - } - - out.writeUTF(jvmOwnerId); - } - - @Override - public void fromDelta(DataInput in) - throws IOException, InvalidDeltaException { - maxInactiveInterval = in.readInt(); - lastAccessedTime = in.readLong(); - Map localDeltas = new HashMap(); - try { - int size = DataSerializer.readInteger(in); - for (int i = 0; i < size; i++) { - String key = DataSerializer.readString(in); - DeltaEvent evt = DataSerializer.readObject(in); - localDeltas.put(key, evt); - } - } catch (ClassNotFoundException ex) { - LOG.error("Unable to de-serialize delta events", ex); - return; - } - - LOG.debug("Processing {} delta events for {}", - localDeltas.size(), session); - for (DeltaEvent e : localDeltas.values()) { - if (e.isUpdate()) { - attributes.put(e.getName(), e.getValue()); - if (session.getNativeSession() != null) { - session.getNativeSession().setAttribute(e.getName(), e.getValue()); - } - } else { - attributes.remove(e.getName()); - if (session.getNativeSession() != null) { - session.getNativeSession().setAttribute(e.getName(), null); - } - } - } - jvmOwnerId = in.readUTF(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/AbstractSessionAttributes.java ---------------------------------------------------------------------- diff --git a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/AbstractSessionAttributes.java b/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/AbstractSessionAttributes.java deleted file mode 100644 index c4af041..0000000 --- a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/AbstractSessionAttributes.java +++ /dev/null @@ -1,188 +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.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 attributes = - Collections.synchronizedMap(new HashMap()); - - /** - * 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 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 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/f6c4c2f9/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/DeltaEvent.java ---------------------------------------------------------------------- diff --git a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/DeltaEvent.java b/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/DeltaEvent.java deleted file mode 100644 index 4c248dd..0000000 --- a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/DeltaEvent.java +++ /dev/null @@ -1,119 +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.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/f6c4c2f9/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/DeltaQueuedSessionAttributes.java ---------------------------------------------------------------------- diff --git a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/DeltaQueuedSessionAttributes.java b/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/DeltaQueuedSessionAttributes.java deleted file mode 100644 index cb4f673..0000000 --- a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/DeltaQueuedSessionAttributes.java +++ /dev/null @@ -1,94 +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.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/f6c4c2f9/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/DeltaSessionAttributes.java ---------------------------------------------------------------------- diff --git a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/DeltaSessionAttributes.java b/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/DeltaSessionAttributes.java deleted file mode 100644 index 8cc9866..0000000 --- a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/DeltaSessionAttributes.java +++ /dev/null @@ -1,75 +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.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/f6c4c2f9/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/ImmediateSessionAttributes.java ---------------------------------------------------------------------- diff --git a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/ImmediateSessionAttributes.java b/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/ImmediateSessionAttributes.java deleted file mode 100644 index 15936ba..0000000 --- a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/ImmediateSessionAttributes.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.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/f6c4c2f9/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/QueuedSessionAttributes.java ---------------------------------------------------------------------- diff --git a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/QueuedSessionAttributes.java b/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/QueuedSessionAttributes.java deleted file mode 100644 index 8d20b43..0000000 --- a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/QueuedSessionAttributes.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.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/f6c4c2f9/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/SessionAttributes.java ---------------------------------------------------------------------- diff --git a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/SessionAttributes.java b/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/SessionAttributes.java deleted file mode 100644 index b3b0cef..0000000 --- a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/attributes/SessionAttributes.java +++ /dev/null @@ -1,120 +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.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 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/f6c4c2f9/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/util/NamedThreadFactory.java ---------------------------------------------------------------------- diff --git a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/util/NamedThreadFactory.java b/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/util/NamedThreadFactory.java deleted file mode 100644 index 7491cf0..0000000 --- a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/util/NamedThreadFactory.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.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} - *

- * 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/f6c4c2f9/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/util/ThreadLocalSession.java ---------------------------------------------------------------------- diff --git a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/util/ThreadLocalSession.java b/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/util/ThreadLocalSession.java deleted file mode 100644 index 996b1fd..0000000 --- a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/util/ThreadLocalSession.java +++ /dev/null @@ -1,39 +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.util; - -import javax.servlet.http.HttpSession; - -/** - */ -public class ThreadLocalSession { - private static ThreadLocal threadLocal = - new ThreadLocal(); - - 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/f6c4c2f9/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/util/TypeAwareMap.java ---------------------------------------------------------------------- diff --git a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/util/TypeAwareMap.java b/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/util/TypeAwareMap.java deleted file mode 100644 index 705bafd..0000000 --- a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/util/TypeAwareMap.java +++ /dev/null @@ -1,50 +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.util; - -import com.gemstone.gemfire.modules.session.internal.common.CacheProperty; - -import java.util.HashMap; - -/** - * - */ -public class TypeAwareMap extends HashMap { - - private Class keyType; - - public TypeAwareMap(Class 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/f6c4c2f9/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/jmx/SessionStatistics.java ---------------------------------------------------------------------- diff --git a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/jmx/SessionStatistics.java b/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/jmx/SessionStatistics.java deleted file mode 100644 index 9f945da..0000000 --- a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/jmx/SessionStatistics.java +++ /dev/null @@ -1,78 +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.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/f6c4c2f9/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/jmx/SessionStatisticsMXBean.java ---------------------------------------------------------------------- diff --git a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/jmx/SessionStatisticsMXBean.java b/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/jmx/SessionStatisticsMXBean.java deleted file mode 100644 index 33cfc3e..0000000 --- a/extensions/gemfire-modules-session/src/main/java/com/gemstone/gemfire/modules/session/internal/jmx/SessionStatisticsMXBean.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.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/f6c4c2f9/extensions/gemfire-modules-session/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/AbstractListener.java ---------------------------------------------------------------------- diff --git a/extensions/gemfire-modules-session/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/AbstractListener.java b/extensions/gemfire-modules-session/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/AbstractListener.java deleted file mode 100644 index 0bca895..0000000 --- a/extensions/gemfire-modules-session/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/AbstractListener.java +++ /dev/null @@ -1,57 +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 java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -/** - * @author jdeppe - */ -public abstract class AbstractListener { - - protected final List events = - new ArrayList(); - - protected CountDownLatch latch; - - public AbstractListener() { - this(1); - } - - public AbstractListener(int numCalls) { - latch = new CountDownLatch(numCalls); - RendezvousManager.registerListener(this); - } - - public synchronized void setLatch(int numCalls) { - latch = new CountDownLatch(numCalls); - events.clear(); - } - - public boolean await(long timeout, - TimeUnit unit) throws InterruptedException { - return latch.await(timeout, unit); - } - - public List getEvents() { - return events; - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/gemfire-modules-session/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/BasicServlet.java ---------------------------------------------------------------------- diff --git a/extensions/gemfire-modules-session/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/BasicServlet.java b/extensions/gemfire-modules-session/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/BasicServlet.java deleted file mode 100644 index 5804317..0000000 --- a/extensions/gemfire-modules-session/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/BasicServlet.java +++ /dev/null @@ -1,52 +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 java.io.IOException; -import javax.servlet.ServletConfig; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.eclipse.jetty.servlet.DefaultServlet; -/** - * - */ -public class BasicServlet extends DefaultServlet { - - Callback callback = null; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - - if (callback != null) { - callback.call(request, response); - } - } - - @Override - public void init(ServletConfig config) throws ServletException { - super.init(config); - ServletContext context = config.getServletContext(); - - String cbInitParam = config.getInitParameter("test.callback"); - callback = (Callback) context.getAttribute(cbInitParam); - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/gemfire-modules-session/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/Callback.java ---------------------------------------------------------------------- diff --git a/extensions/gemfire-modules-session/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/Callback.java b/extensions/gemfire-modules-session/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/Callback.java deleted file mode 100644 index fa5b64f..0000000 --- a/extensions/gemfire-modules-session/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/Callback.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; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - * Interface which, when implemented, can be put into a servlet context and executed by the servlet. - */ -public interface Callback { - void call(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException; -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/gemfire-modules-session/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/CallbackServlet.java ---------------------------------------------------------------------- diff --git a/extensions/gemfire-modules-session/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/CallbackServlet.java b/extensions/gemfire-modules-session/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/CallbackServlet.java deleted file mode 100644 index 3050280..0000000 --- a/extensions/gemfire-modules-session/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/CallbackServlet.java +++ /dev/null @@ -1,91 +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 java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -public class CallbackServlet extends HttpServlet { - - private Callback callback; - - /** - * Processes requests for both HTTP GET and POST - * methods. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - protected void processRequest(HttpServletRequest request, - HttpServletResponse response) - throws ServletException, IOException { - - if (callback != null) { - callback.call(request, response); - } - } - - public void setCallback(Callback callback) { - this.callback = callback; - } - - /** - * Handles the HTTP GET method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - processRequest(request, response); - } - - /** - * Handles the HTTP POST method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doPost(HttpServletRequest request, - HttpServletResponse response) - throws ServletException, IOException { - processRequest(request, response); - } - - /** - * Returns a short description of the servlet. - * - * @return a String containing servlet description - */ - @Override - public String getServletInfo() { - return "Short description"; - } - -}