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