001    /**
002     * Copyright (c) 2000-2013 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            @Override
037            public void postProcessPersistenceUnitInfo(
038                    MutablePersistenceUnitInfo mutablePersistenceUnitInfo) {
039    
040                    for (String mappingFileName : PropsValues.JPA_CONFIGS) {
041                            mutablePersistenceUnitInfo.addMappingFileName(mappingFileName);
042                    }
043    
044                    Properties properties = PropsUtil.getProperties(
045                            PropsKeys.JPA_PROVIDER_PROPERTY_PREFIX, true);
046    
047                    if (_log.isInfoEnabled()) {
048                            _log.info(PropertiesUtil.list(properties));
049                    }
050    
051                    mutablePersistenceUnitInfo.setProperties(properties);
052            }
053    
054            private static Log _log = LogFactoryUtil.getLog(
055                    LiferayPersistenceUnitPostProcessor.class);
056    
057    }