001/* 002 * (C) Copyright 2012 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Anahide Tchertchian 018 */ 019package org.nuxeo.runtime.model; 020 021import java.util.HashMap; 022import java.util.Map; 023 024/** 025 * Simple contribution registry, keeping up to date contributions in a map, and not handling merge. 026 * 027 * @since 5.6 028 * @deprecated since 10.3 use DefaultComponent descriptors management methods instead 029 */ 030@Deprecated 031public abstract class SimpleContributionRegistry<T> extends ContributionFragmentRegistry<T> { 032 033 protected Map<String, T> currentContribs = new HashMap<>(); 034 035 @Override 036 public void contributionUpdated(String id, T contrib, T newOrigContrib) { 037 currentContribs.put(id, contrib); 038 } 039 040 @Override 041 public void contributionRemoved(String id, T origContrib) { 042 currentContribs.remove(id); 043 } 044 045 @Override 046 public boolean isSupportingMerge() { 047 return false; 048 } 049 050 @Override 051 public T clone(T orig) { 052 throw new UnsupportedOperationException(); 053 } 054 055 @Override 056 public void merge(T src, T dst) { 057 throw new UnsupportedOperationException(); 058 } 059 060 protected T getCurrentContribution(String id) { 061 return currentContribs.get(id); 062 } 063 064}