Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2006, 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.xb.spi;
 
AbstractBeanAdapter.

Author(s):
Adrian Brock
Version:
$Revision: 1.1 $
 
 public class AbstractBeanAdapter extends BeanAdapter
 {
   
The bean info
 
    private BeanInfo beanInfo;

   
Any factory
 
    private MethodInfo factory;

   
Whether the value is constructed
 
    private boolean constructed = false;
   
   
The value
 
    private Object value;
   
   
Create a new AbstractBeanAdapter.

Parameters:
beanAdapterFactory the bean adapter factory
beanInfo the bean info
factory the factory
Throws:
java.lang.IllegalArgumentException for null bean adapter factory or bean info
 
    public AbstractBeanAdapter(BeanAdapterFactory beanAdapterFactoryBeanInfo beanInfoMethodInfo factory)
    {
       super(beanAdapterFactory);
       if (beanInfo == null)
          throw new IllegalArgumentException("Null bean info");
       this. = beanInfo;
       this. = factory;
    }

   
Get the bean info

Returns:
the bean info
 
    public BeanInfo getBeanInfo()
    {
       return ;
    }

   
Get the factory

Returns:
the factgory
 
    public MethodInfo getFactory()
    {
       return ;
    }
    
    public Object get(PropertyInfo propertyInfothrows Throwable
    {
       ensureConstructed();
       return propertyInfo.get();
    }
    
    public void set(PropertyInfo propertyInfoObject childthrows Throwable
    {
       ensureConstructed();
       propertyInfo.set(child);
    }
 
    public Object getValue()
    {
      ensureConstructed();
      return ;
   }

   
Construct the object

Returns:
the value
   protected Object construct()
   {
      try
      {
         if ( != null)
            return .invoke(nullnull);
         return .newInstance();
      }
      catch (Throwable t)
      {
         throw new RuntimeException("Error instantiating bean for " + .getName(), t);
      }
   }
   
   
Ensure the object has been constructed
   protected void ensureConstructed()
   {
      if ( == false)
          = construct();
       = true;
   }
New to GrepCode? Check out our FAQ X