Make SessionDataMap a LifeCycle
This commit is contained in:
parent
3c6dab9790
commit
a0e7b21180
|
@ -23,6 +23,7 @@ import java.io.IOException;
|
|||
import org.eclipse.jetty.server.session.SessionContext;
|
||||
import org.eclipse.jetty.server.session.SessionData;
|
||||
import org.eclipse.jetty.server.session.SessionDataMap;
|
||||
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
||||
|
||||
import net.rubyeye.xmemcached.MemcachedClient;
|
||||
import net.rubyeye.xmemcached.XMemcachedClientBuilder;
|
||||
|
@ -34,7 +35,7 @@ import net.rubyeye.xmemcached.XMemcachedClientBuilder;
|
|||
*
|
||||
* Uses memcached as a cache for SessionData.
|
||||
*/
|
||||
public class MemcachedSessionDataMap implements SessionDataMap
|
||||
public class MemcachedSessionDataMap extends AbstractLifeCycle implements SessionDataMap
|
||||
{
|
||||
public static final String DEFAULT_HOST = "localhost";
|
||||
public static final String DEFAULT_PORT = "11211";
|
||||
|
@ -125,4 +126,19 @@ public class MemcachedSessionDataMap implements SessionDataMap
|
|||
_client.delete(id);
|
||||
return true; //delete returns false if the value didn't exist
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void doStop() throws Exception
|
||||
{
|
||||
super.doStop();
|
||||
if (_client != null)
|
||||
{
|
||||
_client.shutdown();
|
||||
_client = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -18,12 +18,14 @@
|
|||
|
||||
package org.eclipse.jetty.server.session;
|
||||
|
||||
import org.eclipse.jetty.util.component.LifeCycle;
|
||||
|
||||
/**
|
||||
* SessionDataMap
|
||||
*
|
||||
* A map style access to SessionData keyed by the session id.
|
||||
*/
|
||||
public interface SessionDataMap
|
||||
public interface SessionDataMap extends LifeCycle
|
||||
{
|
||||
/**
|
||||
* Initialize this data map for the
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.eclipse.jetty.util.component.LifeCycle;
|
|||
* A store for the data contained in a Session object. The store
|
||||
* would usually be persistent.
|
||||
*/
|
||||
public interface SessionDataStore extends SessionDataMap, LifeCycle
|
||||
public interface SessionDataStore extends SessionDataMap
|
||||
{
|
||||
|
||||
/**
|
||||
|
|
|
@ -133,6 +133,14 @@ public class MemcachedTestServer extends AbstractTestServer
|
|||
return expiredIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStop() throws Exception
|
||||
{
|
||||
super.doStop();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* @param port
|
||||
|
|
Loading…
Reference in New Issue