/** * Copyright (c) 2000-present Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ package com.liferay.portal.search.web.facet.util; import com.liferay.portal.search.web.facet.SearchFacet; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; import org.osgi.service.component.annotations.ReferenceCardinality; import org.osgi.service.component.annotations.ReferencePolicy; import org.osgi.service.component.annotations.ReferencePolicyOption; /** * @author Eudaldo Alonso */ @Component(immediate = true, service = SearchFacetTracker.class) public class SearchFacetTracker { public static List<SearchFacet> getSearchFacets() { return _searchFacets; } @Reference( cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC, policyOption = ReferencePolicyOption.GREEDY, unbind = "removeSearchFacet" ) protected void addSearchFacet(SearchFacet searchFacet) { _searchFacets.add(searchFacet); } protected void removeSearchFacet(SearchFacet searchFacet) { _searchFacets.remove(searchFacet); } private static final List<SearchFacet> _searchFacets = new CopyOnWriteArrayList<>(); }