1 18 package org.objectweb.kilim.description; 19 20 import java.util.Iterator ; 21 import java.util.List ; 22 import java.util.ArrayList ; 23 24 import org.objectweb.kilim.KilimException; 25 26 31 public class Binding extends TemplateElementImpl { 32 private String portName; 33 private List boundProviders; 34 35 41 public Binding(String aPort, TemplateDescription aTemplate) throws KilimException { 42 if (aPort == null) { 43 if (aTemplate != null) { 44 throw new KilimException("attempt to use a null name for a port in a bind in template " + aTemplate.getName()); 45 } else { 46 throw new KilimException("attempt to use a null name for a port in a bind in a null template " + aTemplate.getName()); 47 } 48 } 49 if (aTemplate == null) { 50 throw new KilimException("attempt to bind port " + aPort + " in a null template "); 51 } 52 portName = aPort; 53 setContainingTemplate(aTemplate); 54 } 55 56 60 public String getPortName() { 61 return portName; 62 } 63 64 68 public void setPortName(String aPortName) { 69 portName = aPortName; 70 } 71 72 77 public Iterator getBoundProviders() { 78 if (boundProviders == null) { 79 return KILIM.EMPTY_ITERATOR; 80 } 81 return boundProviders.listIterator(); 82 } 83 84 89 public void bindProvider(BasicElement aElement) throws KilimException { 90 if (aElement == null) { 91 throw new KilimException("illegal null element in binding port " + portName); 92 } 93 if (boundProviders == null) { 94 boundProviders = new ArrayList (); 95 } 96 boundProviders.add(aElement); 97 } 98 99 104 public void unbindProvider(BasicElement aElement) throws KilimException { 105 if (aElement == null) { 106 throw new KilimException("illegal null element in unbinding port " + portName + " in template " + getContainingTemplate().getName()); 107 } 108 109 if (boundProviders == null) { 110 throw new KilimException("attempt to remove an element from an empty binding " + portName + " in template " + getContainingTemplate().getName()); 111 } 112 boundProviders.remove(aElement); 113 } 114 } 115 | Popular Tags |