Package java.util

Examples of java.util.WeakHashMap$Holder


                      Transaction txn)
        throws DatabaseException {

        if (cdbMode) {
            CdbCursors cdbCursors = null;
            WeakHashMap cdbCursorsMap = (WeakHashMap) localCdbCursors.get();
            if (cdbCursorsMap == null) {
                cdbCursorsMap = new WeakHashMap();
                localCdbCursors.set(cdbCursorsMap);
            } else {
                cdbCursors = (CdbCursors) cdbCursorsMap.get(db);
            }
            if (cdbCursors == null) {
                cdbCursors = new CdbCursors();
                cdbCursorsMap.put(db, cdbCursors);
            }

            /*
             * In CDB mode the cursorConfig specified by the user is ignored
             * and only the writeCursor parameter is honored.  This is the only
View Full Code Here


     */
    Cursor dupCursor(Cursor cursor, boolean writeCursor, boolean samePosition)
        throws DatabaseException {

        if (cdbMode) {
            WeakHashMap cdbCursorsMap = (WeakHashMap) localCdbCursors.get();
            if (cdbCursorsMap != null) {
                Database db = cursor.getDatabase();
                CdbCursors cdbCursors = (CdbCursors) cdbCursorsMap.get(db);
                if (cdbCursors != null) {
                    List cursors = writeCursor ? cdbCursors.writeCursors
                                               : cdbCursors.readCursors;
                    if (cursors.contains(cursor)) {
                        Cursor newCursor = cursor.dup(samePosition);
View Full Code Here

        if (cursor == null) {
            return;
        }
        if (cdbMode) {
            WeakHashMap cdbCursorsMap = (WeakHashMap) localCdbCursors.get();
            if (cdbCursorsMap != null) {
                Database db = cursor.getDatabase();
                CdbCursors cdbCursors = (CdbCursors) cdbCursorsMap.get(db);
                if (cdbCursors != null) {
                    if (cdbCursors.readCursors.remove(cursor) ||
                        cdbCursors.writeCursors.remove(cursor)) {
                        cursor.close();
                        return;
View Full Code Here

        // Update the handler activations.
        final IHandlerService service = (IHandlerService) serviceLocator
            .getService(IHandlerService.class);
        Map activationsByActionId = null;
        if (activationsByActionIdByServiceLocator == null) {
          activationsByActionIdByServiceLocator = new WeakHashMap();
          activationsByActionId = new HashMap();
          activationsByActionIdByServiceLocator.put(serviceLocator,
              activationsByActionId);
        } else {
          activationsByActionId = (Map) activationsByActionIdByServiceLocator
View Full Code Here

     * Puts an ElementsByTagName object in the cache.
     */
    public void putElementsByTagName(Node n, String ns, String ln,
                                     ElementsByTagName l) {
        if (elementsByTagNames == null) {
            elementsByTagNames = new WeakHashMap(11);
        }
        SoftDoublyIndexedTable t;
        t = (SoftDoublyIndexedTable)elementsByTagNames.get(n);
        if (t == null) {
            elementsByTagNames.put(n, t = new SoftDoublyIndexedTable());
View Full Code Here

            indexes.put(name, info);
            patternMap.put(pattern, info);

            Map tbl = (Map) bestIndexers.get(style);
            if (tbl == null) {
                tbl = new WeakHashMap();
                bestIndexers.put(style, tbl);
            }
            tbl.clear();
            idxList = (IndexerInfo[]) indexes.values().toArray(EmptyIndexerInfo);
View Full Code Here

        String style = idx.style;
        patternMap.remove(idx.pattern);

        Map tbl = (Map) bestIndexers.get(style);
        if (tbl == null) {
            tbl = new WeakHashMap();
            bestIndexers.put(style, tbl);
        }
        tbl.clear();

        idxList = (IndexerInfo[]) indexes.values().toArray(EmptyIndexerInfo);
View Full Code Here

            }
        };
        lib.callVoidCallback(cb);
        assertTrue("Callback not called", called[0]);
       
        Map refs = new WeakHashMap(callbackCache());
        assertTrue("Callback not cached", refs.containsKey(cb));
        CallbackReference ref = (CallbackReference)refs.get(cb);
        refs = callbackCache();
        Pointer cbstruct = ref.cbstruct;
       
        cb = null;
        System.gc();
        for (int i = 0; i < 100 && (ref.get() != null || refs.containsValue(ref)); ++i) {
            try {
                Thread.sleep(10); // Give the GC a chance to run
                System.gc();
            } finally {}
        }
        assertNull("Callback not GC'd", ref.get());
        assertFalse("Callback still in map", refs.containsValue(ref));
       
        ref = null;
        System.gc();
        for (int i = 0; i < 100 && (cbstruct.peer != 0 || refs.size() > 0); ++i) {
            // Flush weak hash map
            refs.size();
            try {
                Thread.sleep(10); // Give the GC a chance to run
                System.gc();
            } finally {}
        }
View Full Code Here

        Pointer handle = f.invokePointer(new Object[] { Native.jnidispatchPath != null ? Native.jnidispatchPath : "jnidispatch" });
        assertNotNull("GetModuleHandle(\"jnidispatch\") failed: " + Native.getLastError(), handle);
        assertEquals("Wrong module HANDLE for DLL function pointer", handle, pref.getValue());

        // Check slot re-use
        Map refs = new WeakHashMap(callbackCache());
        assertTrue("Callback not cached", refs.containsKey(cb));
        CallbackReference ref = (CallbackReference)refs.get(cb);
        refs = callbackCache();
        Pointer cbstruct = ref.cbstruct;
        Pointer first_fptr = cbstruct.getPointer(0);
       
        cb = null;
        System.gc();
        for (int i = 0; i < 100 && (ref.get() != null || refs.containsValue(ref)); ++i) {
            Thread.sleep(10); // Give the GC a chance to run
            System.gc();
        }
        assertNull("Callback not GC'd", ref.get());
        assertFalse("Callback still in map", refs.containsValue(ref));
       
        ref = null;
        System.gc();
        for (int i = 0; i < 100 && (cbstruct.peer != 0 || refs.size() > 0); ++i) {
            // Flush weak hash map
            refs.size();
            Thread.sleep(10); // Give the GC a chance to run
            System.gc();
        }
        assertEquals("Callback trampoline not freed", 0, cbstruct.peer);

        // Next allocation should be at same place
        called[0] = false;
        cb = new TestCallback();

        lib.callVoidCallback(cb);
        ref = (CallbackReference)refs.get(cb);
        cbstruct = ref.cbstruct;

        assertTrue("Callback not called", called[0]);
        assertEquals("Same (in-DLL) address should be re-used for DLL callbacks after callback is GCd",
                     first_fptr, cbstruct.getPointer(0));
View Full Code Here

     * for cleanup during commit/rollback or close.
     * @param lobReference LOB Object
     */
    void addLOBReference (Object lobReference) {
        if (rootConnection.lobReferences == null) {
            rootConnection.lobReferences = new WeakHashMap ();
        }
        rootConnection.lobReferences.put (lobReference, null);
    }
View Full Code Here

TOP

Related Classes of java.util.WeakHashMap$Holder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.