1 22 package org.jboss.ejb3.test.standalone; 23 24 import org.jboss.beans.metadata.plugins.AbstractBeanMetaData; 25 import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData; 26 import org.jboss.beans.metadata.plugins.AbstractValueMetaData; 27 import org.jboss.kernel.Kernel; 28 29 35 public class SimpleDeployer 36 { 37 public static class AlreadyInstantiated extends AbstractConstructorMetaData 38 { 39 private Object bean; 40 41 public class Factory 42 { 43 44 public Object create() 45 { 46 return bean; 47 } 48 } 49 50 public AlreadyInstantiated(Object bean) 51 { 52 this.bean = bean; 53 this.setFactory(new AbstractValueMetaData(new Factory())); 54 this.setFactoryClass(Factory.class.getName()); 55 this.setFactoryMethod("create"); 56 } 57 } 58 59 60 private Kernel kernel; 61 62 public Kernel getKernel() 63 { 64 return kernel; 65 } 66 67 public void setKernel(Kernel kernel) 68 { 69 this.kernel = kernel; 70 } 71 72 73 74 public void create() 75 { 76 install("SOME_STUPID_BEAN", new Object ()); 77 } 78 private void install(String name, Object service) 79 { 80 AbstractBeanMetaData bean = new AbstractBeanMetaData(name, service.getClass().getName()); 81 bean.setConstructor(new AlreadyInstantiated(service)); 82 try 83 { 84 kernel.getController().install(bean); 85 } 86 catch (Throwable throwable) 87 { 88 throw new RuntimeException (throwable); 89 } 90 } 91 92 } 93 | Popular Tags |