Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright 2012-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License").
  * You may not use this file except in compliance with the License.
  * A copy of the License is located at
  *
  *  http://aws.amazon.com/apache2.0
  *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
package com.amazonaws.services.sqs.internal;
public class SQSRequestHandler extends AbstractRequestHandler {
    private static final Map<StringStringnonstandardEndpointMap = new HashMap<StringString>();
    static {
        .put("queue.amazonaws.com""sqs.us-east-1.amazonaws.com");
        .put("us-west-1.queue.amazonaws.com""sqs.us-west-1.amazonaws.com");
        .put("us-west-2.queue.amazonaws.com""sqs.us-west-2.amazonaws.com");
        .put("eu-west-1.queue.amazonaws.com""sqs.eu-west-1.amazonaws.com");
        .put("ap-southeast-1.queue.amazonaws.com""sqs.ap-southeast-1.amazonaws.com");
        .put("ap-northeast-1.queue.amazonaws.com""sqs.ap-northeast-1.amazonaws.com");
        .put("sa-east-1.queue.amazonaws.com""sqs.sa-east-1.amazonaws.com");
        .put("us-gov-west-1.queue.amazonaws.com""sqs.us-gov-west-1.amazonaws.com");
        .put("ap-southeast-2.queue.amazonaws.com""sqs.ap-southeast-2.amazonaws.com");
    }
    @Override
    public void beforeRequest(Request<?> request) {
        URI endpoint = request.getEndpoint();
        // If the request is using a non-standard endpoint, then
        // alter it to use the corresponding, standard endpoint
        if (.containsKey(endpoint.getHost())) {
            String newHost = .get(endpoint.getHost());
            String newEndpoint = endpoint.toString().replaceFirst(endpoint.getHost(), newHost);
            request.setEndpoint(URI.create(newEndpoint));
        }
    }
New to GrepCode? Check out our FAQ X