Skip to content
This repository was archived by the owner on Feb 7, 2018. It is now read-only.

Commit 2de64e4

Browse files
committed
Pull Request #19. Enabling new schema and bumping version to 2.0.
1 parent ff0d48b commit 2de64e4

File tree

3 files changed

+28
-46
lines changed

3 files changed

+28
-46
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<artifactId>aws-dynamodb-session-tomcat</artifactId>
77
<packaging>jar</packaging>
88
<name>Amazon DynamoDB Session Manager for Tomcat</name>
9-
<version>1.0.5</version>
9+
<version>2.0.0</version>
1010
<description>The Amazon DynamoDB Session Manager for Tomcat provides a custom session manager for Tomcat 7 that stores session data in Amazon DynamoDB, Amazon's fully managed NoSQL database service.</description>
1111
<url>https://aws.amazon.com/java</url>
1212

src/main/java/com/amazonaws/services/dynamodb/sessionmanager/DynamoDBSessionManager.java

Lines changed: 13 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
import com.amazonaws.auth.PropertiesCredentials;
3131
import com.amazonaws.internal.StaticCredentialsProvider;
3232
import com.amazonaws.regions.RegionUtils;
33+
import com.amazonaws.services.dynamodb.sessionmanager.converters.DefaultDynamoSessionItemConverter;
3334
import com.amazonaws.services.dynamodb.sessionmanager.converters.DefaultTomcatSessionConverter;
34-
import com.amazonaws.services.dynamodb.sessionmanager.converters.LegacyDynamoDBSessionItemConverter;
3535
import com.amazonaws.services.dynamodb.sessionmanager.converters.LegacyTomcatSessionConverter;
3636
import com.amazonaws.services.dynamodb.sessionmanager.converters.SessionConverter;
3737
import com.amazonaws.services.dynamodb.sessionmanager.converters.TomcatSessionConverterChain;
@@ -49,9 +49,9 @@ public class DynamoDBSessionManager extends PersistentManagerBase {
4949

5050
public static final String DEFAULT_TABLE_NAME = "Tomcat_SessionState";
5151

52-
private static final String USER_AGENT = "DynamoSessionManager/1.1";
52+
private static final String USER_AGENT = "DynamoSessionManager/2.0";
5353
private static final String name = "AmazonDynamoDBSessionManager";
54-
private static final String info = name + "/1.1";
54+
private static final String info = name + "/2.0";
5555

5656
private String regionId = "us-east-1";
5757
private String endpoint;
@@ -87,10 +87,6 @@ public String getName() {
8787
return name;
8888
}
8989

90-
//
91-
// Context.xml Configuration Members
92-
//
93-
9490
public void setRegionId(String regionId) {
9591
this.regionId = regionId;
9692
}
@@ -135,10 +131,6 @@ public void setProxyPort(Integer proxyPort) {
135131
this.proxyPort = proxyPort;
136132
}
137133

138-
//
139-
// Private Interface
140-
//
141-
142134
@Override
143135
protected void initInternal() throws LifecycleException {
144136
this.setDistributable(true);
@@ -170,16 +162,16 @@ private AWSCredentialsProvider initCredentials() {
170162
if (credentialsInContextConfigAreValid()) {
171163
throw new AmazonClientException("Incomplete AWS security credentials specified in context.xml.");
172164
}
173-
debug("Using AWS access key ID and secret key from context.xml");
165+
logger.debug("Using AWS access key ID and secret key from context.xml");
174166
return new StaticCredentialsProvider(new BasicAWSCredentials(accessKey, secretKey));
175167
}
176168

177169
// Use any explicitly specified credentials properties file next
178170
if (credentialsFile != null) {
179171
try {
180-
debug("Reading security credentials from properties file: " + credentialsFile);
172+
logger.debug("Reading security credentials from properties file: " + credentialsFile);
181173
PropertiesCredentials credentials = new PropertiesCredentials(credentialsFile);
182-
debug("Using AWS credentials from file: " + credentialsFile);
174+
logger.debug("Using AWS credentials from file: " + credentialsFile);
183175
return new StaticCredentialsProvider(credentials);
184176
} catch (Exception e) {
185177
throw new AmazonClientException(
@@ -191,13 +183,13 @@ private AWSCredentialsProvider initCredentials() {
191183
// Fall back to the default credentials chain provider if credentials weren't explicitly set
192184
AWSCredentialsProvider defaultChainProvider = new DefaultAWSCredentialsProviderChain();
193185
if (defaultChainProvider.getCredentials() == null) {
194-
debug("Loading security credentials from default credentials provider chain.");
186+
logger.debug("Loading security credentials from default credentials provider chain.");
195187
throw new AmazonClientException(
196188
"Unable find AWS security credentials. "
197189
+ "Searched JVM system properties, OS env vars, and EC2 instance roles. "
198190
+ "Specify credentials in Tomcat's context.xml file or put them in one of the places mentioned above.");
199191
}
200-
debug("Using default AWS credentials provider chain to load credentials");
192+
logger.debug("Using default AWS credentials provider chain to load credentials");
201193
return defaultChainProvider;
202194
}
203195

@@ -223,12 +215,12 @@ private ClientConfiguration initClientConfiguration() {
223215

224216
// Attempt to use an explicit proxy configuration
225217
if (proxyHost != null || proxyPort != null) {
226-
debug("Reading proxy settings from context.xml");
218+
logger.debug("Reading proxy settings from context.xml");
227219
if (proxyHost == null || proxyPort == null) {
228220
throw new AmazonClientException("Incomplete proxy settings specified in context.xml."
229221
+ " Both proxy hot and proxy port needs to be specified");
230222
}
231-
debug("Using proxy host and port from context.xml");
223+
logger.debug("Using proxy host and port from context.xml");
232224
clientConfiguration.withProxyHost(proxyHost).withProxyPort(proxyPort);
233225
}
234226

@@ -260,9 +252,9 @@ private SessionConverter getSessionConverter() {
260252
LegacyTomcatSessionConverter legacyConverter = new LegacyTomcatSessionConverter(this, classLoader,
261253
maxInactiveInterval);
262254
DefaultTomcatSessionConverter defaultConverter = new DefaultTomcatSessionConverter(this, classLoader);
263-
// Converter compatible with the legacy schema but can understand new schema
264-
return new SessionConverter(TomcatSessionConverterChain.wrap(legacyConverter, defaultConverter),
265-
new LegacyDynamoDBSessionItemConverter());
255+
// Converter that 'writes' with the new schema but can still read the legacy schema
256+
return new SessionConverter(TomcatSessionConverterChain.wrap(defaultConverter, legacyConverter),
257+
new DefaultDynamoSessionItemConverter());
266258
}
267259

268260
/**
@@ -283,28 +275,4 @@ private Context getAssociatedContext() {
283275
throw new IllegalStateException(e);
284276
}
285277
}
286-
287-
//
288-
// Logger Utility Functions
289-
//
290-
291-
public static void debug(String s) {
292-
logger.debug(s);
293-
}
294-
295-
public static void warn(String s) {
296-
logger.warn(s);
297-
}
298-
299-
public static void warn(String s, Exception e) {
300-
logger.warn(s, e);
301-
}
302-
303-
public static void error(String s) {
304-
logger.error(s);
305-
}
306-
307-
public static void error(String s, Exception e) {
308-
logger.error(s, e);
309-
}
310278
}

src/main/java/com/amazonaws/services/dynamodb/sessionmanager/util/ValidatorUtils.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
/*
2+
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
115
package com.amazonaws.services.dynamodb.sessionmanager.util;
216

317
public class ValidatorUtils {

0 commit comments

Comments
 (0)