1 /*
2 * This file is part of *** M y C o R e ***
3 * See http://www.mycore.de/ for details.
4 *
5 * MyCoRe is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * MyCoRe is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with MyCoRe. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 package org.mycore.common.processing;
20
21 import java.util.stream.Stream;
22
23 import org.mycore.common.config.MCRConfiguration2;
24
25 /**
26 * Registry for {@link MCRProcessable} and {@link MCRProcessableCollection}.
27 * Can be used for managing and monitoring purposes.
28 *
29 * @author Matthias Eichner
30 */
31 public interface MCRProcessableRegistry {
32
33 /**
34 * Return the default instance of the processable registry
35 *
36 * @return the singleton instance
37 */
38 static MCRProcessableRegistry getSingleInstance() {
39 return MCRConfiguration2
40 .<MCRProcessableRegistry>getSingleInstanceOf("MCR.Processable.Registry.Class").orElseThrow();
41 }
42
43 /**
44 * Registers a new collection to the registry.
45 *
46 * @param collection the collection to register
47 */
48 void register(MCRProcessableCollection collection);
49
50 /**
51 * Removes a collection from the registry
52 *
53 * @param collection the collection to remove
54 */
55 void unregister(MCRProcessableCollection collection);
56
57 /**
58 * Streams all the collections of this registry.
59 *
60 * @return stream of the registry content.
61 */
62 Stream<MCRProcessableCollection> stream();
63
64 /**
65 * Adds a new listener.
66 *
67 * @param listener the listener to add
68 */
69 void addListener(MCRProcessableRegistryListener listener);
70
71 /**
72 * Removes a listener.
73 *
74 * @param listener the listener to remove
75 */
76 void removeListener(MCRProcessableRegistryListener listener);
77
78 }