1 18 19 package org.objectweb.kilim.model; 20 21 import java.util.Iterator ; 22 23 import org.objectweb.kilim.KilimException; 24 import org.objectweb.kilim.description.Port; 25 import org.objectweb.kilim.description.Slot; 26 import org.objectweb.kilim.model.services.DefaultNamingContext; 27 28 31 public class SlotFactory extends DefaultNamingContext implements Factory { 32 private String localName; 33 private ComponentFactory containingFactory; 34 35 private Slot slotDescription; 36 private Component containingComponent; 37 38 44 45 public SlotFactory(String aName, ComponentFactory aFactory) throws KilimException { 46 super(aName, aFactory); 47 localName = aName; 48 containingFactory = aFactory; 49 containingComponent = aFactory.getComponent(); 50 if (containingFactory != null) { 51 containingFactory.addChildNamingContext(aName, this); 52 } 53 } 54 55 59 public ComponentFactory getContainingFactory() { 60 return containingFactory; 61 } 62 63 68 public void addSubFactory(ComponentFactory aElement) throws KilimException { 69 throw new KilimException("attempt to add a subfactory to slot factory " + getQualifiedName()); 70 } 71 72 77 public void removeSubFactory(ComponentFactory aElement) throws KilimException { 78 throw new KilimException("attempt to remove a subfactory from slot factory " + getQualifiedName()); 79 } 80 81 87 public ComponentFactory getSubFactory(String aName) throws KilimException { 88 throw new KilimException("attempt to get subfactory " + aName + " from slot factory " + getQualifiedName()); 89 } 90 91 96 public Iterator getSubFactories() throws KilimException { 97 throw new KilimException("attempt to get subfactories from slot factory " + getQualifiedName()); 98 } 99 100 106 public RtComponentSlot newSlot(Slot aSlot) throws KilimException { 107 if (aSlot == null) { 108 throw new KilimException("attempt to create a null slot in component " + containingComponent.getQualifiedName()); 109 } 110 111 RtComponentSlot rSlot = new RtComponentSlot(aSlot, containingComponent, this); 112 Iterator iter = aSlot.getPorts(); 114 while (iter.hasNext()) { 115 Port elem = (Port) iter.next(); 116 RtComponentInterface interf = newInterface(elem, rSlot); 117 rSlot.addInterface(interf); 118 addBoundName(interf.getLocalName(), interf); 119 } 120 return rSlot; 121 } 122 123 private RtComponentInterface newInterface(Port port, RtComponentSlot aSlot) throws KilimException { 124 RtComponentInterface interf = null; 125 if (port.isUnary()) { 126 interf = new RtSingleValuePort(port, aSlot); 127 } else { 128 interf = new RtCollectionPort(port, aSlot); 129 } 130 131 String interfName; 132 String qualName = getQualifiedName(); 133 if ("".equals(qualName)) { 134 interfName = port.getLocalName(); 135 } else { 136 interfName = qualName + "/" + port.getLocalName(); 137 } 138 return interf; 139 } 140 } | Popular Tags |