001    /**
002     * Copyright (c) 2000-present 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.util;
016    
017    import com.liferay.portal.kernel.dao.jdbc.aop.DynamicDataSourceTargetSource;
018    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
019    import com.liferay.portal.kernel.spring.osgi.OSGiBeanProperties;
020    
021    import javax.mail.Session;
022    
023    import javax.sql.DataSource;
024    
025    /**
026     * @author Brian Wing Shun Chan
027     * @author Michael Young
028     */
029    @OSGiBeanProperties(service = InfrastructureUtil.class)
030    public class InfrastructureUtil {
031    
032            public static DataSource getDataSource() {
033                    PortalRuntimePermission.checkGetBeanProperty(
034                            InfrastructureUtil.class, "dataSource");
035    
036                    return _dataSource;
037            }
038    
039            public static DynamicDataSourceTargetSource
040                    getDynamicDataSourceTargetSource() {
041    
042                    PortalRuntimePermission.checkGetBeanProperty(
043                            InfrastructureUtil.class, "dynamicDataSourceTargetSource");
044    
045                    return _dynamicDataSourceTargetSource;
046            }
047    
048            public static Session getMailSession() {
049                    PortalRuntimePermission.checkGetBeanProperty(
050                            InfrastructureUtil.class, "mailSession");
051    
052                    return _mailSession;
053            }
054    
055            public static Object getTransactionManager() {
056                    PortalRuntimePermission.checkGetBeanProperty(
057                            InfrastructureUtil.class, "transactionManager");
058    
059                    return _transactionManager;
060            }
061    
062            public void setDataSource(DataSource dataSource) {
063                    PortalRuntimePermission.checkSetBeanProperty(getClass(), "dataSource");
064    
065                    _dataSource = dataSource;
066            }
067    
068            public void setDynamicDataSourceTargetSource(
069                    DynamicDataSourceTargetSource dynamicDataSourceTargetSource) {
070    
071                    PortalRuntimePermission.checkSetBeanProperty(
072                            getClass(), "dynamicDataSourceTargetSource");
073    
074                    _dynamicDataSourceTargetSource = dynamicDataSourceTargetSource;
075            }
076    
077            public void setMailSession(Session mailSession) {
078                    PortalRuntimePermission.checkSetBeanProperty(getClass(), "mailSession");
079    
080                    _mailSession = mailSession;
081            }
082    
083            public void setTransactionManager(Object transactionManager) {
084                    PortalRuntimePermission.checkSetBeanProperty(
085                            getClass(), "transactionManager");
086    
087                    _transactionManager = transactionManager;
088            }
089    
090            private static DataSource _dataSource;
091            private static DynamicDataSourceTargetSource _dynamicDataSourceTargetSource;
092            private static Session _mailSession;
093            private static Object _transactionManager;
094    
095    }