Skip to content

Commit 5f54d74

Browse files
committed
initial support for java in AWS Lambda
1 parent cbbbeb6 commit 5f54d74

File tree

13 files changed

+1337
-0
lines changed

13 files changed

+1337
-0
lines changed

aws-lambda-java-core/pom.xml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
4+
<groupId>com.amazonaws</groupId>
5+
<artifactId>aws-lambda-java-core</artifactId>
6+
<version>1.0.0</version>
7+
<packaging>jar</packaging>
8+
9+
<name>AWS Lambda Java Core Library</name>
10+
<description>
11+
Minimal set of interface definitions for Java support in AWS Lambda
12+
</description>
13+
<url>https://aws.amazon.com/lambda/</url>
14+
<licenses>
15+
<license>
16+
<name>Apache License, Version 2.0</name>
17+
<url>https://aws.amazon.com/apache2.0</url>
18+
<distribution>repo</distribution>
19+
</license>
20+
</licenses>
21+
<scm>
22+
<url>https://github.com/aws/aws-lambda-java-libs.git</url>
23+
</scm>
24+
<developers>
25+
<developer>
26+
<name>AWS Lambda team</name>
27+
<organization>Amazon Web Services</organization>
28+
<organizationUrl>https://aws.amazon.com/</organizationUrl>
29+
</developer>
30+
</developers>
31+
32+
<distributionManagement>
33+
<repository>
34+
<id>sonatype-nexus-staging</id>
35+
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
36+
</repository>
37+
</distributionManagement>
38+
39+
<profiles>
40+
<profile>
41+
<id>dev</id>
42+
<build>
43+
<plugins>
44+
<plugin>
45+
<groupId>org.apache.maven.plugins</groupId>
46+
<artifactId>maven-javadoc-plugin</artifactId>
47+
<version>2.9.1</version>
48+
<executions>
49+
<execution>
50+
<id>attach-javadocs</id>
51+
<goals>
52+
<goal>jar</goal>
53+
</goals>
54+
</execution>
55+
</executions>
56+
</plugin>
57+
</plugins>
58+
</build>
59+
</profile>
60+
<profile>
61+
<id>release</id>
62+
<build>
63+
<plugins>
64+
<plugin>
65+
<groupId>org.apache.maven.plugins</groupId>
66+
<artifactId>maven-source-plugin</artifactId>
67+
<version>2.2.1</version>
68+
<executions>
69+
<execution>
70+
<id>attach-sources</id>
71+
<goals>
72+
<goal>jar-no-fork</goal>
73+
</goals>
74+
</execution>
75+
</executions>
76+
</plugin>
77+
<plugin>
78+
<groupId>org.apache.maven.plugins</groupId>
79+
<artifactId>maven-javadoc-plugin</artifactId>
80+
<version>2.9.1</version>
81+
<executions>
82+
<execution>
83+
<id>attach-javadocs</id>
84+
<goals>
85+
<goal>jar</goal>
86+
</goals>
87+
</execution>
88+
</executions>
89+
</plugin>
90+
<plugin>
91+
<groupId>org.apache.maven.plugins</groupId>
92+
<artifactId>maven-gpg-plugin</artifactId>
93+
<version>1.5</version>
94+
<executions>
95+
<execution>
96+
<id>sign-artifacts</id>
97+
<phase>verify</phase>
98+
<goals>
99+
<goal>sign</goal>
100+
</goals>
101+
</execution>
102+
</executions>
103+
</plugin>
104+
<plugin>
105+
<groupId>org.sonatype.plugins</groupId>
106+
<artifactId>nexus-staging-maven-plugin</artifactId>
107+
<version>1.6.3</version>
108+
<extensions>true</extensions>
109+
<configuration>
110+
<serverId>sonatype-nexus-staging</serverId>
111+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
112+
<autoReleaseAfterClose>false</autoReleaseAfterClose>
113+
</configuration>
114+
</plugin>
115+
</plugins>
116+
</build>
117+
</profile>
118+
</profiles>
119+
</project>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. */
2+
3+
package com.amazonaws.services.lambda.runtime;
4+
5+
/**
6+
* Contains information about the client application that invoked the Lambda function.
7+
*
8+
*/
9+
public interface Client {
10+
11+
/**
12+
* Gets the application's title
13+
*
14+
*/
15+
public String getAppTitle();
16+
17+
/**
18+
* Gets the application's version
19+
*
20+
*/
21+
public String getAppVersionName();
22+
23+
/**
24+
* Gets the application's version code
25+
*
26+
*/
27+
public String getAppVersionCode();
28+
29+
/**
30+
* Gets the application's package name
31+
*/
32+
public String getAppPackageName();
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. */
2+
3+
package com.amazonaws.services.lambda.runtime;
4+
5+
import java.util.Map;
6+
7+
/**
8+
*
9+
* Provides information about cLient configuration and execution environment.
10+
*
11+
*/
12+
public interface ClientContext {
13+
/**
14+
* Gets the client information provided by the AWS Mobile SDK
15+
*
16+
*/
17+
public Client getClient();
18+
19+
/**
20+
* Gets custom values set by the client application
21+
* <p>
22+
* This map is mutable (and not thread-safe if mutated)
23+
* </p>
24+
*/
25+
public Map<String, String> getCustom();
26+
27+
/**
28+
* Gets environment information provided by mobile SDK, immutable.
29+
*
30+
*/
31+
public Map<String, String> getEnvironment();
32+
33+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. */
2+
3+
package com.amazonaws.services.lambda.runtime;
4+
5+
/**
6+
* Provides information related to Amazon Congnito identities.
7+
*
8+
*/
9+
public interface CognitoIdentity {
10+
/**
11+
* Gets the Amazon Cognito identity ID
12+
*
13+
*/
14+
public String getIdentityId();
15+
16+
/**
17+
* Gets the Amazon Cognito identity pool ID
18+
*
19+
*/
20+
public String getIdentityPoolId();
21+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. */
2+
3+
package com.amazonaws.services.lambda.runtime;
4+
5+
/**
6+
*
7+
* The context object allows you to access useful information available within
8+
* the Lambda execution environment
9+
*
10+
*/
11+
public interface Context {
12+
13+
/**
14+
* Gets the AWS request ID associated with the request.
15+
* <p>
16+
* This is the same ID returned to the client that called invoke(). This ID
17+
* is reused for retries on the same request.
18+
* </p>
19+
*/
20+
public String getAwsRequestId();
21+
22+
/**
23+
* Gets the CloudWatch log group that this container is configured to log
24+
* to.
25+
* <p>
26+
* The return value may be null:
27+
* <ul>
28+
* <li>
29+
* If the container is not configured to log to CloudWatch.</li>
30+
* <li>
31+
* If the role provided to the function does not have sufficient
32+
* permissions.</li>
33+
* </ul>
34+
* </p>
35+
*/
36+
public String getLogGroupName();
37+
38+
/**
39+
* Gets the CloudWatch log stream that this container is configured to log
40+
* to.
41+
* <p>
42+
* The return value may be null:
43+
* <ul>
44+
* <li>
45+
* If the container is not configured to log to CloudWatch.</li>
46+
* <li>
47+
* If the role provided to the function does not have sufficient
48+
* permissions.</li>
49+
* </ul>
50+
* </p>
51+
*/
52+
public String getLogStreamName();
53+
54+
/**
55+
* Gets the name of the function being executed.
56+
*
57+
*/
58+
public String getFunctionName();
59+
60+
/**
61+
* Gets information about the Amazon Cognito identity provider when invoked
62+
* through the AWS Mobile SDK. It can be null
63+
*
64+
*/
65+
public CognitoIdentity getIdentity();
66+
67+
/**
68+
* Gets information about the client application and device when invoked
69+
* through the AWS Mobile SDK. It can be null.
70+
*
71+
*/
72+
public ClientContext getClientContext();
73+
74+
/**
75+
* Gets the time remaining for this execution in milliseconds
76+
*/
77+
public int getRemainingTimeInMillis();
78+
79+
/**
80+
* Gets the memory size configured for the Lambda function
81+
*
82+
*/
83+
public int getMemoryLimitInMB();
84+
85+
/**
86+
* Gets a the lambda logger instance associated with the context object
87+
*
88+
*/
89+
public LambdaLogger getLogger();
90+
91+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. */
2+
3+
package com.amazonaws.services.lambda.runtime;
4+
5+
/**
6+
* A low level Lambda runtime logger
7+
*
8+
*/
9+
public interface LambdaLogger {
10+
11+
/**
12+
* Logs a string to AWS CloudWatch Logs
13+
*
14+
* <p>
15+
* Logging will not be done:
16+
* <ul>
17+
* <li>
18+
* If the container is not configured to log to CloudWatch.
19+
* </li>
20+
* <li>
21+
* If the role provided to the function does not have sufficient permissions.
22+
* </li>
23+
* </ul>
24+
* </p>
25+
*
26+
* @param string A string containing the event to log.
27+
*/
28+
public void log(String string);
29+
}
30+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.amazonaws.services.lambda.runtime;
2+
3+
import com.amazonaws.services.lambda.runtime.Context;
4+
5+
/**
6+
*
7+
* Lambda request handlers implement AWS Lambda Function application logic using plain old java objects
8+
* as input and output.
9+
*
10+
* @param <I> The input parameter type
11+
* @param <O> The output parameter type
12+
*/
13+
public interface RequestHandler<I, O> {
14+
/**
15+
* Handles a Lambda Function request
16+
* @param input The Lambda Function input
17+
* @param context The Lambda execution environment context object.
18+
* @return The Lambda Function output
19+
*/
20+
public O handleRequest(I input, Context context);
21+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. */
2+
3+
package com.amazonaws.services.lambda.runtime;
4+
5+
import java.io.InputStream;
6+
import java.io.OutputStream;
7+
import java.io.IOException;
8+
9+
/**
10+
* Low-level request-handling interface, Lambda stream request handlers implement AWS Lambda Function application logic
11+
* using input and output stream
12+
*/
13+
public interface RequestStreamHandler {
14+
/**
15+
* Handles a Lambda Function request
16+
* @param input The Lambda Function input stream
17+
* @param output The Lambda function output stream
18+
* @param context The Lambda execution environment context object.
19+
* @throws IOException
20+
*/
21+
public void handleRequest(InputStream input, OutputStream output, Context context) throws IOException;
22+
}

0 commit comments

Comments
 (0)