org.jboss.beans.metadata.plugins
Class AbstractTypeMetaData

java.lang.Object
  extended by org.jboss.util.JBossObject
      extended by org.jboss.beans.metadata.plugins.AbstractValueMetaData
          extended by org.jboss.beans.metadata.plugins.AbstractTypeMetaData
All Implemented Interfaces:
Serializable, Cloneable, TypeProvider, MetaDataVisitorNode, ValueMetaData, org.jboss.util.JBossInterface
Direct Known Subclasses:
AbstractCollectionMetaData, AbstractMapMetaData, StringValueMetaData

public abstract class AbstractTypeMetaData
extends AbstractValueMetaData
implements Serializable

A typed value.

Version:
$Revision: 76173 $
Author:
Adrian Brock, Ales Justin
See Also:
Serialized Form

Field Summary
protected  String beanName
          The bean name
protected  KernelConfigurator configurator
          The configurator
protected  ControllerContext context
          The context
protected  String propertyName
          The property name
protected  String type
          The type
 
Fields inherited from class org.jboss.util.JBossObject
hashCode, log, toString
 
Fields inherited from interface org.jboss.beans.metadata.plugins.TypeProvider
ERROR_MSG
 
Constructor Summary
AbstractTypeMetaData()
          Create a new typed value
AbstractTypeMetaData(String value)
          Create a new typed value
 
Method Summary
protected
<T> T
checkResult(Object result, Class<T> expected)
          Check result for class compatibility.
protected
<T> T
createInstance(org.jboss.reflect.spi.TypeInfo info, ClassLoader cl, Class<T> expected, boolean explicit)
          Create new instance from type field.
protected  org.jboss.reflect.spi.ClassInfo getClass(MetaDataVisitor visitor, String classType)
           
protected  org.jboss.reflect.spi.ClassInfo getClassInfo(ClassLoader cl)
          Get the class info for this type
protected  org.jboss.reflect.spi.ClassInfo getClassInfo(String classType, ClassLoader cl)
           
protected abstract  Object getDefaultInstance()
          Get the default instance.
 String getType()
           
protected  org.jboss.reflect.spi.TypeInfo getTypeInfo(ClassLoader cl)
          Get the type info for this type
protected  org.jboss.reflect.spi.TypeInfo getTypeInfo(String classType, ClassLoader cl)
           
protected
<T> T
getTypeInstance(org.jboss.reflect.spi.TypeInfo info, ClassLoader cl, Class<T> expected)
          Create the class instance
protected
<T> T
getTypeInstance(org.jboss.reflect.spi.TypeInfo info, ClassLoader cl, Class<T> expected, boolean preInstantiatedLookup)
          Create the class instance
 void initialVisit(MetaDataVisitor visitor)
          Visit the node
protected
<T> T
preinstantiatedLookup(ClassLoader cl, Class<T> expected)
          Check for already existing instances.
protected  void preparePreinstantiatedLookup(MetaDataVisitor visitor)
          Check if we can extract the information about existing instance - only on property metadata.
 void setConfigurator(KernelConfigurator configurator)
          Set the configurator
 void setType(String type)
          Set the type
 void toString(org.jboss.util.JBossStringBuilder buffer)
           
 
Methods inherited from class org.jboss.beans.metadata.plugins.AbstractValueMetaData
clone, describeVisit, getChildren, getType, getUnderlyingValue, getValue, getValue, isUseJMXObjectNameFix, setValue, toShortString
 
Methods inherited from class org.jboss.util.JBossObject
cacheGetHashCode, cacheToString, equals, flushJBossObjectCache, getClassShortName, getHashCode, hashCode, list, notEqual, toShortString, toString, toStringImplementation
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jboss.util.JBossInterface
toShortString
 

Field Detail

type

protected String type
The type


context

protected transient ControllerContext context
The context


configurator

protected transient KernelConfigurator configurator
The configurator


propertyName

protected String propertyName
The property name


beanName

protected String beanName
The bean name

Constructor Detail

AbstractTypeMetaData

public AbstractTypeMetaData()
Create a new typed value


AbstractTypeMetaData

