/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package web.component.impl.awselb.model;

import com.amazonaws.services.elasticloadbalancing.model.Listener;
import com.amazonaws.services.elasticloadbalancing.model.ListenerDescription;
import web.component.api.model.LoadBalancer;
import web.component.api.model.LoadBalancerListener;

/**
 *
 * @author Hiroshi
 */
public class LoadBalancerListenerImpl extends Listener implements LoadBalancerListener{

    private LoadBalancer lb;
    
    LoadBalancerListenerImpl(){
        
    }
    
    LoadBalancerListenerImpl(ListenerDescription description){
        Listener lbaListener = description.getListener();
        this.setInstancePort(lbaListener.getInstancePort());
        this.setInstanceProtocol(lbaListener.getInstanceProtocol());
        this.setServicePort(lbaListener.getLoadBalancerPort());
        this.setServiceProtocol(lbaListener.getProtocol());
    }
    
    public static LoadBalancerListener create(){
        return new LoadBalancerListenerImpl();
    }

    @Override
    public void setInstancePort(int instancePort) {
        super.setInstancePort(instancePort);
    }

    @Override
    public void setServicePort(int servciePort) {
        super.setLoadBalancerPort(servciePort);
    }

    @Override
    public Integer getInstancePort() {
        return super.getInstancePort();
    }

    @Override
    public Integer getServicePort() {
        return super.getLoadBalancerPort();
    }

    @Override
    public void setServiceProtocol(String serviceProtocol) {
        super.setProtocol(serviceProtocol);
    }

    @Override
    public String getInstanceProtocol() {
        return super.getInstanceProtocol();
    }

    @Override
    public String getServiceProtocol() {
        return super.getProtocol();
    }
    
    @Override
    public void setServerCertificate(String serverCertificateId){
        super.setSSLCertificateId(serverCertificateId);
    }

    @Override
    public LoadBalancer getLoadBalancer() {
        return lb;
    }

    @Override
    public LoadBalancer delete() {
        LoadBalancer deleteFrom = lb;
        if(deleteFrom != null ){
            deleteFrom.deleteListener(this);
            lb = null;
        }
        return deleteFrom;
    }
    
}

@@ -2153,32 +2153,480 @@
 turn lb;%0A    %7D%0A%0A
+    @Override%0A    public void addTo(LoadBalancer addedTo)%7B%0A        if(lb == null)%7B%0A            if(!(addedTo instanceof LoadBalancerImpl))%0A                throw new IllegalArgumentException(%22Invalid load balancer specified.%22);%0A            addedTo.createListener(this);%0A            lb = addedTo;%0A        %7Delse if(!lb.equals(addedTo))%7B%0A            throw new IllegalArgumentException(%22Already attached to another load balancer.%22);%0A        %7D%0A    %7D%0A    %0A
     @Override%0A  

Update LoadBalancerListenerImpl.java