1 4 package com.tc.aspectwerkz; 5 6 import com.tc.aspectwerkz.definition.AspectDefinition; 7 8 import java.io.ObjectInputStream ; 9 import java.lang.ref.WeakReference ; 10 import java.util.HashMap ; 11 import java.util.Map ; 12 13 18 public final class AspectContext { 19 22 public static final Object [] EMPTY_OBJECT_ARRAY = new Object []{}; 23 24 27 private String m_name; 28 29 32 private String m_qName; 33 34 37 private transient WeakReference m_aspectClassRef; 38 39 42 private DeploymentModel m_deploymentModel; 43 44 47 private Map m_parameters = new HashMap (); 48 49 52 private Map m_metaData = new HashMap (); 53 54 57 private String m_uuid; 58 59 62 private transient AspectDefinition m_aspectDefinition; 63 64 68 private transient Object m_associatedObject; 69 70 80 public AspectContext(final String uuid, 81 final Class aspectClass, 82 final String name, 83 final DeploymentModel deploymentModel, 84 final AspectDefinition aspectDef, 85 final Map parameters, 86 final Object associated) { 87 m_uuid = uuid; 88 m_aspectClassRef = new WeakReference (aspectClass); 89 m_name = name; 90 m_qName = aspectDef.getQualifiedName(); 91 m_deploymentModel = deploymentModel; 92 m_aspectDefinition = aspectDef; 93 if (parameters != null) { 94 m_parameters = parameters; 95 } 96 m_associatedObject = associated; 97 } 98 99 104 public String getUuid() { 105 return m_uuid; 106 } 107 108 113 public String getName() { 114 return m_name; 115 } 116 117 122 public DeploymentModel getDeploymentModel() { 123 return m_deploymentModel; 124 } 125 126 131 public Class getAspectClass() { 132 return (Class ) m_aspectClassRef.get(); 133 } 134 135 142 public AspectDefinition getAspectDefinition() { 143 return m_aspectDefinition; 144 } 145 146 152 public void setParameter(final String name, final String value) { 153 m_parameters.put(name, value); 154 } 155 156 162 public String getParameter(final String name) { 163 return (String ) m_parameters.get(name); 164 } 165 166 172 public void addMetaData(final Object key, final Object value) { 173 m_metaData.put(key, value); 174 } 175 176 182 public Object getMetaData(final Object key) { 183 return m_metaData.get(key); 184 } 185 186 192 public Object getAssociatedObject() { 193 return m_associatedObject; 194 } 195 196 202 private void readObject(final ObjectInputStream stream) throws Exception { 203 ObjectInputStream.GetField fields = stream.readFields(); 204 m_uuid = (String ) fields.get("m_uuid", null); 205 m_name = (String ) fields.get("m_name", null); 206 m_qName = (String ) fields.get("m_qName", null); 207 Class aspectClass = Class.forName(m_name); 208 m_aspectClassRef = new WeakReference (aspectClass); 209 m_deploymentModel = (DeploymentModel) fields.get("m_deploymentModel", DeploymentModel.PER_JVM); 210 m_parameters = (Map ) fields.get("m_parameters", new HashMap ()); 211 m_metaData = (Map ) fields.get("m_metaData", new HashMap ()); 212 213 } 215 } | Popular Tags |