1 22 package org.jboss.config.plugins; 23 24 import org.jboss.beans.info.spi.BeanInfo; 25 import org.jboss.beans.info.spi.BeanInfoFactory; 26 import org.jboss.classadapter.spi.ClassAdapter; 27 import org.jboss.classadapter.spi.ClassAdapterFactory; 28 import org.jboss.classadapter.spi.DependencyBuilder; 29 import org.jboss.config.spi.Configuration; 30 import org.jboss.joinpoint.spi.JoinpointFactoryBuilder; 31 import org.jboss.reflect.spi.ClassInfo; 32 import org.jboss.reflect.spi.TypeInfo; 33 import org.jboss.reflect.spi.TypeInfoFactory; 34 import org.jboss.repository.spi.MetaDataContextFactory; 35 import org.jboss.util.NestedRuntimeException; 36 37 43 public abstract class AbstractConfiguration implements Configuration 44 { 45 46 private BeanInfoFactory beanInfoFactory; 47 48 49 private ClassAdapterFactory classAdapterFactory; 50 51 52 private TypeInfoFactory typeInfoFactory; 53 54 55 private JoinpointFactoryBuilder joinpointFactoryBuilder; 56 57 58 private MetaDataContextFactory metaDataContextFactory; 59 60 61 private DependencyBuilder dependencyBuilder; 62 63 66 public AbstractConfiguration() 67 { 68 } 69 70 public BeanInfo getBeanInfo(String className, ClassLoader cl) throws Throwable 71 { 72 ClassAdapter classAdapter = getClassAdapterFactory().getClassAdapter(className, cl); 73 return getBeanInfoFactory().getBeanInfo(classAdapter); 74 } 75 76 public BeanInfo getBeanInfo(Class clazz) throws Throwable 77 { 78 ClassAdapter classAdapter = getClassAdapterFactory().getClassAdapter(clazz); 79 return getBeanInfoFactory().getBeanInfo(classAdapter); 80 } 81 82 public BeanInfo getBeanInfo(TypeInfo typeInfo) throws Throwable 83 { 84 ClassAdapter classAdapter = getClassAdapterFactory().getClassAdapter(typeInfo); 85 return getBeanInfoFactory().getBeanInfo(classAdapter); 86 } 87 88 public ClassInfo getClassInfo(String className, ClassLoader cl) throws Throwable 89 { 90 ClassAdapter classAdapter = getClassAdapterFactory().getClassAdapter(className, cl); 91 return classAdapter.getClassInfo(); 92 } 93 94 public ClassInfo getClassInfo(Class clazz) throws Throwable 95 { 96 ClassAdapter classAdapter = getClassAdapterFactory().getClassAdapter(clazz); 97 return classAdapter.getClassInfo(); 98 } 99 100 public TypeInfoFactory getTypeInfoFactory() 101 { 102 if (typeInfoFactory == null) 103 { 104 try 105 { 106 typeInfoFactory = createDefaultTypeInfoFactory(); 107 } 108 catch (RuntimeException e) 109 { 110 throw e; 111 } 112 catch (Error e) 113 { 114 throw e; 115 } 116 catch (Throwable t) 117 { 118 throw new NestedRuntimeException("Cannot create TypeInfoFactory", t); 119 } 120 } 121 return typeInfoFactory; 122 } 123 124 public JoinpointFactoryBuilder getJoinpointFactoryBuilder() 125 { 126 if (joinpointFactoryBuilder == null) 127 { 128 try 129 { 130 joinpointFactoryBuilder = createDefaultJoinpointFactoryBuilder(); 131 } 132 catch (RuntimeException e) 133 { 134 throw e; 135 } 136 catch (Error e) 137 { 138 throw e; 139 } 140 catch (Throwable t) 141 { 142 throw new NestedRuntimeException("Cannot create JoinpointFactoryBuilder", t); 143 } 144 } 145 return joinpointFactoryBuilder; 146 } 147 148 public MetaDataContextFactory getMetaDataContextFactory() 149 { 150 if (metaDataContextFactory == null) 151 { 152 try 153 { 154 metaDataContextFactory = createDefaultMetaDataContextFactory(); 155 } 156 catch (RuntimeException e) 157 { 158 throw e; 159 } 160 catch (Error e) 161 { 162 throw e; 163 } 164 catch (Throwable t) 165 { 166 throw new NestedRuntimeException("Cannot create MetaDataContextFactory", t); 167 } 168 } 169 return metaDataContextFactory; 170 } 171 172 public DependencyBuilder getDependencyBuilder() 173 { 174 if (dependencyBuilder == null) 175 { 176 try 177 { 178 dependencyBuilder = createDefaultDependencyBuilder(); 179 } 180 catch (RuntimeException e) 181 { 182 throw e; 183 } 184 catch (Error e) 185 { 186 throw e; 187 } 188 catch (Throwable t) 189 { 190 throw new NestedRuntimeException("Cannot create DependencyBuilder", t); 191 } 192 } 193 return dependencyBuilder; 194 } 195 196 202 protected BeanInfoFactory getBeanInfoFactory() throws Throwable 203 { 204 if (beanInfoFactory == null) 205 beanInfoFactory = createDefaultBeanInfoFactory(); 206 return beanInfoFactory; 207 } 208 209 215 protected ClassAdapterFactory getClassAdapterFactory() throws Throwable 216 { 217 if (classAdapterFactory == null) 218 classAdapterFactory = createDefaultClassAdapterFactory(); 219 return classAdapterFactory; 220 } 221 222 228 protected abstract BeanInfoFactory createDefaultBeanInfoFactory() throws Throwable ; 229 230 236 protected abstract ClassAdapterFactory createDefaultClassAdapterFactory() throws Throwable ; 237 238 244 protected abstract TypeInfoFactory createDefaultTypeInfoFactory() throws Throwable ; 245 246 252 protected abstract JoinpointFactoryBuilder createDefaultJoinpointFactoryBuilder() throws Throwable ; 253 254 260 protected abstract MetaDataContextFactory createDefaultMetaDataContextFactory() throws Throwable ; 261 262 268 protected abstract DependencyBuilder createDefaultDependencyBuilder() throws Throwable ; 269 } 270 | Popular Tags |