1 18 19 package org.objectweb.kilim.model.instanciation; 20 21 import java.util.HashMap ; 22 23 import org.objectweb.kilim.KilimException; 24 25 39 40 public class DefaultInstanciationStrategy implements InstanciationStrategy { 41 private InstanciationMger defaultMger = new BDUInstanciationMger(); 42 private HashMap perTemplateMger; 43 private HashMap perInstanceMger; 44 45 48 public DefaultInstanciationStrategy() throws KilimException { 49 } 50 51 57 public DefaultInstanciationStrategy(InstanciationMger aMger) throws KilimException { 58 setDefaultMger(aMger); 59 } 60 61 64 public void setDefaultMger(InstanciationMger aMger) throws KilimException { 65 if (aMger == null) { 66 throw new KilimException("attempt to install a null instanciation manager as default"); 67 } 68 defaultMger = aMger; 69 } 70 71 74 public InstanciationMger getDefaultMger() { 75 return defaultMger; 76 } 77 78 81 public void setPerTemplateMger(String aName, InstanciationMger aManager) throws KilimException { 82 if (aName == null) { 83 throw new KilimException("attempt to install a manager for template through a null name"); 84 } 85 86 if (perTemplateMger == null) { 87 perTemplateMger = new HashMap (); 88 } 89 perTemplateMger.put(aName, aManager); 90 } 91 92 95 public InstanciationMger getPerTemplateMger(String aName) throws KilimException { 96 if (aName == null) { 97 throw new KilimException("attempt to get a template manager through a null name "); 98 } 99 100 if (perTemplateMger == null) { 101 return null; 102 } 103 return (InstanciationMger) perTemplateMger.get(aName); 104 } 105 106 109 public void setPerInstanceMger(String aName, InstanciationMger aManager) throws KilimException { 110 if (aManager == null) { 111 throw new KilimException("attempt to install a null instanciation manager for template " + aName); 112 } 113 114 if (perInstanceMger == null) { 115 perInstanceMger = new HashMap (); 116 } 117 perInstanceMger.put(aName, aManager); 118 } 119 120 123 public InstanciationMger getPerInstanceMger(String aName) throws KilimException { 124 if (aName == null) { 125 throw new KilimException("attempt to get a instance manager through a null name "); 126 } 127 128 if (perInstanceMger == null) { 129 return null; 130 } 131 return (InstanciationMger) perInstanceMger.get(aName); 132 } 133 } 134 | Popular Tags |