1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.asset;
16  
17  import com.liferay.portal.kernel.util.ListUtil;
18  import com.liferay.portlet.asset.AssetRendererFactoryRegistry;
19  import com.liferay.portlet.asset.model.AssetRendererFactory;
20  
21  import java.util.List;
22  import java.util.Map;
23  import java.util.concurrent.ConcurrentHashMap;
24  
25  /**
26   * <a href="AssetRendererFactoryRegistryImpl.java.html"><b><i>View Source</i>
27   * </b></a>
28   *
29   * @author Bruno Farache
30   * @author Marcellus Tavares
31   */
32  public class AssetRendererFactoryRegistryImpl
33      implements AssetRendererFactoryRegistry {
34  
35      public AssetRendererFactory getAssetRendererFactoryByClassName(
36          String className) {
37  
38          return _factoriesMapByClassName.get(className);
39      }
40  
41      public AssetRendererFactory getAssetRendererFactoryByType(String type) {
42          return _factoriesMapByClassType.get(type);
43      }
44  
45      public List<AssetRendererFactory> getAssetRendererFactories() {
46          return ListUtil.fromCollection(_factoriesMapByClassName.values());
47      }
48  
49      public void register(AssetRendererFactory assetRendererFactory) {
50          _factoriesMapByClassName.put(
51              assetRendererFactory.getClassName(), assetRendererFactory);
52          _factoriesMapByClassType.put(
53              assetRendererFactory.getType(), assetRendererFactory);
54      }
55  
56      public void unregister(AssetRendererFactory assetRendererFactory) {
57          _factoriesMapByClassName.remove(assetRendererFactory.getClassName());
58          _factoriesMapByClassType.remove(assetRendererFactory.getType());
59      }
60  
61      private Map<String, AssetRendererFactory> _factoriesMapByClassName =
62          new ConcurrentHashMap<String, AssetRendererFactory>();
63      private Map<String, AssetRendererFactory> _factoriesMapByClassType =
64          new ConcurrentHashMap<String, AssetRendererFactory>();
65  
66  }