Example usage for com.amazonaws.services.elasticloadbalancing.model Listener setInstanceProtocol

List of usage examples for com.amazonaws.services.elasticloadbalancing.model Listener setInstanceProtocol

Introduction

In this page you can find the example usage for com.amazonaws.services.elasticloadbalancing.model Listener setInstanceProtocol.

Prototype


public void setInstanceProtocol(String instanceProtocol) 

Source Link

Document

<p> The protocol to use for routing traffic to instances: HTTP, HTTPS, TCP, or SSL.

Usage

From source file:org.apache.stratos.aws.extension.AWSHelper.java

License:Apache License

/**
 * Returns the Listeners required for the service. Listeners are derived
 * from the proxy port, port and protocol values of the service.
 *
 * @param service//from   www. j a v a 2s  .com
 * @return list of listeners required for the service
 */
public List<Listener> getRequiredListeners(Member member) throws LoadBalancerExtensionException {
    List<Listener> listeners = new ArrayList<Listener>();

    Collection<Port> ports = member.getPorts();

    for (Port port : ports) {
        int instancePort = port.getValue();
        int proxyPort = port.getProxy();
        String protocol = port.getProtocol().toUpperCase();
        String instanceProtocol = protocol;

        Listener listener = new Listener(protocol, proxyPort, instancePort);
        listener.setInstanceProtocol(instanceProtocol);
        if ("HTTPS".equalsIgnoreCase(protocol) || "SSL".equalsIgnoreCase(protocol)) {
            // if the SSL certificate is not configured in the aws.properties file, can't continue
            if (getSslCertificateId() == null || getSslCertificateId().isEmpty()) {
                String errorMsg = "Required property " + Constants.LOAD_BALANCER_SSL_CERTIFICATE_ID
                        + " not provided in configuration";
                log.error(errorMsg);
                throw new LoadBalancerExtensionException(errorMsg);
            }
            // TODO: make debug?
            if (log.isInfoEnabled()) {
                log.info("Listener protocol = " + protocol + ", hence setting the SSL Certificate Id: "
                        + getSslCertificateId());
            }
            listener.setSSLCertificateId(getSslCertificateId());
        }

        listeners.add(listener);
    }

    return listeners;
}