@Test public void testCloneAndInitialize() { MockPE prototype = new MockPE(); PrototypeWrapper prototypeWrapper = new PrototypeWrapper(prototype, new WallClock()); assertEquals(0, prototype.getInitializeCount()); MockPE instance = (MockPE)prototypeWrapper.getPE("asd"); assertNotNull(instance); assertEquals(0, prototype.getInitializeCount()); assertEquals(1, instance.getInitializeCount()); }
public AbstractPE getPE(String keyValue) { AbstractPE pe = null; try { pe = (AbstractPE) lookupTable.get(keyValue); if (pe == null) { pe = (AbstractPE) prototype.clone(); pe.initInstance(); } lookupTable.set(keyValue, pe, prototype.getTtl()); } catch (Exception e) { logger.error("exception when looking up pe for key:" + keyValue, e); } return pe; }
PrototypeWrapper { public AbstractPE getPE(String keyValue) { AbstractPE pe = null; try { pe = (AbstractPE) lookupTable.get(keyValue); if (pe == null) { pe = (AbstractPE) prototype.clone(); pe.initInstance(); } lookupTable.set(keyValue, pe, prototype.getTtl()); } catch (Exception e) { logger.error("exception when looking up pe for key:" + keyValue, e); } return pe; } }
PrototypeWrapper { public AbstractPE getPE(String keyValue) { AbstractPE pe = null; try { pe = (AbstractPE) lookupTable.get(keyValue); if (pe == null) { pe = (AbstractPE) prototype.clone(); pe.initInstance(); } lookupTable.set(keyValue, pe, prototype.getTtl()); } catch (Exception e) { logger.error("exception when looking up pe for key:" + keyValue, e); } return pe; } PrototypeWrapper(AbstractPE prototype, Clock s4Clock); }
PrototypeWrapper { public AbstractPE getPE(String keyValue) { AbstractPE pe = null; try { pe = (AbstractPE) lookupTable.get(keyValue); if (pe == null) { pe = (AbstractPE) prototype.clone(); pe.initInstance(); } lookupTable.set(keyValue, pe, prototype.getTtl()); } catch (Exception e) { logger.error("exception when looking up pe for key:" + keyValue, e); } return pe; } PrototypeWrapper(AbstractPE prototype, Clock s4Clock); String getId(); AbstractPE getPE(String keyValue); AbstractPE lookupPE(String keyValue); void expire(String keyValue); int getPECount(); List<EventAdvice> advise(); void setSafeKeeper(SafeKeeper safeKeeper); }
PrototypeWrapper { public AbstractPE getPE(String keyValue) { AbstractPE pe = null; try { pe = (AbstractPE) lookupTable.get(keyValue); if (pe == null) { pe = (AbstractPE) prototype.clone(); pe.initInstance(); } lookupTable.set(keyValue, pe, prototype.getTtl()); } catch (Exception e) { logger.error("exception when looking up pe for key:" + keyValue, e); } return pe; } PrototypeWrapper(AbstractPE prototype, Clock s4Clock); String getId(); AbstractPE getPE(String keyValue); AbstractPE lookupPE(String keyValue); void expire(String keyValue); int getPECount(); List<EventAdvice> advise(); void setSafeKeeper(SafeKeeper safeKeeper);  }