1 12 package org.aspectj.lang.reflect; 13 14 import java.lang.ref.WeakReference ; 15 import java.util.Map ; 16 import java.util.WeakHashMap ; 17 18 import org.aspectj.internal.lang.reflect.AjTypeImpl; 19 20 25 public class AjTypeSystem { 26 27 private static Map <Class , WeakReference <AjType>> ajTypes = new WeakHashMap <Class ,WeakReference <AjType>>(); 28 29 36 public static <T> AjType<T> getAjType(Class <T> fromClass) { 37 if (ajTypes.containsKey(fromClass)) { 38 WeakReference <AjType> weakRefToAjType = ajTypes.get(fromClass); 39 AjType<T> theAjType = weakRefToAjType.get(); 40 if (theAjType != null) { 41 return theAjType; 42 } else { 43 theAjType = new AjTypeImpl<T>(fromClass); 44 ajTypes.put(fromClass, new WeakReference <AjType>(theAjType)); 45 return theAjType; 46 } 47 } 48 AjType<T> theAjType = new AjTypeImpl<T>(fromClass); 50 ajTypes.put(fromClass, new WeakReference <AjType>(theAjType)); 51 return theAjType; 52 } 53 } 54 | Popular Tags |