1 22 package org.jboss.aop.metadata; 23 24 import org.jboss.aop.joinpoint.Invocation; 25 import org.jboss.aop.util.PayloadKey; 26 27 28 38 public class ThreadMetaData implements MetaDataResolver 39 { 40 ThreadLocal metaData = new ThreadLocal (); 41 42 public void addMetaData(Object tag, Object attr, Object value) 43 { 44 addMetaData(tag, attr, value, PayloadKey.MARSHALLED); 45 } 46 47 public void addMetaData(Object tag, Object attr, Object value, PayloadKey type) 48 { 49 SimpleMetaData data = (SimpleMetaData)metaData.get(); 50 if (data == null) 51 { 52 data = new SimpleMetaData(); 53 metaData.set(data); 54 } 55 data.addMetaData(tag, attr, value, type); 56 } 57 58 public Object getMetaData(Object tag, Object attr) 59 { 60 SimpleMetaData data = (SimpleMetaData)metaData.get(); 61 if (data == null) return null; 62 return data.getMetaData(tag, attr); 63 } 64 65 public synchronized void removeMetaData(Object tag, Object attr) 66 { 67 SimpleMetaData data = (SimpleMetaData)metaData.get(); 68 if (data == null) return; 69 data.removeMetaData(tag, attr); 70 } 71 72 public synchronized void removeGroupData(Object tag) 73 { 74 SimpleMetaData data = (SimpleMetaData)metaData.get(); 75 if (data == null) return; 76 data.removeGroupData(tag); 77 } 78 79 public Object resolve(Invocation invocation, Object tag, Object attr) 80 { 81 return getMetaData(tag, attr); 82 } 83 84 public SimpleMetaData getAllMetaData(Invocation invocation) 85 { 86 return (SimpleMetaData)metaData.get(); 87 } 88 public void clear() 89 { 90 metaData.set(null); 91 } 92 93 94 private static final ThreadMetaData me = new ThreadMetaData(); 95 public static ThreadMetaData instance() { return me; } 96 } 97 | Popular Tags |