1 16 package scriptella.core; 17 18 import scriptella.spi.Connection; 19 20 21 29 public class DynamicContextDecorator extends DynamicContext { 30 private DynamicContext context; 31 private Connection cachedConnection; 32 33 public DynamicContextDecorator(DynamicContext context) { 34 setContext(context); 35 } 36 37 41 DynamicContextDecorator() { 42 } 43 44 @Override 45 public Object getParameter(final String name) { 46 return context.getParameter(name); 47 } 48 49 @Override 50 public Connection getConnection() { 51 if (cachedConnection==null) { 52 cachedConnection=context.getConnection(); 53 } 54 return cachedConnection; 55 } 56 57 58 64 void setContext(final DynamicContext context) { 65 this.context = context; 66 globalContext = context.getGlobalContext(); 67 cachedConnection = null; 68 } 69 70 } 71 | Popular Tags |