jetty/jetty.project

ContainerLifeCycleMap

クローズ

#13,647 opened on 2025/10/02

 (1 件のコメント) (0 件のリアクション) (0 人の担当者)Java (1,913 件のフォーク)batch import
EnhancementHelp Wanted

Repository metrics

Stars
 (3,701 個のスター)
PR merge metrics
 (平均マージ 6d 14h) (30d で 48 merged PRs)

説明

Jetty version(s) Implement a ContainerLifeCycleMap that tracks values as beans.

Enhancement Description

package org.eclipse.jetty.util.component;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class ContainerLifeCycleMap<K, V extends LifeCycle> extends ContainerLifeCycle implements Map<K, V>, Container
{
    private final Map<K, V> _map = new HashMap<>();

    @Override
    public Set<Entry<K, V>> entrySet()
    {
        return _map.entrySet();
    }

    @Override
    public int size()
    {
        return _map.size();
    }

    @Override
    public boolean isEmpty()
    {
        return _map.isEmpty();
    }

    @Override
    public boolean containsKey(Object key)
    {
        return _map.containsKey(key);
    }

    @Override
    public boolean containsValue(Object value)
    {
        return _map.containsValue(value);
    }

    @Override
    public V get(Object key)
    {
        return _map.get(key);
    }

    @Override
    public V put(K key, V value)
    {
        V old = _map.put(key, value);
        updateBean(old, value);
        return old;
    }

    @Override
    public V remove(Object key)
    {
        return _map.remove(key);
    }

    @Override
    public void putAll(Map<? extends K, ? extends V> m)
    {
        for (Entry<? extends K, ? extends V> entry : m.entrySet())
        {
            V old = put(entry.getKey(), entry.getValue());
            updateBean(old, entry.getValue());
        }
    }

    @Override
    public void clear()
    {
        for (V v : _map.values())
            removeBean(v);
        _map.clear();
    }

    @Override
    public Set<K> keySet()
    {
        // TODO we need to wrap the set to track modifications to it, so we can update beans
        return _map.keySet();
    }

    @Override
    public Collection<V> values()
    {
        // TODO we need to wrap the collection to track modifications to it, so we can update beans
        return _map.values();
    }
}

コントリビューターガイド