1 29 30 package com.caucho.loader.enhancer; 31 32 import com.caucho.bytecode.JClass; 33 import com.caucho.bytecode.JavaClass; 34 import com.caucho.config.ConfigException; 35 import com.caucho.java.gen.GenClass; 36 import com.caucho.util.L10N; 37 38 import java.util.logging.Logger ; 39 40 43 public class ClassEnhancerConfig implements ClassEnhancer { 44 private static final L10N L = new L10N(ClassEnhancerConfig.class); 45 46 private static final Logger log = 47 Logger.getLogger(ClassEnhancerConfig.class.getName()); 48 49 private EnhancerManager _manager; 50 51 private Class _annotation; 52 private Class _type; 53 private boolean _isStatic = true; 54 55 private ClassEnhancer _enhancer; 56 57 60 public void setEnhancerManager(EnhancerManager manager) 61 { 62 _manager = manager; 63 } 64 65 68 public void setAnnotation(Class ann) 69 { 70 _annotation = ann; 71 } 72 73 76 public Class getAnnotation() 77 { 78 return _annotation; 79 } 80 81 84 public void setType(Class type) 85 throws Exception 86 { 87 _type = type; 88 89 if (ClassEnhancer.class.isAssignableFrom(type)) { 90 _enhancer = (ClassEnhancer) type.newInstance(); 91 } 92 else 93 throw new ConfigException(L.l("'{0}' is an unsupported class enhancer type. ClassEnhancer is required.", 94 type.getName())); 95 } 96 97 100 public void setStatic(boolean isStatic) 101 { 102 _isStatic = isStatic; 103 } 104 105 108 public Object createInit() 109 { 110 return _enhancer; 111 } 112 113 116 public void init() 117 throws ConfigException 118 { 119 } 121 122 125 public boolean shouldEnhance(String className) 126 { 127 return _enhancer.shouldEnhance(className); 128 } 129 130 133 public void preEnhance(JavaClass baseClass) 134 throws Exception 135 { 136 _enhancer.preEnhance(baseClass); 137 } 138 139 142 public void enhance(GenClass genClass, 143 JClass baseClass, 144 String extClassName) 145 throws Exception 146 { 147 _enhancer.enhance(genClass, baseClass, extClassName); 148 } 149 150 153 public void postEnhance(JavaClass extClass) 154 throws Exception 155 { 156 _enhancer.postEnhance(extClass); 157 } 158 } 159 | Popular Tags |