1 25 26 package org.objectweb.easybeans.container.mdb; 27 28 import org.objectweb.easybeans.api.EZBContainer; 29 import org.objectweb.easybeans.api.FactoryException; 30 import org.objectweb.easybeans.api.bean.EasyBeansMDB; 31 import org.objectweb.easybeans.api.bean.info.IBeanInfo; 32 import org.objectweb.easybeans.api.pool.PoolException; 33 import org.objectweb.easybeans.container.AbsFactory; 34 import org.objectweb.easybeans.container.info.MessageDrivenInfo; 35 import org.objectweb.easybeans.log.JLog; 36 import org.objectweb.easybeans.log.JLogFactory; 37 import org.objectweb.easybeans.pool.JPool; 38 import org.objectweb.easybeans.pool.PoolEntryStatistics; 39 import org.objectweb.easybeans.pool.PoolFactory; 40 import org.objectweb.easybeans.rpc.api.EJBRequest; 41 import org.objectweb.easybeans.rpc.api.EJBResponse; 42 43 50 public class MDBFactory extends AbsFactory<EasyBeansMDB> implements PoolFactory<EasyBeansMDB, Long > { 51 52 55 private static JLog logger = JLogFactory.getLog(MDBFactory.class); 56 57 60 private MessageDrivenInfo messageDrivenInfo = null; 61 62 68 public MDBFactory(final String className, final EZBContainer container) throws FactoryException { 69 super(className, container); 70 setPool(new JPool<EasyBeansMDB, Long >(this)); 71 } 72 73 79 @Override 80 public EJBResponse rpcInvoke(final EJBRequest request) { 81 return null; 84 } 85 86 93 public EJBResponse localCall(final long hash, final Object [] methodArgs, final Long beanId) { 94 return null; 97 } 98 99 102 public void stop() { 103 try { 105 getPool().stop(); 106 } catch (PoolException e) { 107 logger.error("Problem when stopping the factory", e); 108 } 109 } 110 111 114 public IBeanInfo getBeanInfo() { 115 return messageDrivenInfo; 116 } 117 118 121 public MessageDrivenInfo getMessageDrivenInfo() { 122 return messageDrivenInfo; 123 } 124 125 129 public void setMessageDrivenInfo(final MessageDrivenInfo messageDrivenInfo) { 130 this.messageDrivenInfo = messageDrivenInfo; 131 } 132 133 139 public EasyBeansMDB create(final Long clue) throws PoolException { 140 EasyBeansMDB instance = null; 141 try { 142 instance = getBeanClass().newInstance(); 143 } catch (InstantiationException e) { 144 throw new PoolException("Cannot create a new instance", e); 145 } catch (IllegalAccessException e) { 146 throw new PoolException("Cannot create a new instance", e); 147 } 148 149 instance.setEasyBeansFactory(this); 151 152 EasyBeansMDBContext mdbContext = new EasyBeansMDBContext(instance); 154 instance.setEasyBeansContext(mdbContext); 155 156 ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); 157 Thread.currentThread().setContextClassLoader(getContainer().getClassLoader()); 158 try { 159 injectResources(instance); 161 162 instance.postConstructEasyBeansLifeCycle(); 164 } finally { 165 Thread.currentThread().setContextClassLoader(oldClassLoader); 166 } 167 168 return instance; 169 } 170 171 177 public boolean isMatching(final EasyBeansMDB object, final Long clue) { 178 return true; 181 } 182 183 189 public boolean validate(final EasyBeansMDB object, final PoolEntryStatistics stats) { 190 return true; 191 } 192 193 194 } 195 | Popular Tags |