集册 Java实例教程 返回bean描述符。

返回bean描述符。

欢马劈雪     最近更新时间:2020-01-02 10:19:05

617
返回bean描述符。

/*

 * Copyright 2004-2010 the Seasar Foundation and the Others.

 *

 * Licensed under the Apache License, Version 2.0 (the "License");

 * you may not use this file except in compliance with the License.

 * You may obtain a copy of the License at

 *

 *     http://www.apache.org/licenses/LICENSE-2.0

 *

 * Unless required by applicable law or agreed to in writing, software

 * distributed under the License is distributed on an "AS IS" BASIS,

 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,

 * either express or implied. See the License for the specific language

 * governing permissions and limitations under the License.

 */

import java.util.Iterator;
/**
来 自 n o w j a v a . c o m - 时  代  Java
**/

import java.util.Map;

import java.util.concurrent.ConcurrentHashMap;

import javax.servlet.http.HttpServletRequest;


public class Main{

    public static void main(String[] argv) throws Exception{

        Class beanClass = String.class;

        System.out.println(getBeanDesc(beanClass));

    }

    private static ConcurrentHashMap<String, BeanDesc> beanDescCache = new ConcurrentHashMap<String, BeanDesc>(

            200);

    private static volatile boolean initialized = false;

    /**

     * Returns the bean descriptor.

     * 

     * @param beanClass

     *            the bean class

     * @return the bean descriptor

     * @throws NullPointerException

     *             if the beanClass parameter is null

     * 

     *///from 时 代 J a v a 公 众 号 - nowjava.com

    public static BeanDesc getBeanDesc(Class<?> beanClass)

            throws NullPointerException {

        if (beanClass == null) {

            throw new NullPointerException(

                    "The beanClass parameter is null.");

        }

        if (!initialized) {

            initialize();

        }


        BeanDesc beanDesc = beanDescCache.get(beanClass.getName());

        if (beanDesc != null) {

            return beanDesc;

        }

        beanDesc = BeanDesc.create(beanClass);

        b
展开阅读全文