org.apache.axis2.jaxws.util.WeakKey Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of axis2-metadata Show documentation
Show all versions of axis2-metadata Show documentation
JSR-181 and JSR-224 Annotations Processing
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.axis2.jaxws.util;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
/**
* Implement a WeakReference key to be used in a collection. Being a WeakReference, it will not
* prevent the key from being Garbage Collected. The key can only be created with a reference queue
* so that users of this class provide cleanup logic which uses the items in the reference queue to
* cleanup entries in the collection.
*
* Note that the ReferenceQueue will contain the WeakKey instance that assocaited with the
* referent that was GC'd. So, the elements on the ReferenceQueue can be used to directly access
* and remove entries in the collection it is a key for. For example, one could do something
* like the following in cleanup logic:
* Object gcKey = null;
* while ((gcKey = q.poll()) != null) {
* WeakKey wk = (WeakKey) gcKey;
* removedEntry = collection.remove(wk);
* ...
* }
*/
public class WeakKey extends WeakReference
© 2015 - 2024 Weber Informatics LLC | Privacy Policy