Skip to content

Commit 473db78

Browse files
authored
Version 1.0.0 of the Large payload offloading common library for AWS (#1)
* Version 1.0.0 of the Large payload offloading common library for AWS
1 parent 561daf5 commit 473db78

File tree

12 files changed

+1071
-5
lines changed

12 files changed

+1071
-5
lines changed

README.md

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,32 @@
1-
## My Project
1+
## Large Payload Offloading Java Common Library For AWS
22

3-
TODO: Fill this README out!
3+
The **Large Payload Offloading Java Common Library For AWS** enables you to manage payloads with Amazon S3.
4+
For example, this is useful for storing and retrieving payloads with size greater than the current SQS/SNS limit of 256 KB, up to a maximum of 2 GB.
5+
6+
You can use this library to:
47

5-
Be sure to:
8+
* Specify whether payloads are always stored in Amazon S3 or only when a payload's size exceeds 256 KB.
69

7-
* Change the title in this README
8-
* Edit your repository description on GitHub
10+
* Get the corresponding payload object from an Amazon S3 bucket.
11+
12+
* Delete the corresponding payload object from an Amazon S3 bucket.
13+
14+
You can download release builds through the [releases section of this](https://github.com/awslabs/large-payload-offloading-java-common-lib-for-aws/releases) project.
15+
16+
## Getting Started
17+
18+
* **Sign up for AWS** -- Before using this library with Amazon services, you need an AWS account. For more information about creating an AWS account and retrieving your AWS credentials, see [AWS Account and Credentials](http://docs.aws.amazon.com/AWSSdkDocsJava/latest/DeveloperGuide/java-dg-setup.html) in the AWS SDK for Java Developer Guide.
19+
* **Minimum requirements** -- You'll need Java 8 (or later) and [Maven 3](http://maven.apache.org/).
20+
* **Download** -- Download the [latest preview release](https://github.com/awslabs/large-payload-offloading-java-common-lib-for-aws/releases) or pick it up from Maven:
21+
22+
```xml
23+
<dependency>
24+
<groupId>com.amazonaws</groupId>
25+
<artifactId>large-payload-offloading-java-common-lib-for-aws</artifactId>
26+
<version>1.0.0</version>
27+
<type>jar</type>
28+
</dependency>
29+
```
930

1031
## Security
1132

pom.xml

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.amazonaws</groupId>
8+
<artifactId>large-payload-offloading-java-common-lib-for-aws</artifactId>
9+
<version>1.0.0</version>
10+
<packaging>jar</packaging>
11+
<name>Large payload offloading common library for AWS</name>
12+
<description>Common library between extended Amazon AWS clients to save payloads up to 2GB on Amazon S3.</description>
13+
<url>https://github.com/awslabs/large-payload-offloading-java-common-lib-for-aws</url>
14+
15+
<scm>
16+
<url>https://github.com/awslabs/large-payload-offloading-java-common-lib-for-aws</url>
17+
</scm>
18+
19+
<licenses>
20+
<license>
21+
<name>Apache License, Version 2.0</name>
22+
<url>https://aws.amazon.com/apache2.0</url>
23+
<distribution>repo</distribution>
24+
</license>
25+
</licenses>
26+
27+
<developers>
28+
<developer>
29+
<id>amazonwebservices</id>
30+
<organization>Amazon Web Services</organization>
31+
<organizationUrl>https://aws.amazon.com</organizationUrl>
32+
<roles>
33+
<role>developer</role>
34+
</roles>
35+
</developer>
36+
</developers>
37+
38+
<properties>
39+
<aws-java-sdk.version>1.11.817</aws-java-sdk.version>
40+
</properties>
41+
42+
<dependencies>
43+
<dependency>
44+
<groupId>com.amazonaws</groupId>
45+
<artifactId>aws-java-sdk-s3</artifactId>
46+
<version>${aws-java-sdk.version}</version>
47+
</dependency>
48+
<dependency>
49+
<groupId>junit</groupId>
50+
<artifactId>junit</artifactId>
51+
<version>4.12</version>
52+
<scope>test</scope>
53+
</dependency>
54+
<dependency>
55+
<groupId>org.mockito</groupId>
56+
<artifactId>mockito-core</artifactId>
57+
<version>3.3.3</version>
58+
<scope>test</scope>
59+
</dependency>
60+
<dependency>
61+
<groupId>org.hamcrest</groupId>
62+
<artifactId>hamcrest-all</artifactId>
63+
<version>1.3</version>
64+
<scope>test</scope>
65+
</dependency>
66+
<dependency>
67+
<groupId>pl.pragmatists</groupId>
68+
<artifactId>JUnitParams</artifactId>
69+
<version>1.1.1</version>
70+
<scope>test</scope>
71+
</dependency>
72+
</dependencies>
73+
74+
<build>
75+
<pluginManagement>
76+
<plugins>
77+
<plugin>
78+
<groupId>org.apache.maven.plugins</groupId>
79+
<artifactId>maven-compiler-plugin</artifactId>
80+
<version>3.8.1</version>
81+
<configuration>
82+
<source>1.8</source>
83+
<target>1.8</target>
84+
<encoding>UTF-8</encoding>
85+
</configuration>
86+
</plugin>
87+
<plugin>
88+
<groupId>org.sonatype.plugins</groupId>
89+
<artifactId>nexus-staging-maven-plugin</artifactId>
90+
<version>1.6.7</version>
91+
<extensions>true</extensions>
92+
<configuration>
93+
<serverId>ossrh</serverId>
94+
<nexusUrl>https://aws.oss.sonatype.org</nexusUrl>
95+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
96+
</configuration>
97+
</plugin>
98+
</plugins>
99+
</pluginManagement>
100+
</build>
101+
102+
<profiles>
103+
<profile>
104+
<id>publishing</id>
105+
<distributionManagement>
106+
<snapshotRepository>
107+
<id>ossrh</id>
108+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
109+
</snapshotRepository>
110+
<repository>
111+
<id>ossrh</id>
112+
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
113+
</repository>
114+
</distributionManagement>
115+
<build>
116+
<plugins>
117+
<plugin>
118+
<groupId>org.apache.maven.plugins</groupId>
119+
<artifactId>maven-gpg-plugin</artifactId>
120+
<version>1.6</version>
121+
<executions>
122+
<execution>
123+
<id>sign-artifacts</id>
124+
<phase>verify</phase>
125+
<goals>
126+
<goal>sign</goal>
127+
</goals>
128+
<configuration>
129+
<gpgArguments>
130+
<gpgArgument>--pinentry-mode</gpgArgument>
131+
<gpgArgument>loopback</gpgArgument>
132+
</gpgArguments>
133+
</configuration>
134+
</execution>
135+
</executions>
136+
</plugin>
137+
</plugins>
138+
</build>
139+
</profile>
140+
</profiles>
141+
</project>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.amazonaws.largepayloadoffloading;
2+
3+
import java.io.OutputStream;
4+
5+
/**
6+
* This class is used for checking the size of a string without copying the
7+
* whole string into memory and converting it to bytes array. Compared to
8+
* String.getBytes().length, it is more efficient and reliable for large
9+
* strings.
10+
*/
11+
class CountingOutputStream extends OutputStream {
12+
private long totalSize;
13+
14+
@Override
15+
public void write(int b) {
16+
++totalSize;
17+
}
18+
19+
@Override
20+
public void write(byte[] b) {
21+
totalSize += b.length;
22+
}
23+
24+
@Override
25+
public void write(byte[] b, int offset, int len) {
26+
totalSize += len;
27+
}
28+
29+
public long getTotalSize() {
30+
return totalSize;
31+
}
32+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.amazonaws.largepayloadoffloading;
2+
3+
import com.fasterxml.jackson.core.JsonProcessingException;
4+
import com.fasterxml.jackson.databind.DeserializationFeature;
5+
import com.fasterxml.jackson.databind.ObjectMapper;
6+
import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping;
7+
import com.fasterxml.jackson.databind.ObjectWriter;
8+
import com.fasterxml.jackson.databind.SerializationFeature;
9+
10+
/**
11+
* This class implements conversion through Jackson JSON processor. Methods are
12+
* provided for serializing an object to JSON and deserializing from JSON to an
13+
* object.
14+
*/
15+
class JsonDataConverter {
16+
protected final ObjectMapper objectMapper;
17+
18+
public JsonDataConverter() {
19+
this(new ObjectMapper());
20+
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
21+
objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
22+
objectMapper.enableDefaultTyping(DefaultTyping.NON_FINAL);
23+
}
24+
25+
public JsonDataConverter(ObjectMapper objectMapper) {
26+
this.objectMapper = objectMapper;
27+
}
28+
29+
public String serializeToJson(Object obj) throws JsonProcessingException {
30+
ObjectWriter objectWriter = objectMapper.writer();
31+
return objectWriter.writeValueAsString(obj);
32+
}
33+
34+
public <T> T deserializeFromJson(String jsonText, Class<T> objectType) throws Exception {
35+
return objectMapper.readValue(jsonText, objectType);
36+
}
37+
}

0 commit comments

Comments
 (0)