Java源码示例:com.amazonaws.services.lambda.runtime.ClientContext
示例1
@Test
public void testContextMarshalling() throws Exception {
ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
ObjectReader reader = mapper.readerFor(ClientContextImpl.class);
ClientContext clientContext = reader.readValue(ctx);
Assertions.assertNotNull(clientContext.getClient());
Assertions.assertNotNull(clientContext.getCustom());
Assertions.assertNotNull(clientContext.getEnvironment());
Assertions.assertEquals("<client_id>", clientContext.getClient().getInstallationId());
Assertions.assertEquals("<app_title>", clientContext.getClient().getAppTitle());
Assertions.assertEquals("<app_version_name>", clientContext.getClient().getAppVersionName());
Assertions.assertEquals("<app_version_code>", clientContext.getClient().getAppVersionCode());
Assertions.assertEquals("<app_package_name>", clientContext.getClient().getAppPackageName());
Assertions.assertEquals("world", clientContext.getCustom().get("hello"));
Assertions.assertEquals("<platform>", clientContext.getEnvironment().get("platform"));
}
示例2
public LambdaContext(Context ctx) {
this.ctx = ctx;
if (ctx == null) {
return;
}
this.ctxMap.put("functionVersion", ctx.getFunctionVersion());
this.ctxMap.put("functionName", ctx.getFunctionName());
this.ctxMap.put("awsRequestId", ctx.getAwsRequestId());
this.ctxMap.put("invokedFunctionArn", ctx.getInvokedFunctionArn());
this.ctxMap.put("logGroupName", ctx.getLogGroupName());
this.ctxMap.put("logStreamName", ctx.getLogStreamName());
ClientContext cc = ctx.getClientContext();
if (cc != null) {
this.ctxMap.put("clientContextCustom", cc.getCustom().toString());
this.ctxMap.put("clientContextEnvironment", cc.getEnvironment().toString());
Client c = cc.getClient();
if (c != null) {
this.ctxMap.put("clientContextClientInstallationId", c.getInstallationId());
this.ctxMap.put("clientContextClientAppPackageName", c.getAppPackageName());
this.ctxMap.put("clientContextClientAppTitle", c.getAppTitle());
this.ctxMap.put("clientContextClientAppVersionCode", c.getAppVersionCode());
this.ctxMap.put("clientContextClientAppVersionName", c.getAppVersionName());
}
}
this.ctxMap.values().removeIf(Objects::isNull);
}
示例3
@Override
public ClientContext getClientContext() {
return null;
}
示例4
@Override
public ClientContext getClientContext() {
// TODO Use LambdaRuntimeInvocationResponseHeaders.LAMBDA_RUNTIME_CLIENT_CONTEXT to build this
return null;
}
示例5
public ClientContext getClientContext() {
// TODO Auto-generated method stub
return null;
}
示例6
@Override
public ClientContext getClientContext() {
return null;
}
示例7
@Override
public void run() {
InputStream input = new ByteArrayInputStream(json.getBytes(StandardCharsets.UTF_8));
try {
new NeptuneExportLambda().handleRequest(input, System.out, new Context() {
@Override
public String getAwsRequestId() {
throw new NotImplementedException();
}
@Override
public String getLogGroupName() {
throw new NotImplementedException();
}
@Override
public String getLogStreamName() {
throw new NotImplementedException();
}
@Override
public String getFunctionName() {
throw new NotImplementedException();
}
@Override
public String getFunctionVersion() {
throw new NotImplementedException();
}
@Override
public String getInvokedFunctionArn() {
throw new NotImplementedException();
}
@Override
public CognitoIdentity getIdentity() {
throw new NotImplementedException();
}
@Override
public ClientContext getClientContext() {
throw new NotImplementedException();
}
@Override
public int getRemainingTimeInMillis() {
throw new NotImplementedException();
}
@Override
public int getMemoryLimitInMB() {
throw new NotImplementedException();
}
@Override
public LambdaLogger getLogger() {
return new LambdaLogger() {
@Override
public void log(String s) {
System.out.println(s);
}
@Override
public void log(byte[] bytes) {
throw new NotImplementedException();
}
};
}
});
} catch (Exception e) {
System.err.println("An error occurred while exporting from Neptune:");
e.printStackTrace();
System.exit(-1);
}
System.exit(0);
}
示例8
@Override
public ClientContext getClientContext() {
return clientContext;
}
示例9
private Context getContext() {
return new Context() {
@Override
public String getAwsRequestId() {
return "23234234";
}
@Override
public String getLogGroupName() {
return null;
}
@Override
public String getLogStreamName() {
return null;
}
@Override
public String getFunctionName() {
return null;
}
@Override
public String getFunctionVersion() {
return null;
}
@Override
public String getInvokedFunctionArn() {
return null;
}
@Override
public CognitoIdentity getIdentity() {
return null;
}
@Override
public ClientContext getClientContext() {
return null;
}
@Override
public int getRemainingTimeInMillis() {
return 5000;
}
@Override
public int getMemoryLimitInMB() {
return 128;
}
@Override
public LambdaLogger getLogger() {
return null;
}
};
}
示例10
@Override
public ClientContext getClientContext() {
return null;
}
示例11
@Override
public ClientContext getClientContext() {
return null;
}
示例12
public ClientContext getClientContext(){
return null;
}
示例13
@Override
public ClientContext getClientContext() {
return clientContext;
}
示例14
public void setClientContext(ClientContext value) {
clientContext = value;
}