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.kernel.spring.util;
016    
017    /**
018     * @author Shuyang Zhou
019     */
020    public class ClassNameUtil {
021    
022            public static String getClassName(String className)
023                    throws ClassNotFoundException {
024    
025                    Thread currentThread = Thread.currentThread();
026    
027                    ClassLoader classLoader = currentThread.getContextClassLoader();
028    
029                    return getClassName(className, classLoader);
030            }
031    
032            public static String getClassName(String className, ClassLoader classLoader)
033                    throws ClassNotFoundException {
034    
035                    Class<?> clazz = Class.forName(className, false, classLoader);
036    
037                    return clazz.getName();
038            }
039    
040            public static String getSimpleClassName(String className)
041                    throws ClassNotFoundException {
042    
043                    Thread currentThread = Thread.currentThread();
044    
045                    ClassLoader classLoader = currentThread.getContextClassLoader();
046    
047                    return getSimpleClassName(className, classLoader);
048            }
049    
050            public static String getSimpleClassName(
051                            String className, ClassLoader classLoader)
052                    throws ClassNotFoundException {
053    
054                    Class<?> clazz = Class.forName(className, false, classLoader);
055    
056                    return clazz.getSimpleName();
057            }
058    
059    }