001/*
002 * (C) Copyright 2006-2016 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 *     tiry
018 */
019package org.nuxeo.ecm.core.event.pipe;
020
021import org.nuxeo.runtime.model.ContributionFragmentRegistry;
022
023import java.util.ArrayList;
024import java.util.HashMap;
025import java.util.List;
026import java.util.Map;
027import java.util.Set;
028
029/**
030 * Contribution registry for EventPipeDescriptor
031 *
032 * @since 8.4
033 */
034public class EventPipeRegistry extends ContributionFragmentRegistry<EventPipeDescriptor> {
035
036    protected Map<String, EventPipeDescriptor> reg = new HashMap<>();
037
038    @Override
039    public EventPipeDescriptor clone(EventPipeDescriptor desc) {
040        return desc.clone();
041    }
042
043    @Override
044    public void contributionRemoved(String name, EventPipeDescriptor desc) {
045        reg.remove(name);
046    }
047
048    @Override
049    public void contributionUpdated(String name, EventPipeDescriptor desc, EventPipeDescriptor origin) {
050        reg.put(name, desc);
051    }
052
053    @Override
054    public String getContributionId(EventPipeDescriptor desc) {
055        return desc.getName();
056    }
057
058    @Override
059    public void merge(EventPipeDescriptor src, EventPipeDescriptor dest) {
060        dest.merge(src);
061    }
062
063    public EventPipeDescriptor getPipeDescriptor(String name) {
064        return reg.get(name);
065    }
066
067    public Set<String> getPipeNames() {
068        return reg.keySet();
069    }
070
071    public List<EventPipeDescriptor> getPipes() {
072        return new ArrayList<>(reg.values());
073    }
074
075
076}