1 22 package org.jboss.classadapter.plugins; 23 24 import org.jboss.classadapter.spi.ClassAdapter; 25 import org.jboss.classadapter.spi.ClassAdapterFactory; 26 import org.jboss.config.spi.Configuration; 27 import org.jboss.reflect.spi.ClassInfo; 28 import org.jboss.reflect.spi.TypeInfo; 29 import org.jboss.reflect.spi.TypeInfoFactory; 30 31 36 public class BasicClassAdapterFactory implements ClassAdapterFactory 37 { 38 39 protected Configuration configuration; 40 41 public Configuration getConfiguration() 42 { 43 return configuration; 44 } 45 46 public void setConfiguration(Configuration configuration) 47 { 48 this.configuration = configuration; 49 } 50 51 public ClassAdapter getClassAdapter(Class clazz) 52 { 53 TypeInfoFactory typeInfoFactory = configuration.getTypeInfoFactory(); 54 TypeInfo typeInfo = typeInfoFactory.getTypeInfo(clazz); 55 return getClassAdapter(typeInfo); 56 } 57 58 public ClassAdapter getClassAdapter(String name, ClassLoader cl) throws ClassNotFoundException 59 { 60 TypeInfoFactory typeInfoFactory = configuration.getTypeInfoFactory(); 61 TypeInfo typeInfo = typeInfoFactory.getTypeInfo(name, cl); 62 return getClassAdapter(typeInfo); 63 } 64 65 public ClassAdapter getClassAdapter(TypeInfo typeInfo) 66 { 67 if (typeInfo instanceof ClassInfo == false) 68 throw new IllegalArgumentException ("Not a class " + typeInfo.getName()); 69 ClassInfo classInfo = (ClassInfo) typeInfo; 70 71 return new BasicClassAdapter(this, classInfo); 72 } 73 } 74 | Popular Tags |