Package org.jboss.kernel.plugins.config

Source Code of org.jboss.kernel.plugins.config.AbstractKernelConfig

/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.kernel.plugins.config;

import org.jboss.beans.info.plugins.AbstractBeanInfoFactory;
import org.jboss.beans.info.spi.BeanInfo;
import org.jboss.beans.info.spi.BeanInfoFactory;
import org.jboss.classadapter.plugins.reflect.ReflectClassAdapterFactory;
import org.jboss.classadapter.spi.ClassAdapter;
import org.jboss.classadapter.spi.ClassAdapterFactory;
import org.jboss.kernel.plugins.AbstractKernelObject;
import org.jboss.kernel.spi.config.KernelConfig;
import org.jboss.reflect.spi.ClassInfo;

/**
* Abstract Kernel configuration.
*
* @author <a href="adrian@jboss.com">Adrian Brock</a>
* @author <a href="mailto:les.hazlewood@jboss.org">Les A. Hazlewood</a>
* @version $Revision: 1.13 $
*/
public abstract class AbstractKernelConfig extends AbstractKernelObject implements KernelConfig
{
   /** The default bean info factory */
   private BeanInfoFactory beanInfoFactory;
  
   /** The default class adaptor factory */
   private ClassAdapterFactory classAdapterFactory;
   /**
    * Create an abstract kernel configuration
    *
    * @throws Exception for any error
    */
   public AbstractKernelConfig() throws Exception
   {
   }
  
   public BeanInfo getBeanInfo(String className, ClassLoader cl) throws Exception
   {
      ClassAdapter classAdapter = getClassAdapterFactory().getClassAdapter(className, cl);
      return getBeanInfoFactory().getBeanInfo(cl, classAdapter);
   }
  
   public BeanInfo getBeanInfo(Class clazz) throws Exception
   {
      ClassAdapter classAdapter = getClassAdapterFactory().getClassAdapter(clazz);
      return getBeanInfoFactory().getBeanInfo(clazz.getClassLoader(), classAdapter);
   }
  
   public ClassInfo getClassInfo(String className, ClassLoader cl) throws Exception
   {
      ClassAdapter classAdapter = getClassAdapterFactory().getClassAdapter(className, cl);
      return classAdapter.getClassInfo();
   }
  
   public ClassInfo getClassInfo(Class clazz) throws Exception
   {
      ClassAdapter classAdapter = getClassAdapterFactory().getClassAdapter(clazz);
      return classAdapter.getClassInfo();
   }

   /**
    * Get the BeanInfoFactory
    *
    * @return the BeanInfoFactory
    * @throws Exception for any error
    */
   protected BeanInfoFactory getBeanInfoFactory() throws Exception
   {
      if (beanInfoFactory == null)
         beanInfoFactory = createDefaultBeanInfoFactory();
      return beanInfoFactory;
   }

   /**
    * Get the class adapter factory
    *
    * @return the ClassAdapterFactory
    * @throws Exception for any error
    */
   protected ClassAdapterFactory getClassAdapterFactory() throws Exception
   {
      if (classAdapterFactory == null)
         classAdapterFactory = createDefaultClassAdapterFactory();
      return classAdapterFactory;
   }
  
   /**
    * Create the default bean info factory
    *
    * @return the bean info factory
    * @throws Exception for any error
    */
   protected BeanInfoFactory createDefaultBeanInfoFactory() throws Exception
   {
      return new AbstractBeanInfoFactory();
   }

   /**
    * Create the default type info factory
    *
    * @return the type info factory
    * @throws Exception for any error
    */
   protected ClassAdapterFactory createDefaultClassAdapterFactory() throws Exception
   {
      return new ReflectClassAdapterFactory();
   }
}
TOP

Related Classes of org.jboss.kernel.plugins.config.AbstractKernelConfig

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.