001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.resiliency.spi;
016    
017    import com.liferay.portal.kernel.resiliency.PortalResiliencyException;
018    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
019    
020    import java.rmi.RemoteException;
021    
022    import java.util.Set;
023    
024    /**
025     * @author Shuyang Zhou
026     */
027    public class SPIRegistryUtil {
028    
029            public static void addExcludedPortletId(String portletId) {
030                    getSPIRegistry().addExcludedPortletId(portletId);
031            }
032    
033            public static SPI getErrorSPI() {
034                    return getSPIRegistry().getErrorSPI();
035            }
036    
037            public static Set<String> getExcludedPortletIds() {
038                    return getSPIRegistry().getExcludedPortletIds();
039            }
040    
041            public static SPI getPortletSPI(String portletId)
042                    throws PortalResiliencyException {
043    
044                    return getSPIRegistry().getPortletSPI(portletId);
045            }
046    
047            public static SPI getServletContextSPI(String servletContextName)
048                    throws PortalResiliencyException {
049    
050                    return getSPIRegistry().getServletContextSPI(servletContextName);
051            }
052    
053            public static SPIRegistry getSPIRegistry() {
054                    PortalRuntimePermission.checkGetBeanProperty(SPIRegistryUtil.class);
055    
056                    return _spiRegistry;
057            }
058    
059            public static void registerSPI(SPI spi) throws RemoteException {
060                    getSPIRegistry().registerSPI(spi);
061            }
062    
063            public static void removeExcludedPortletId(String portletId) {
064                    getSPIRegistry().removeExcludedPortletId(portletId);
065            }
066    
067            public static void setSPIRegistryValidator(
068                    SPIRegistryValidator spiRegistryValidator) {
069    
070                    getSPIRegistry().setSPIRegistryValidator(spiRegistryValidator);
071            }
072    
073            public static void unregisterSPI(SPI spi) {
074                    getSPIRegistry().unregisterSPI(spi);
075            }
076    
077            public void setSPIRegistry(SPIRegistry spiRegistry) {
078                    PortalRuntimePermission.checkSetBeanProperty(SPIRegistryUtil.class);
079    
080                    _spiRegistry = spiRegistry;
081            }
082    
083            private static SPIRegistry _spiRegistry;
084    
085    }