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.hibernate;
016    
017    import com.liferay.portal.kernel.portlet.PortletClassLoaderUtil;
018    import com.liferay.portal.util.ClassLoaderUtil;
019    
020    import org.hibernate.dialect.Dialect;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     * @author Ganesh Ram
025     */
026    public class PortletHibernateConfiguration
027            extends PortalHibernateConfiguration {
028    
029            @Override
030            protected ClassLoader getConfigurationClassLoader() {
031                    ClassLoader classLoader = PortletClassLoaderUtil.getClassLoader();
032    
033                    if (classLoader == null) {
034    
035                            // This should not be null except in cases where sharding is enabled
036    
037                            classLoader = ClassLoaderUtil.getContextClassLoader();
038                    }
039    
040                    return classLoader;
041            }
042    
043            @Override
044            protected String[] getConfigurationResources() {
045                    return new String[] {"META-INF/portlet-hbm.xml"};
046            }
047    
048            @Override
049            protected void setDB(Dialect dialect) {
050    
051                    // Plugins should not update the default DB reference
052    
053            }
054    
055    }