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.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    }