001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.spring.jpa;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    import com.liferay.portal.kernel.util.PropertiesUtil;
020    import com.liferay.portal.kernel.util.PropsKeys;
021    import com.liferay.portal.util.PropsUtil;
022    import com.liferay.portal.util.PropsValues;
023    
024    import java.util.Properties;
025    
026    import org.springframework.orm.jpa.persistenceunit.MutablePersistenceUnitInfo;
027    import org.springframework.orm.jpa.persistenceunit.PersistenceUnitPostProcessor;
028    
029    /**
030     * @author Prashant Dighe
031     * @author Brian Wing Shun Chan
032     */
033    public class LiferayPersistenceUnitPostProcessor
034            implements PersistenceUnitPostProcessor {
035    
036            public void postProcessPersistenceUnitInfo(
037                    MutablePersistenceUnitInfo mutablePersistenceUnitInfo) {
038    
039                    for (String mappingFileName : PropsValues.JPA_CONFIGS) {
040                            mutablePersistenceUnitInfo.addMappingFileName(mappingFileName);
041                    }
042    
043                    Properties properties = PropsUtil.getProperties(
044                            PropsKeys.JPA_PROVIDER_PROPERTY_PREFIX, true);
045    
046                    if (_log.isInfoEnabled()) {
047                            _log.info(PropertiesUtil.list(properties));
048                    }
049    
050                    mutablePersistenceUnitInfo.setProperties(properties);
051            }
052    
053            private static Log _log = LogFactoryUtil.getLog(
054                    LiferayPersistenceUnitPostProcessor.class);
055    
056    }