1 5 package org.exoplatform.container.groovy; 6 7 import org.exoplatform.container.ExoContainer; 8 import org.picocontainer.PicoContainer; 9 import org.picocontainer.PicoInitializationException; 10 import org.picocontainer.defaults.AbstractComponentAdapter; 11 16 public class ExoGroovyComponentAdapter extends AbstractComponentAdapter { 17 private GroovyObject gobject_ ; 18 19 public ExoGroovyComponentAdapter(GroovyObject gobject) { 20 super(gobject.getType(), gobject.getType()) ; 21 gobject_ = gobject ; 22 } 23 24 public Object getComponentInstance(PicoContainer container) { 25 Object obj = gobject_.getObject() ; 26 if(obj == null) { 27 try { 28 synchronized(container) { 29 ExoContainer exoContainer = (ExoContainer) container ; 30 obj = exoContainer.createComponent(gobject_.getType()); 31 gobject_.setObject(obj) ; 32 } 33 } catch (Exception ex) { 34 throw new PicoInitializationException("Cannot instantiate script: " + gobject_.getGroovyResource(), ex) ; 35 } 36 } 37 return obj ; 38 } 39 40 public void verify(PicoContainer container) { 41 42 } 43 } 44 | Popular Tags |