1 29 package jegg.impl; 30 31 import java.util.Collection ; 32 import java.util.HashSet ; 33 import java.util.Properties ; 34 35 36 41 class EggInfo 42 { 43 private final String _dispatcherName; 44 private final String _eggName; 45 private final String _handlerClass; 46 private final boolean _bindEarly; 47 48 private EggShell _egg; 49 private boolean _resolved = false; 50 51 private Collection _uses; 52 53 private Properties _properties; 54 55 EggInfo(final String eggName, final String handlerClass, final String dispatcherName, final boolean early) 56 { 57 super(); 58 _eggName = eggName; 59 _handlerClass = handlerClass; 60 _dispatcherName = dispatcherName; 61 _bindEarly = early; 62 } 63 64 EggInfo(EggInfo info) 65 { 66 this(info.getEggName(), info.getHandlerClassName(), info.getDispatcherName(), info.shouldBindEarly()); 67 _resolved = info.isResolved(); 68 _egg = info.getEgg(); 69 } 70 71 String getDispatcherName() {return _dispatcherName; } 72 String getEggName() { return _eggName; } 73 String getHandlerClassName() { return _handlerClass; } 74 75 synchronized void addDependency(String n) 76 { 77 if ( null == _uses ) { _uses = new HashSet (); } 78 _uses.add(n); 79 } 80 synchronized String [] getDependencies() 81 { 82 if (null == _uses) 83 return new String [0]; 84 else 85 return (String []) _uses.toArray(new String [_uses.size()]); 86 } 87 88 synchronized void addProperty(final String name, final String value) 89 { 90 if (null == _properties) {_properties = new Properties ();} 91 _properties.put(name,value); 92 } 93 94 synchronized Properties getProperties() {return _properties;} 95 96 boolean shouldBindEarly() 97 { 98 return _bindEarly; 99 } 100 101 synchronized void setEgg(EggShell egg) 102 { 103 if (null != _egg) 104 throw new IllegalStateException ("Egg already set for "+_eggName); 105 _egg = egg; 106 } 107 108 synchronized EggShell getEgg() { return _egg; } 109 110 synchronized void setResolved(final boolean b) { _resolved = b; } 111 synchronized boolean isResolved() { return _resolved; } 112 113 public String toString() 114 { 115 StringBuffer buf = new StringBuffer ("EggInfo["); 116 if (null != _eggName) 117 buf.append(_eggName); 118 buf.append("]"); 119 return buf.toString(); 120 } 121 } 122 | Popular Tags |