public AbstractTypeMetaData(String value)
Create a new typed value

Parameters:
value - the value
Method Detail

setType

public void setType(String type)
Set the type

Parameters:
type - the type

getType

public String getType()

initialVisit

public void initialVisit(MetaDataVisitor visitor)
Description copied from interface: MetaDataVisitorNode
Visit the node

Specified by:
initialVisit in interface MetaDataVisitorNode
Overrides:
initialVisit in class AbstractValueMetaData
Parameters:
visitor - the visitor

preparePreinstantiatedLookup

protected void preparePreinstantiatedLookup(MetaDataVisitor visitor)
Check if we can extract the information about existing instance - only on property metadata.

Parameters:
visitor - underlying visitor

preinstantiatedLookup

protected <T> T preinstantiatedLookup(ClassLoader cl,
                                      Class<T> expected)
Check for already existing instances.

Type Parameters:
T - expected type
Parameters:
cl - the classloader
expected - the expected class
Returns:
existing instance or null otherwise

checkResult

protected <T> T checkResult(Object result,
                            Class<T> expected)
Check result for class compatibility.

Type Parameters:
T - the expected type
Parameters:
result - the result
expected - expected class
Returns:
casted result
Throws:
ClassCastException - if result cannot be casted into expected parameter

createInstance

protected <T> T createInstance(org.jboss.reflect.spi.TypeInfo info,
                               ClassLoader cl,
                               Class<T> expected,
                               boolean explicit)
                    throws Throwable
Create new instance from type field. Fall back to info parameter if no type field is set.

Type Parameters:
T - expected type
Parameters:
info - the type of reference we are about to set
cl - the classloader to use
expected - the expected class
explicit - is type explicit
Returns:
class instance or null if type is too broad
Throws:
Throwable - on any error

getTypeInstance

protected <T> T getTypeInstance(org.jboss.reflect.spi.TypeInfo info,
                                ClassLoader cl,
                                Class<T> expected)
                     throws Throwable
Create the class instance

Type Parameters:
T - expected type
Parameters:
info - the request type
cl - the classloader
expected - the expected class
Returns:
the class instance
Throws:
Throwable - for any error

getTypeInstance

protected <T> T getTypeInstance(org.jboss.reflect.spi.TypeInfo info,
                                ClassLoader cl,
                                Class<T> expected,
                                boolean preInstantiatedLookup)
                     throws Throwable
Create the class instance

Type Parameters:
T - expected type
Parameters:
info - the request type
cl - the classloader
expected - the expected class
preInstantiatedLookup - whether to do the preinstantiated lookup
Returns:
the class instance
Throws:
Throwable - for any error

getDefaultInstance

protected abstract Object getDefaultInstance()
Get the default instance.

Returns:
the default instance

setConfigurator

public void setConfigurator(KernelConfigurator configurator)
Set the configurator

Parameters:
configurator - the configurator

toString

public void toString(org.jboss.util.JBossStringBuilder buffer)
Overrides:
toString in class AbstractValueMetaData

getClassInfo

protected org.jboss.reflect.spi.ClassInfo getClassInfo(ClassLoader cl)
                                                throws Throwable
Get the class info for this type

Parameters:
cl - classloader
Returns:
the class info
Throws:
Throwable - for any error

getClassInfo

protected org.jboss.reflect.spi.ClassInfo getClassInfo(String classType,
                                                       ClassLoader cl)
                                                throws Throwable
Throws:
Throwable

getTypeInfo

protected org.jboss.reflect.spi.TypeInfo getTypeInfo(ClassLoader cl)
                                              throws Throwable
Get the type info for this type

Parameters:
cl - classloader
Returns:
the type info
Throws:
Throwable - for any error

getTypeInfo

protected org.jboss.reflect.spi.TypeInfo getTypeInfo(String classType,
                                                     ClassLoader cl)
                                              throws Throwable
Throws:
Throwable

getClass

protected org.jboss.reflect.spi.ClassInfo getClass(MetaDataVisitor visitor,
                                                   String classType)
                                            throws Throwable
Throws:
Throwable


Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.