1 18 19 package org.objectweb.kilim.model; 20 21 import java.util.Iterator ; 22 import java.util.Stack ; 23 24 import org.objectweb.kilim.KilimException; 25 import org.objectweb.kilim.description.BasicElement; 26 import org.objectweb.kilim.description.InlinedElement; 27 import org.objectweb.kilim.description.KILIM; 28 import org.objectweb.kilim.description.NamedElement; 29 import org.objectweb.kilim.description.TemplateDescription; 30 import org.objectweb.kilim.description.TemplateElementImpl; 31 32 35 public abstract class RtComponentProvider extends RtComponentInterface { 36 protected static Stack callStack = new Stack (); 37 private RuntimeSource support; 38 private Object source; 39 40 46 protected RtComponentProvider(TemplateElementImpl aElement, ContainerElement aComponent, RuntimeSource aSupport) { 47 super(aElement, aComponent); 48 support = aSupport; 49 } 50 51 54 public String getLocalName() { 55 TemplateElementImpl elem = getElementDescription(); 56 if (elem instanceof InlinedElement) { 57 return ((InlinedElement) elem).getLocalName(); 58 } else if (elem instanceof NamedElement) { 59 return ((NamedElement) elem).getLocalName(); 60 } 61 return ""; 62 } 63 64 67 public boolean isEventSource() { 68 return false; 69 } 70 71 74 public Object getEventSourceValue() throws KilimException { 75 return source; 76 } 77 78 81 public void setEventSourceValue(Object aSource) throws KilimException { 82 source = aSource; 83 } 84 85 89 public RuntimeSource getSupport() { 90 return support; 91 } 92 93 96 public void bindProvider(RuntimeSource aSource, boolean jReplace) throws KilimException { 97 TemplateDescription tmp0 = getContainingComponent().getTemplate(); 98 String lName = getLocalName(); 99 String tmpList = tmp0.getName(); 100 while ((tmp0 = tmp0.getSuperTemplate()) != null) { 101 Iterator iter = tmp0.getBindings(lName, true); 102 if (iter != KILIM.EMPTY_ITERATOR) { 103 tmpList = tmpList + ", " + tmp0.getName(); 104 } 105 } 106 throw new KilimException("attempt to bind a provider " + getQualifiedName() + " (binding definition in templates : " + tmpList + ")"); 107 } 108 109 112 public void unbindProvider(RuntimeSource aSource) throws KilimException { 113 throw new KilimException("attempt to unbind a provider " + getQualifiedName()); 114 } 115 116 119 public boolean isSingleValuePort() { 120 return false; 121 } 122 123 126 public boolean isCollectionPort() { 127 return false; 128 } 129 130 133 public boolean isProvider() { 134 return true; 135 } 136 137 140 public boolean isProperty() { 141 return false; 142 } 143 144 147 protected void specificBindValue(Object aValue) throws KilimException { 148 throw new KilimException ("attempt to bind a value to a provider " + getQualifiedName()); 149 } 150 151 154 protected void specificUnbindValue() throws KilimException { 155 throw new KilimException ("attempt to bind a value to a provider " + getQualifiedName()); 156 } 157 158 162 public int getKind() { 163 return ((BasicElement) getElementDescription()).getKind(); 164 } 165 } | Popular Tags |