Package java.lang.ref

Examples of java.lang.ref.SoftReference


            Object referent = reference.get();
            ImagingListenerImpl listener;
            if (referent == null) {
                // First invocation or SoftReference has been cleared.
                reference =
                    new SoftReference(listener = new ImagingListenerImpl());
            } else {
                // SoftReference has not been cleared.
                listener = (ImagingListenerImpl)referent;
            }
View Full Code Here


        ZipEntry entry = zipFile.getEntry("META-INF/MANIFEST.MF");

        // Get a buffer for this thread if there is one already otherwise,
        // create one of size DEFAULT_BUFFER (64K) if the manifest is less
        // than 64k or of the size of the manifest.
        SoftReference ref = (SoftReference) m_defaultBuffer.get();
        byte[] bytes = null;
        if (ref != null)
        {
            bytes = (byte[]) ref.get();
        }
        int size = (int) entry.getSize();
        if (bytes == null)
        {
            bytes = new byte[size > DEFAULT_BUFFER ? size : DEFAULT_BUFFER];
            m_defaultBuffer.set(new SoftReference(bytes));
        }
        else if (size > bytes.length)
        {
            bytes = new byte[size];
            m_defaultBuffer.set(new SoftReference(bytes));
        }

        // Now read in the manifest in one go into the bytes array.
        // The InputStream is already
        // buffered and can handle up to 64K buffers in one go.
View Full Code Here

            }
        }

        try
        {
            SoftReference collectionEntry = null;

            PermissionCollection collection = null;

            synchronized (m_cache)
            {
                collectionEntry = (SoftReference) m_cache.get(targetClass);
            }

            if (collectionEntry != null)
            {
                collection = (PermissionCollection) collectionEntry.get();
            }

            if (collection == null)
            {
                collection = target.newPermissionCollection();

                if (collection == null)
                {
                    collection = new DefaultPermissionCollection();
                }

                for (int i = 0; i < m_permissionInfos.length; i++)
                {
                    PermissionInfo permissionInfo = m_permissionInfos[i];
                    String infoType = permissionInfo.getType();
                    String permissionType = targetClass.getName();

                    if (infoType.equals(permissionType))
                    {
                        Permission permission = createPermission(
                            permissionInfo, targetClass);

                        if (permission != null)
                        {
                            collection.add(permission);
                        }
                    }
                }

                synchronized (m_cache)
                {
                    m_cache.put(new Entry(target.getClass(), m_queue),
                        new SoftReference(collection));
                }
            }

            return collection.implies(target);
        }
View Full Code Here

    private Permission getFromCache(String encoded, Class target)
    {
        synchronized (m_permissionCache)
        {
            SoftReference ref = (SoftReference) m_permissionCache.get(encoded);
            if (ref != null)
            {
                Map inner = (Map) ref.get();
                if (inner != null)
                {
                    Entry entry = (Entry) inner.get(target);
                    if (entry != null)
                    {
View Full Code Here

    public void bundleChanged( BundleEvent event )
    {
        if ( event.getType() == BundleEvent.STOPPING )
        {
            SoftReference mtir = ( SoftReference ) this.bundleMetaTypeInformation.remove( new Long( event.getBundle()
                .getBundleId() ) );
            if ( mtir != null )
            {
                MetaTypeInformationImpl mti = ( MetaTypeInformationImpl ) mtir.get();
                if ( mti != null )
                {
                    mti.dispose();
                }
            }
View Full Code Here

                }
            }
        }

        this.bundleMetaTypeInformation.put( new Long( bundle.getBundleId() ),
            new SoftReference( mti ) );
    }
View Full Code Here

    }


    private MetaTypeInformationImpl getMetaTypeInformationInternal( final Bundle bundle )
    {
        SoftReference mtir = ( SoftReference ) this.bundleMetaTypeInformation.get( new Long( bundle.getBundleId() ) );
        return ( MetaTypeInformationImpl ) ( ( mtir == null ) ? null : mtir.get() );
    }
View Full Code Here

                for (int i = 0; i < numSuppressedKeys; i++) {
                    suppressedKeys.add(SUPPRESSED_KEYS[i]);
                }

                // Cache the Vector of suppressed keys.
                suppressedKeyReference = new SoftReference(suppressedKeys);
            }
        }

        return suppressedKeys;
    }
View Full Code Here

                    }
                }
            }

            // Cache the table.
            hintTableReference = new SoftReference(table);
        }

        return table;
    }
View Full Code Here

                for(int i = 0; i < numSuppressedKeys; i++) {
                    suppressedKeys.add(SUPPRESSED_KEYS[i]);
                }

                // Cache the Vector of suppressed keys.
                suppressedKeyReference = new SoftReference(suppressedKeys);
            }
        }

        return suppressedKeys;
    }
View Full Code Here

TOP

Related Classes of java.lang.ref.SoftReference

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.