1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.spring.jpa;
16  
17  import com.liferay.portal.kernel.log.Log;
18  import com.liferay.portal.kernel.log.LogFactoryUtil;
19  import com.liferay.portal.kernel.util.PropertiesUtil;
20  import com.liferay.portal.kernel.util.PropsKeys;
21  import com.liferay.portal.util.PropsUtil;
22  import com.liferay.portal.util.PropsValues;
23  
24  import java.util.Properties;
25  
26  import org.springframework.orm.jpa.persistenceunit.MutablePersistenceUnitInfo;
27  import org.springframework.orm.jpa.persistenceunit.PersistenceUnitPostProcessor;
28  
29  /**
30   * <a href="LiferayPersistenceUnitPostProcessor.java.html"><b><i>View Source</i>
31   * </b></a>
32   *
33   * @author Prashant Dighe
34   * @author Brian Wing Shun Chan
35   */
36  public class LiferayPersistenceUnitPostProcessor
37      implements PersistenceUnitPostProcessor {
38  
39      public void postProcessPersistenceUnitInfo(
40          MutablePersistenceUnitInfo mutablePersistenceUnitInfo) {
41  
42          for (String mappingFileName : PropsValues.JPA_CONFIGS) {
43              mutablePersistenceUnitInfo.addMappingFileName(mappingFileName);
44          }
45  
46          Properties properties = PropsUtil.getProperties(
47              PropsKeys.JPA_PROVIDER_PROPERTY_PREFIX, true);
48  
49          if (_log.isInfoEnabled()) {
50              _log.info(PropertiesUtil.list(properties));
51          }
52  
53          mutablePersistenceUnitInfo.setProperties(properties);
54      }
55  
56      private static Log _log = LogFactoryUtil.getLog(
57          LiferayPersistenceUnitPostProcessor.class);
58  
59  }