Skip to content

Commit 407a813

Browse files
committed
Changed startup handler setter to onStartup
1 parent eaab838 commit 407a813

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public String echoServletHeaders(@Context HttpServletRequest context) {
146146
You can register [`Filter`](https://docs.oracle.com/javaee/7/api/javax/servlet/Filter.html) implementations by implementing a `StartupsHandler` as defined in the `AwsLambdaServletContainerHandler` class. The `onStartup` methods receives a reference to the current `ServletContext`.
147147

148148
```java
149-
handler.setStartupHandler(c -> {
149+
handler.onStartup(c -> {
150150
FilterRegistration.Dynamic registration = c.addFilter("CustomHeaderFilter", CustomHeaderFilter.class);
151151
// update the registration to map to a path
152152
registration.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*");

aws-serverless-java-container-core/src/main/java/com/amazonaws/serverless/proxy/internal/servlet/AwsLambdaServletContainerHandler.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ public abstract class AwsLambdaServletContainerHandler<RequestType, ResponseType
4242
// Variables - Private
4343
//-------------------------------------------------------------
4444

45-
4645
private FilterChainManager filterChainManager;
4746

4847
//-------------------------------------------------------------
@@ -92,23 +91,23 @@ protected void setServletContext(final ServletContext context) {
9291

9392

9493
/**
95-
* You can use the <code>setStartupHandler</code> to intercept the ServletContext as the Spring application is
94+
* You can use the <code>onStartup</code> to intercept the ServletContext as the Spring application is
9695
* initialized and inject custom values. The StartupHandler is called after the <code>onStartup</code> method
9796
* of the <code>LambdaSpringApplicationinitializer</code> implementation. For example, you can use this method to
9897
* add custom filters to the servlet context:
9998
*
10099
* <pre>
101100
* {@code
102101
* handler = SpringLambdaContainerHandler.getAwsProxyHandler(EchoSpringAppConfig.class);
103-
* handler.setStartupHandler(c -> {
102+
* handler.onStartup(c -> {
104103
* // the "c" parameter to this function is the initialized servlet context
105104
* c.addFilter("CustomHeaderFilter", CustomHeaderFilter.class);
106105
* });
107106
* }
108107
* </pre>
109108
* @param h A lambda expression that implements the <code>StartupHandler</code> functional interface
110109
*/
111-
public void setStartupHandler(final StartupHandler h) {
110+
public void onStartup(final StartupHandler h) {
112111
startupHandler = h;
113112
}
114113

aws-serverless-java-container-spring/src/test/java/com/amazonaws/serverless/proxy/spring/SpringServletContextTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static void setUp() {
3232
try {
3333
handler = SpringLambdaContainerHandler.getAwsProxyHandler(EchoSpringAppConfig.class);
3434
handler.setRefreshContext(true);
35-
handler.setStartupHandler(c -> {
35+
handler.onStartup(c -> {
3636
FilterRegistration.Dynamic registration = c.addFilter("CustomHeaderFilter", CustomHeaderFilter.class);
3737
// update the registration to map to a path
3838
registration.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*");

0 commit comments

Comments
 (0)