Merge remote-tracking branch 'origin/jetty-9.4.x'

This commit is contained in:
Jan Bartel 2016-09-28 14:55:43 +10:00
commit 2383fb1c4a
4 changed files with 39 additions and 2 deletions

View File

@ -13,6 +13,7 @@
<Set name="gracePeriodSec"><Property name="jetty.session.gracePeriod.seconds" default="3600" /></Set>
<Set name="maxRetries"><Property name="jetty.session.gcloud.maxRetries" default="5"/></Set>
<Set name="backoffMs"><Property name="jetty.session.gcloud.backoffMs" default="1000"/></Set>
<Set name="namespace"><Property name="jetty.session.gcloud.namespace" default=""/></Set>
<Set name="entityDataModel">
<New class="org.eclipse.jetty.gcloud.session.GCloudSessionDataStore$EntityDataModel">
<Set name="kind">

View File

@ -92,6 +92,7 @@ http://www.apache.org/licenses/LICENSE-2.0.html
## GCloudDatastore Session config
#jetty.session.gcloud.maxRetries=5
#jetty.session.gcloud.backoffMs=1000
#jetty.session.gcloud.namespace=
#jetty.session.gcloud.model.kind=GCloudSession
#jetty.session.gcloud.model.id=id
#jetty.session.gcloud.model.contextPath=contextPath

View File

@ -72,6 +72,9 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore
protected boolean _dsProvided = false;
protected EntityDataModel _model;
private String _namespace;
@ -316,6 +319,15 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore
_backoff = ms;
}
public void setNamespace (String namespace)
{
_namespace = namespace;
}
public String getNamespace ()
{
return _namespace;
}
public int getBackoffMs ()
{
@ -341,8 +353,13 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore
protected void doStart() throws Exception
{
if (!_dsProvided)
_datastore = DatastoreOptions.defaultInstance().service();
{
if (!StringUtil.isBlank(getNamespace()))
_datastore = DatastoreOptions.builder().namespace(getNamespace()).build().service();
else
_datastore = DatastoreOptions.defaultInstance().service();
}
if (_model == null)
_model = new EntityDataModel();

View File

@ -30,6 +30,7 @@ import org.eclipse.jetty.server.session.SessionHandler;
*/
public class GCloudSessionDataStoreFactory extends AbstractSessionDataStoreFactory
{
private String _namespace;
private int _maxRetries;
private int _backoffMs;
private GCloudSessionDataStore.EntityDataModel _model;
@ -66,6 +67,22 @@ public class GCloudSessionDataStoreFactory extends AbstractSessionDataStoreFacto
}
/**
* @return the namespace
*/
public String getNamespace()
{
return _namespace;
}
/**
* @param namespace the namespace to set
*/
public void setNamespace(String namespace)
{
_namespace = namespace;
}
/**
* @see org.eclipse.jetty.server.session.SessionDataStoreFactory#getSessionDataStore(org.eclipse.jetty.server.session.SessionHandler)
*/
@ -76,6 +93,7 @@ public class GCloudSessionDataStoreFactory extends AbstractSessionDataStoreFacto
ds.setBackoffMs(getBackoffMs());
ds.setMaxRetries(getMaxRetries());
ds.setGracePeriodSec(getGracePeriodSec());
ds.setNamespace(_namespace);
return ds;
}