本文整理汇总了Java中com.amazonaws.transform.Unmarshaller类的典型用法代码示例。如果您正苦于以下问题:Java Unmarshaller类的具体用法?Java Unmarshaller怎么用?Java Unmarshaller使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Unmarshaller类属于com.amazonaws.transform包,在下文中一共展示了Unmarshaller类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: JsonResponseHandler
import com.amazonaws.transform.Unmarshaller; //导入依赖的package包/类
/**
* Constructs a new response handler that will use the specified JSON unmarshaller to unmarshall
* the service response and uses the specified response element path to find the root of the
* business data in the service's response.
* @param responseUnmarshaller The JSON unmarshaller to use on the response.
* @param simpleTypeUnmarshallers List of unmarshallers to be used for scalar types.
* @param customTypeMarshallers List of custom unmarshallers to be used for special types.
* @param jsonFactory the json factory to be used for parsing the response.
*/
public JsonResponseHandler(Unmarshaller<T, JsonUnmarshallerContext> responseUnmarshaller,
Map<Class<?>, Unmarshaller<?, JsonUnmarshallerContext>> simpleTypeUnmarshallers,
Map<UnmarshallerType, Unmarshaller<?, JsonUnmarshallerContext>> customTypeMarshallers,
JsonFactory jsonFactory, boolean needsConnectionLeftOpen,
boolean isPayloadJson) {
/*
* Even if the invoked operation just returns null, we still need an
* unmarshaller to run so we can pull out response metadata.
*
* We might want to pass this in through the client class so that we
* don't have to do this check here.
*/
this.responseUnmarshaller =
responseUnmarshaller != null ? responseUnmarshaller : new VoidJsonUnmarshaller<T>();
this.needsConnectionLeftOpen = needsConnectionLeftOpen;
this.isPayloadJson = isPayloadJson;
this.simpleTypeUnmarshallers = ValidationUtils.assertNotNull(simpleTypeUnmarshallers, "simple type unmarshallers");
this.customTypeMarshallers = ValidationUtils.assertNotNull(customTypeMarshallers, "custom type marshallers");
this.jsonFactory = ValidationUtils.assertNotNull(jsonFactory, "JSONFactory");
}
示例2: createAse
import com.amazonaws.transform.Unmarshaller; //导入依赖的package包/类
private AmazonServiceException createAse(HttpResponse errorResponse) throws Exception {
// Try to parse the error response as XML
final Document document = documentFromContent(errorResponse.getContent(), idString(errorResponse));
/*
* We need to select which exception unmarshaller is the correct one to
* use from all the possible exceptions this operation can throw.
* Currently we rely on the unmarshallers to return null if they can't
* unmarshall the response, but we might need something a little more
* sophisticated in the future.
*/
for (Unmarshaller<AmazonServiceException, Node> unmarshaller : unmarshallerList) {
AmazonServiceException ase = unmarshaller.unmarshall(document);
if (ase != null) {
ase.setStatusCode(errorResponse.getStatusCode());
return ase;
}
}
return null;
}
示例3: testHeadersAddedToObjectListing
import com.amazonaws.transform.Unmarshaller; //导入依赖的package包/类
/**
* Test the IBM_SSE_KP_ENABLED & IBM_SSE_KP_CRK are set in the ObjectLIsting
* response object
* @throws Exception
*
*/
@Test
public void testHeadersAddedToObjectListing() throws Exception {
Unmarshaller<ObjectListing, InputStream> unmarshaller = new Unmarshallers.ListObjectsUnmarshaller(false);
S3XmlResponseHandler xmlResponseHandler = new S3XmlResponseHandler<ObjectListing>(unmarshaller);
HttpResponse httpResponse = new HttpResponse(null, null);
httpResponse.addHeader(Headers.IBM_SSE_KP_ENABLED, "True");
httpResponse.addHeader(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN, "123456");
InputStream is = new ByteArrayInputStream(getXmlContent().getBytes());;
httpResponse.setContent(is);
AmazonWebServiceResponse<ObjectListing> objectListing = xmlResponseHandler.handle(httpResponse);
assertEquals(objectListing.getResult().getIBMSSEKPCrk(), "123456");
assertEquals(objectListing.getResult().getIBMSSEKPEnabled(), true);
}
示例4: testNullKPHeadersAreHandled
import com.amazonaws.transform.Unmarshaller; //导入依赖的package包/类
/**
* Test the IBM_SSE_KP_ENABLED & IBM_SSE_KP_CRK null headers are handled
*
* @throws Exception
*
*/
@Test
public void testNullKPHeadersAreHandled() throws Exception {
Unmarshaller<ObjectListing, InputStream> unmarshaller = new Unmarshallers.ListObjectsUnmarshaller(false);
S3XmlResponseHandler xmlResponseHandler = new S3XmlResponseHandler<ObjectListing>(unmarshaller);
HttpResponse httpResponse = new HttpResponse(null, null);
httpResponse.addHeader(Headers.IBM_SSE_KP_ENABLED, null);
httpResponse.addHeader(Headers.IBM_SSE_KP_CRK, null);
InputStream is = new ByteArrayInputStream(getXmlContent().getBytes());;
httpResponse.setContent(is);
AmazonWebServiceResponse<ObjectListing> objectListing = xmlResponseHandler.handle(httpResponse);
assertEquals(objectListing.getResult().getIBMSSEKPCrk(), null);
assertEquals(objectListing.getResult().getIBMSSEKPEnabled(), false);
}
示例5: testEmptyKPHeadersAreHandled
import com.amazonaws.transform.Unmarshaller; //导入依赖的package包/类
/**
* Test the IBM_SSE_KP_ENABLED & IBM_SSE_KP_CRK empty headers are handled
*
* @throws Exception
*
*/
@Test
public void testEmptyKPHeadersAreHandled() throws Exception {
Unmarshaller<ObjectListing, InputStream> unmarshaller = new Unmarshallers.ListObjectsUnmarshaller(false);
S3XmlResponseHandler xmlResponseHandler = new S3XmlResponseHandler<ObjectListing>(unmarshaller);
HttpResponse httpResponse = new HttpResponse(null, null);
InputStream is = new ByteArrayInputStream(getXmlContent().getBytes());;
httpResponse.setContent(is);
AmazonWebServiceResponse<ObjectListing> objectListing = xmlResponseHandler.handle(httpResponse);
assertEquals(objectListing.getResult().getIBMSSEKPCrk(), null);
assertEquals(objectListing.getResult().getIBMSSEKPEnabled(), false);
}
示例6: testOnlyKPEnabledHeaderIsSet
import com.amazonaws.transform.Unmarshaller; //导入依赖的package包/类
/**
* Test the IBM_SSE_KP_CRK empty header is handled
*
* @throws Exception
*
*/
@Test
public void testOnlyKPEnabledHeaderIsSet() throws Exception {
Unmarshaller<ObjectListing, InputStream> unmarshaller = new Unmarshallers.ListObjectsUnmarshaller(false);
S3XmlResponseHandler xmlResponseHandler = new S3XmlResponseHandler<ObjectListing>(unmarshaller);
HttpResponse httpResponse = new HttpResponse(null, null);
httpResponse.addHeader(Headers.IBM_SSE_KP_ENABLED, "True");
InputStream is = new ByteArrayInputStream(getXmlContent().getBytes());;
httpResponse.setContent(is);
AmazonWebServiceResponse<ObjectListing> objectListing = xmlResponseHandler.handle(httpResponse);
assertEquals(objectListing.getResult().getIBMSSEKPCrk(), null);
assertEquals(objectListing.getResult().getIBMSSEKPEnabled(), true);
}
示例7: testOnlyCRKHeaderIsSet
import com.amazonaws.transform.Unmarshaller; //导入依赖的package包/类
/**
* Test the IBM_SSE_KP_CRK empty header is handled
*
* @throws Exception
*
*/
@Test
public void testOnlyCRKHeaderIsSet() throws Exception {
Unmarshaller<ObjectListing, InputStream> unmarshaller = new Unmarshallers.ListObjectsUnmarshaller(false);
S3XmlResponseHandler xmlResponseHandler = new S3XmlResponseHandler<ObjectListing>(unmarshaller);
HttpResponse httpResponse = new HttpResponse(null, null);
httpResponse.addHeader(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN, "34567");
InputStream is = new ByteArrayInputStream(getXmlContent().getBytes());;
httpResponse.setContent(is);
AmazonWebServiceResponse<ObjectListing> objectListing = xmlResponseHandler.handle(httpResponse);
assertEquals(objectListing.getResult().getIBMSSEKPCrk(), "34567");
assertEquals(objectListing.getResult().getIBMSSEKPEnabled(), false);
}
示例8: GenericApiGatewayClient
import com.amazonaws.transform.Unmarshaller; //导入依赖的package包/类
GenericApiGatewayClient(ClientConfiguration clientConfiguration, String endpoint, Region region,
AWSCredentialsProvider credentials, String apiKey, AmazonHttpClient httpClient) {
super(clientConfiguration);
setRegion(region);
setEndpoint(endpoint);
this.credentials = credentials;
this.apiKey = apiKey;
this.signer = new AWS4Signer();
this.signer.setServiceName(API_GATEWAY_SERVICE_NAME);
this.signer.setRegionName(region.getName());
final JsonOperationMetadata metadata = new JsonOperationMetadata().withHasStreamingSuccessResponse(false).withPayloadJson(false);
final Unmarshaller<GenericApiGatewayResponse, JsonUnmarshallerContext> responseUnmarshaller = in -> new GenericApiGatewayResponse(in.getHttpResponse());
this.responseHandler = SdkStructuredPlainJsonFactory.SDK_JSON_FACTORY.createResponseHandler(metadata, responseUnmarshaller);
JsonErrorUnmarshaller defaultErrorUnmarshaller = new JsonErrorUnmarshaller(GenericApiGatewayException.class, null) {
@Override
public AmazonServiceException unmarshall(JsonNode jsonContent) throws Exception {
return new GenericApiGatewayException(jsonContent.toString());
}
};
this.errorResponseHandler = SdkStructuredPlainJsonFactory.SDK_JSON_FACTORY.createErrorResponseHandler(
Collections.singletonList(defaultErrorUnmarshaller), null);
if (httpClient != null) {
super.client = httpClient;
}
}
示例9: SqsAwsSdkAction
import com.amazonaws.transform.Unmarshaller; //导入依赖的package包/类
public SqsAwsSdkAction(RequestT request, String requestUrl,
Marshaller<com.amazonaws.Request<RequestT>, RequestT> marshaller,
Unmarshaller<ResponseT, StaxUnmarshallerContext> unmarshaller) {
this.requestUrl = requestUrl;
this.request = request;
this.marshaller = marshaller;
this.staxResponseHandler = new StaxResponseHandler<>(unmarshaller);
}
示例10: SdkStructuredJsonFactoryImpl
import com.amazonaws.transform.Unmarshaller; //导入依赖的package包/类
public SdkStructuredJsonFactoryImpl(JsonFactory jsonFactory,
Map<Class<?>, Unmarshaller<?, JsonUnmarshallerContext>> unmarshallers,
Map<UnmarshallerType, Unmarshaller<?, JsonUnmarshallerContext>> customTypeMarshallers) {
this.jsonFactory = jsonFactory;
this.unmarshallers = unmarshallers;
this.customTypeMarshallers = customTypeMarshallers;
}
示例11: createResponseHandler
import com.amazonaws.transform.Unmarshaller; //导入依赖的package包/类
@Override
public <T> JsonResponseHandler<T> createResponseHandler(JsonOperationMetadata operationMetadata,
Unmarshaller<T, JsonUnmarshallerContext> responseUnmarshaller) {
return new JsonResponseHandler(responseUnmarshaller, unmarshallers, customTypeMarshallers, jsonFactory,
operationMetadata.isHasStreamingSuccessResponse(),
operationMetadata.isPayloadJson());
}
示例12: StaxResponseHandler
import com.amazonaws.transform.Unmarshaller; //导入依赖的package包/类
/**
* Constructs a new response handler that will use the specified StAX
* unmarshaller to unmarshall the service response and uses the specified
* response element path to find the root of the business data in the
* service's response.
*
* @param responseUnmarshaller
* The StAX unmarshaller to use on the response.
*/
public StaxResponseHandler(Unmarshaller<T, StaxUnmarshallerContext> responseUnmarshaller) {
this.responseUnmarshaller = responseUnmarshaller;
/*
* Even if the invoked operation just returns null, we still need an
* unmarshaller to run so we can pull out response metadata.
*
* We might want to pass this in through the client class so that we
* don't have to do this check here.
*/
if (this.responseUnmarshaller == null) {
this.responseUnmarshaller = new VoidStaxUnmarshaller<T>();
}
}
示例13: unmarshalDecisionTask
import com.amazonaws.transform.Unmarshaller; //导入依赖的package包/类
/**
* Use SWF API to unmarshal a json document into a {@link DecisionTask}.
* Note: json is expected to be in the native format used by SWF
*/
public static DecisionTask unmarshalDecisionTask(String json) {
try {
Unmarshaller<DecisionTask, JsonUnmarshallerContext> unmarshaller = new DecisionTaskJsonUnmarshaller();
JsonParser parser = new JsonFactory().createParser(json);
return unmarshaller.unmarshall(new JsonUnmarshallerContextImpl(parser));
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
示例14: listVoices
import com.amazonaws.transform.Unmarshaller; //导入依赖的package包/类
@Override
public ListVoicesResult listVoices(ListVoicesRequest listVoicesRequest) throws AmazonServiceException,
AmazonClientException {
ExecutionContext executionContext = createExecutionContext(listVoicesRequest);
Request<ListVoicesRequest> request = ListVoicesRequestMarshallerFactory.getMarshaller(
listVoicesRequest.getMethodType()).marshall(listVoicesRequest);
Unmarshaller<ListVoicesResult, JsonUnmarshallerContext> unmarshaller = new ListVoicesResultJsonUnmarshaller();
JsonResponseHandler<ListVoicesResult> responseHandler =
new JsonResponseHandler<ListVoicesResult>(unmarshaller);
Response<ListVoicesResult> response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
}
示例15: getLexicon
import com.amazonaws.transform.Unmarshaller; //导入依赖的package包/类
@Override
public GetLexiconResult getLexicon(GetLexiconRequest getLexiconRequest)
throws AmazonServiceException, AmazonClientException {
ExecutionContext executionContext = createExecutionContext(getLexiconRequest);
GetLexiconRequestMarshaller marshaller = new GetLexiconPostRequestMarshaller();
Request<GetLexiconRequest> request = marshaller.marshall(getLexiconRequest);
Unmarshaller<GetLexiconResult, JsonUnmarshallerContext> unmarshaller = new GetLexiconResultJsonUnmarshaller();
JsonResponseHandler<GetLexiconResult> responseHandler = new JsonResponseHandler<GetLexiconResult>(unmarshaller);
Response<GetLexiconResult> response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
}