1 package org.apache.axis2.context; 2 3 import java.io.Serializable ; 4 import java.util.HashMap ; 5 6 23 24 public abstract class AbstractContext implements Serializable { 25 26 protected transient final HashMap nonPersistentMap; 27 protected final HashMap persistentMap; 28 protected AbstractContext parent; 29 30 protected AbstractContext(AbstractContext parent) { 31 this.persistentMap = new HashMap (); 32 this.nonPersistentMap = new HashMap (); 33 this.parent = parent; 34 } 35 36 45 public void setProperty(String key, Object value, boolean persistent) { 46 if (persistent) { 47 persistentMap.put(key, value); 48 } else { 49 nonPersistentMap.put(key, value); 50 } 51 } 52 53 60 public void setProperty(String key, Object value) { 61 this.setProperty(key, value, false); 62 } 63 64 71 public Object getProperty(String key) { 72 return this.getProperty(key, false); 73 } 74 75 80 public Object getProperty(String key, boolean persistent) { 81 Object obj = null; 82 if (persistent) { 83 obj = persistentMap.get(key); 84 } 85 if(obj == null){ 86 obj = nonPersistentMap.get(key); 87 } 88 if (obj == null && parent != null) { 89 obj = parent.getProperty(key, persistent); 90 } 91 return obj; 92 } 93 96 public void setParent(AbstractContext context) { 97 parent = context; 98 } 99 100 103 public AbstractContext getParent() { 104 return parent; 105 } 106 107 } 108 | Popular Tags |