1 5 package org.exoplatform.container.groovy; 6 7 import groovy.lang.GroovyClassLoader; 8 import java.net.URL ; 9 10 15 public class GroovyObject { 16 private String resource_ ; 17 private Object object_ ; 18 private Class type_ ; 19 private boolean reloadable_ = false ; 20 private long loadTime_ = 1; 21 22 public GroovyObject(String resource) { 23 resource_ = resource ; 24 loadTime_ = System.currentTimeMillis() ; 25 } 26 27 public String getGroovyResource() { return resource_ ; } 28 29 public Object getObject() { return object_ ;} 30 public void setObject(Object object) { 31 loadTime_ = System.currentTimeMillis() ; 32 object_ = object ; 33 if(object != null) { 34 type_ = object.getClass() ; 35 } else { 36 type_ = null ; 37 } 38 } 39 40 public boolean isReloadable() { return reloadable_ ; } 41 public long getLoadTime() { return loadTime_ ; } 42 43 public Class getType() { return type_ ; } 44 45 synchronized public void setType(GroovyClassLoader gcl) throws Exception { 46 URL url = gcl.getResource(resource_) ; 47 if(url.toString().startsWith("file:")) reloadable_ = true ; 48 else reloadable_ = false ; 49 type_ = gcl.parseClass(url.openStream()) ; 50 object_ = null ; 51 } 52 } | Popular Tags |