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.util;
016    
017    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
018    
019    import javax.mail.Session;
020    
021    import javax.sql.DataSource;
022    
023    /**
024     * @author Brian Wing Shun Chan
025     * @author Michael Young
026     */
027    public class InfrastructureUtil {
028    
029            public static DataSource getDataSource() {
030                    PortalRuntimePermission.checkGetBeanProperty(
031                            InfrastructureUtil.class, "dataSource");
032    
033                    return _dataSource;
034            }
035    
036            public static Object getDynamicDataSourceTargetSource() {
037                    PortalRuntimePermission.checkGetBeanProperty(
038                            InfrastructureUtil.class, "dynamicDataSourceTargetSource");
039    
040                    return _dynamicDataSourceTargetSource;
041            }
042    
043            public static Session getMailSession() {
044                    PortalRuntimePermission.checkGetBeanProperty(
045                            InfrastructureUtil.class, "mailSession");
046    
047                    return _mailSession;
048            }
049    
050            public static Object getShardDataSourceTargetSource() {
051                    PortalRuntimePermission.checkGetBeanProperty(
052                            InfrastructureUtil.class, "shardDataSourceTargetSource");
053    
054                    return _shardDataSourceTargetSource;
055            }
056    
057            public static Object getShardSessionFactoryTargetSource() {
058                    PortalRuntimePermission.checkGetBeanProperty(
059                            InfrastructureUtil.class, "shardSessionFactoryTargetSource");
060    
061                    return _shardSessionFactoryTargetSource;
062            }
063    
064            public static Object getTransactionManager() {
065                    PortalRuntimePermission.checkGetBeanProperty(
066                            InfrastructureUtil.class, "transactionManager");
067    
068                    return _transactionManager;
069            }
070    
071            public void setDataSource(DataSource dataSource) {
072                    PortalRuntimePermission.checkSetBeanProperty(getClass(), "dataSource");
073    
074                    _dataSource = dataSource;
075            }
076    
077            public void setDynamicDataSourceTargetSource(
078                    Object dynamicDataSourceTargetSource) {
079    
080                    PortalRuntimePermission.checkSetBeanProperty(
081                            getClass(), "dynamicDataSourceTargetSource");
082    
083                    _dynamicDataSourceTargetSource = dynamicDataSourceTargetSource;
084            }
085    
086            public void setMailSession(Session mailSession) {
087                    PortalRuntimePermission.checkSetBeanProperty(getClass(), "mailSession");
088    
089                    _mailSession = mailSession;
090            }
091    
092            public void setShardDataSourceTargetSource(
093                    Object shardDataSourceTargetSource) {
094    
095                    PortalRuntimePermission.checkSetBeanProperty(
096                            getClass(), "shardDataSourceTargetSource");
097    
098                    _shardDataSourceTargetSource = shardDataSourceTargetSource;
099            }
100    
101            public void setShardSessionFactoryTargetSource(
102                    Object shardSessionFactoryTargetSource) {
103    
104                    PortalRuntimePermission.checkSetBeanProperty(
105                            getClass(), "shardSessionFactoryTargetSource");
106    
107                    _shardSessionFactoryTargetSource = shardSessionFactoryTargetSource;
108            }
109    
110            public void setTransactionManager(Object transactionManager) {
111                    PortalRuntimePermission.checkSetBeanProperty(
112                            getClass(), "transactionManager");
113    
114                    _transactionManager = transactionManager;
115            }
116    
117            private static DataSource _dataSource;
118            private static Object _dynamicDataSourceTargetSource;
119            private static Session _mailSession;
120            private static Object _shardDataSourceTargetSource;
121            private static Object _shardSessionFactoryTargetSource;
122            private static Object _transactionManager;
123    
124    }