1 22 package org.jboss.kernel.plugins.dependency; 23 24 import org.jboss.beans.info.spi.BeanInfo; 25 import org.jboss.beans.metadata.spi.BeanMetaData; 26 import org.jboss.joinpoint.spi.Joinpoint; 27 import org.jboss.kernel.Kernel; 28 import org.jboss.kernel.spi.config.KernelConfigurator; 29 import org.jboss.kernel.spi.dependency.KernelController; 30 import org.jboss.kernel.spi.dependency.KernelControllerContext; 31 import org.jboss.kernel.spi.dependency.KernelControllerContextAware; 32 import org.jboss.kernel.spi.metadata.MutableMetaDataContext; 33 34 40 public class InstantiateAction extends KernelControllerContextAction 41 { 42 public void installAction(KernelControllerContext context) throws Throwable 43 { 44 KernelController controller = (KernelController) context.getController(); 45 Kernel kernel = controller.getKernel(); 46 KernelConfigurator configurator = kernel.getConfigurator(); 47 48 BeanMetaData metaData = context.getBeanMetaData(); 49 BeanInfo info = context.getBeanInfo(); 50 final Joinpoint joinPoint = configurator.getConstructorJoinPoint(info, metaData.getConstructor(), metaData); 51 52 Object object = dispatchJoinPoint(context, joinPoint); 53 context.setTarget(object); 54 55 MutableMetaDataContext metaCtx = context.getMetaDataContext(); 56 if (metaCtx != null) 57 { 58 metaCtx.setTarget(object); 59 } 60 61 try 62 { 63 if (object != null) 64 { 65 if (context.getBeanInfo() == null) 66 { 67 info = configurator.getBeanInfo(object.getClass()); 68 context.setBeanInfo(info); 69 } 70 71 74 controller.addInstantiatedContext(context); 75 } 76 } 77 catch (Throwable t) 78 { 79 uninstall(context); 80 throw t; 81 } 82 } 83 84 public void uninstallAction(KernelControllerContext context) 85 { 86 try 87 { 88 Object object = context.getTarget(); 89 if (object != null) 90 { 91 94 KernelController controller = (KernelController) context.getController(); 95 controller.removeInstantiatedContext(context); 96 } 97 98 } 99 catch (Throwable ignored) 100 { 101 log.debug("Ignored error unsetting context ", ignored); 102 } 103 finally 104 { 105 context.setTarget(null); 106 } 107 } 108 } | Popular Tags |