-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add middlware logics * update javadoc - rename middleware chain * update javadoc * update java doc * refactor code * remove di hook interface for now * update method name
- Loading branch information
Showing
3 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
src/main/java/com/microsoft/azure/functions/internal/spi/middleware/Middleware.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for | ||
* license information. | ||
*/ | ||
package com.microsoft.azure.functions.internal.spi.middleware; | ||
|
||
/** | ||
* This interface is implemented by middlewares to include middleware core logics. | ||
* | ||
* <p>This class is internal and is hence not for public use at this time. Its APIs are unstable and can change | ||
* at any time. | ||
*/ | ||
public interface Middleware { | ||
/** | ||
* Middlewares will override this method to include their own logics. | ||
* @param context execution context that pass along middleware chain | ||
* @param chain middleware chain {@link MiddlewareChain} | ||
* @throws Exception any exception that is thrown out in next middleware | ||
*/ | ||
void invoke(MiddlewareContext context, MiddlewareChain chain) throws Exception; | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/microsoft/azure/functions/internal/spi/middleware/MiddlewareChain.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for | ||
* license information. | ||
*/ | ||
package com.microsoft.azure.functions.internal.spi.middleware; | ||
|
||
/** | ||
* The middleware chain. | ||
* | ||
* <p>This class is internal and is hence not for public use at this time. Its APIs are unstable and can change | ||
* at any time. | ||
*/ | ||
public interface MiddlewareChain { | ||
/** | ||
* Invokes next middleware in the chain. | ||
* @param context execution context that pass along middleware chain | ||
* @throws Exception any exception that happen along middleware chain | ||
*/ | ||
void doNext(MiddlewareContext context) throws Exception; | ||
} |
58 changes: 58 additions & 0 deletions
58
src/main/java/com/microsoft/azure/functions/internal/spi/middleware/MiddlewareContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for | ||
* license information. | ||
*/ | ||
|
||
package com.microsoft.azure.functions.internal.spi.middleware; | ||
|
||
import com.microsoft.azure.functions.ExecutionContext; | ||
|
||
/** | ||
* Middleware Execution Context | ||
* | ||
* <p>This class is internal and is hence not for public use at this time. Its APIs are unstable and can change | ||
* at any time. | ||
*/ | ||
public interface MiddlewareContext extends ExecutionContext { | ||
/** | ||
* Returns the name of parameter defined in customer function. | ||
* The input is the simple class name of target annotation. | ||
* @param annotationSimpleClassName the simple class name of target annotation | ||
* @return the name of parameter defined in customer function | ||
*/ | ||
//TODO: @Nullable | ||
String getParameterName(String annotationSimpleClassName); | ||
|
||
/** | ||
* Returns corresponding parameter value sent from host by the given the parameter name. | ||
* The return type is Object but the real type is String (currently only support get String type, | ||
* planning to support other types in the future.) | ||
* Make it return Object to avoid break this API in the future. | ||
* @param name the name of parameter | ||
* @return an object which will be String type that represents parameter value of customer function | ||
*/ | ||
//TODO: @Nullable | ||
Object getParameterValue(String name); | ||
|
||
/** | ||
* Updates the parameter value by parameter name. It will be the actual parameter value | ||
* used when invoke customer function. This API give middleware ability to update function input. | ||
* @param name the name of parameter to be updated | ||
* @param value the value of parameter to be updated | ||
*/ | ||
void updateParameterValue(String name, Object value); | ||
|
||
/** | ||
* Returns the return value from customer function invocation. | ||
* @return an object that is the return value of customer function | ||
*/ | ||
//TODO: @Nullable | ||
Object getReturnValue(); | ||
|
||
/** | ||
* Updates the return value from customer function invocation. | ||
* @param returnValue value that will be updated as function return value. | ||
*/ | ||
void updateReturnValue(Object returnValue); | ||
} |