2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
23 package org.onap.aai.sparky.search.registry;
25 import java.util.ArrayList;
26 import java.util.List;
28 import org.onap.aai.sparky.search.api.SearchProvider;
31 * Make this a java-scoped singleton to resolve the contextual issue spanning a Spring Context and
32 * accessing the SPR in other parts of the code that are not directly instantiated by a Spring Bean.
33 * Eventually the SPR doesn’t have to be a real singleton, it could simply be a Spring bean scoped
34 * as a singleton and then wired in via dependency injection to the classes that need it. But I’m
35 * not there yet. This will get a demonstrable extension mechanism in place quickly at practically
36 * no cost, beyond what’s already in the email plus some testing.
39 public class SearchProviderRegistry {
41 private List<SearchProvider> searchProviders;
43 public SearchProviderRegistry() {
44 searchProviders = new ArrayList<SearchProvider>();
47 public List<SearchProvider> getSearchProviders() {
48 return searchProviders;
51 public final void addSearchProvider(SearchProvider searchProvider) {
53 if (searchProvider == null) {
57 if (!searchProviders.contains(searchProvider)) {
58 searchProviders.add(searchProvider);
62 public final void addSearchProviders(List<SearchProvider> searchProviders) {
64 if (searchProviders == null) {
68 for (SearchProvider searchProvider : searchProviders) {
69 addSearchProvider(searchProvider);