@Override protected <T> Object toReference(AbstractReferenceMap.ReferenceStrength type, T referent, int hash) { if (referent instanceof IRemotePeer) { RemotePeerReferenceMap<?,?> parent; try { parent = (RemotePeerReferenceMap) ReflectHelper.getPrivateFieldValue( AbstractReferenceMap.ReferenceEntry.class, "parent", this); } catch (Exception e) { throw new RuntimeException("An unexpected runtime exception occurred", e); } switch (type) { case SOFT: return new RemotePeerSoftRef(hash, (IRemotePeer) referent, parent.remotePeerQueue); case WEAK: return new RemotePeerWeakRef(hash, (IRemotePeer) referent, parent.remotePeerQueue); default: break; } } return super.toReference(type, referent, hash); }
AbstractTransaction(String id, StorageAccessIF access) { this.id = id; this.access = access; this.mapping = access.getStorage().getMapping(); // Map containing named queries this.querymap = new HashMap<String, QueryIF>(); // Identity map - maintains the relationships between object // identities and the single(ton) instances used with the // transaction. This enforces the constraint that only one // instance per object identity should exist at a given time in a // transaction. // NOTE: Even though it's the keys that are garbage collected // there is a strict mapping between IdentityIF and PersistentIF // that lets us do this, i.e. the objects reference their // identities, so the identity will not be garbage collected as // long as the object is reachable. this.identity_map = new ReferenceMap<IdentityIF, PersistentIF>(AbstractReferenceMap.ReferenceStrength.HARD, AbstractReferenceMap.ReferenceStrength.SOFT); log.debug(getId() + ": Transaction created."); this.timestamp = System.currentTimeMillis(); }
@SuppressWarnings("unchecked") private ResourceManager() { // resources = new HashMap<String, IResource>(); resources = new ReferenceMap(AbstractReferenceMap.ReferenceStrength.SOFT, AbstractReferenceMap.ReferenceStrength.SOFT, true); random = new SecureRandom(); }
/** * Constructs a new {@code BasicRemotePeerRegistry} instance. */ @SuppressWarnings("unchecked") public BasicRemotePeerRegistry() { backingStore = new RemotePeerReferenceMap(AbstractReferenceMap.ReferenceStrength.WEAK, AbstractReferenceMap.ReferenceStrength.WEAK, true); automationBackingStore = new ReferenceMap(AbstractReferenceMap.ReferenceStrength.WEAK, AbstractReferenceMap.ReferenceStrength.WEAK, true); automationIndices = new HashMap<>(); setAutomationEnabled(true); }
@Override protected AbstractReferenceMap.ReferenceEntry<K, V> createEntry(HashEntry<K, V> next, int hashCode, K key, V value) { if (value instanceof IRemotePeer) { return new RemotePeerReferenceEntry(this, next, hashCode, key, value); } return super.createEntry(next, hashCode, key, value); }
public LocatorLookup(String qname, TransactionIF txn, TopicMapIF tm, int lrusize, E nullObject) { this.qname = qname; this.txn = txn; this.tm = tm; this.lrusize = lrusize; this.cache = new ReferenceMap<LocatorIF, E>(AbstractReferenceMap.ReferenceStrength.SOFT, AbstractReferenceMap.ReferenceStrength.HARD); this.lru = new LRUMap<LocatorIF, E>(lrusize); NULLOBJECT = nullObject; }
public QueryLookup(String qname, TransactionIF txn, int lrusize, V nullObject) { this.qname = qname; this.txn = txn; this.cache = new ReferenceMap(AbstractReferenceMap.ReferenceStrength.SOFT, AbstractReferenceMap.ReferenceStrength.HARD); this.lru = new LRUMap(lrusize); NULLOBJECT = nullObject; }
/** * Constructor. */ private ObjectMap() { globalPC = new LinkedList<Object>(); globalPC.push(SecurityLevel.bottom()); actualReturnLevel = SecurityLevel.top(); actualArguments = new ArrayList<Object>(); innerMap = new ReferenceIdentityMap<Object, HashMap<String, Object>>( AbstractReferenceMap.ReferenceStrength.WEAK, AbstractReferenceMap.ReferenceStrength.WEAK); }
/** * Constructor. */ private ObjectMap() { globalPC = new LinkedList<Object>(); globalPC.push(CurrentSecurityDomain.bottom()); actualReturnLevel = CurrentSecurityDomain.bottom(); // was top!?! actualArguments = new ArrayList<Object>(); innerMap = new ReferenceIdentityMap<Object, HashMap<String, Object>>( AbstractReferenceMap.ReferenceStrength.WEAK, AbstractReferenceMap.ReferenceStrength.WEAK); }
@SuppressWarnings("unchecked") private Map<Serializable, IEntity> createContractStoreMap() { return new ReferenceMap(AbstractReferenceMap.ReferenceStrength.HARD, AbstractReferenceMap.ReferenceStrength.WEAK, true); }
public RemotePeerReferenceMap(AbstractReferenceMap.ReferenceStrength keyType, AbstractReferenceMap.ReferenceStrength valueType, boolean purgeValues) { super(keyType, valueType, purgeValues); }
private <K, V> Map<K, V> createSoftHashMap() { return new ReferenceMap<K, V>(AbstractReferenceMap.ReferenceStrength.SOFT, AbstractReferenceMap.ReferenceStrength.HARD); }
public BidiReferenceMap(AbstractReferenceMap.ReferenceStrength keyType, AbstractReferenceMap.ReferenceStrength valueType, int capacity, float loadFactor, boolean purgeValues){ super(new ReferenceMap<K,V>(keyType,valueType,capacity,loadFactor,purgeValues), new ReferenceMap<V,K>(keyType,valueType,capacity,loadFactor,purgeValues),null); }
public BidiReferenceMap(AbstractReferenceMap.ReferenceStrength keyValueType){ this(keyValueType,keyValueType,16,0.75f,true); }