1 22 package org.jboss.beans.metadata.plugins; 23 24 import org.jboss.beans.metadata.spi.MetaDataVisitor; 25 import org.jboss.dependency.plugins.AbstractDependencyItem; 26 import org.jboss.dependency.spi.ControllerContext; 27 import org.jboss.dependency.spi.ControllerState; 28 import org.jboss.dependency.spi.DependencyItem; 29 import org.jboss.kernel.spi.dependency.KernelController; 30 import org.jboss.kernel.spi.dependency.KernelControllerContext; 31 import org.jboss.reflect.spi.TypeInfo; 32 33 39 public class ThisValueMetaData extends AbstractValueMetaData 40 { 41 42 protected KernelController controller; 43 44 47 public ThisValueMetaData() 48 { 49 } 50 51 public Object getValue(TypeInfo info, ClassLoader cl) throws Throwable 52 { 53 ControllerContext context = controller.getContext(value, ControllerState.INSTANTIATED); 54 if (context == null) 55 throw new Error ("Could not deference this " + this); 56 return context.getTarget(); 57 } 58 59 public void initialVisit(MetaDataVisitor visitor) 60 { 61 KernelControllerContext controllerContext = visitor.getControllerContext(); 62 controller = (KernelController) controllerContext.getController(); 63 value = controllerContext.getName(); 64 ControllerState whenRequired = visitor.getContextState(); 65 66 DependencyItem item = new AbstractDependencyItem(value, value, whenRequired, ControllerState.INSTANTIATED); 67 visitor.addDependency(item); 68 69 super.initialVisit(visitor); 70 } 71 } 72 | Popular Tags |