001    /**
002     * Copyright (c) 2000-2012 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.hibernate;
016    
017    import com.liferay.portal.kernel.portlet.PortletClassLoaderUtil;
018    import com.liferay.portal.security.pacl.PACLClassLoaderUtil;
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 = PACLClassLoaderUtil.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    }