org.jboss.managed.plugins.factory
Class AbstractManagedObjectFactory

java.lang.Object
  extended by org.jboss.managed.api.factory.ManagedObjectFactory
      extended by org.jboss.managed.plugins.factory.AbstractManagedObjectFactory
All Implemented Interfaces:
InstanceClassFactory<Serializable>, ManagedObjectBuilder, ManagedObjectPopulator<Serializable>

public class AbstractManagedObjectFactory
extends ManagedObjectFactory
implements ManagedObjectBuilder, InstanceClassFactory<Serializable>, ManagedObjectPopulator<Serializable>

AbstractManagedObjectFactory.

Version:
$Revision: 1.1 $
Author:
Adrian Brock, Scott.Stark@jboss.org

Field Summary
static GenericMetaType MANAGED_OBJECT_META_TYPE
          The managed object meta type
 
Constructor Summary
AbstractManagedObjectFactory()
           
 
Method Summary
 ManagedObject buildManagedObject(Class<? extends Serializable> clazz)
          The ManagedObjectBuilder.buildManagedObject implementation.
protected  ManagedProperty createDefaultManagedProperty(Fields fields)
          Create default MangedProperty instance.
<T extends Serializable>
ManagedObject
createManagedObject(Class<T> clazz)
          Create a shell managed object from the given class
static ManagedProperty createManagedProperty(Class<? extends ManagedProperty> factory, Fields fields)
          Create a ManagedProperty by looking to the factory for ctor(Fields)
 void createObject(ManagedObject managedObject, Class<? extends Serializable> clazz)
          Create a new underlying object
protected
<T extends Serializable>
ManagedObject
createSkeletonManagedObject(Class<T> clazz)
          Create a skeleton managed object
protected  Serializable createUnderlyingObject(ManagedObjectImpl managedObject, Class<? extends Serializable> clazz)
          Create the underlying object
protected  Collection<?> getAsCollection(Object value)
           
protected  ManagedObjectBuilder getBuilder(Class<?> clazz)
          Get the builder for a class
 Object getComponentName(org.jboss.beans.info.spi.BeanInfo beanInfo, ManagedProperty property, Serializable object, MetaValue value)
          Get the runtime component name.
protected  RuntimeComponentNameTransformer getComponentNameTransformer(org.jboss.reflect.spi.TypeInfo type)
          Get component name transformer.
<T extends Serializable>
InstanceClassFactory<T>
getInstanceClassFactory(Class<T> clazz)
          Get the instance factory for a class
 Class<? extends Serializable> getManagedObjectClass(Serializable instance)
          Default InstanceClassFactory implementation simply returns the instance class.
protected  ManagedOperation getManagedOperation(org.jboss.reflect.spi.MethodInfo methodInfo, ManagementOperation opAnnotation)
           
protected  ManagedProperty getManagedProperty(Class<? extends ManagedProperty> factory, Fields fields)
          Look for ctor(Fields)
protected  ManagedObjectPopulator<Serializable> getPopulator(Class<?> clazz)
          Get the populator for a class
protected  String getPropertyName(ManagedProperty property)
          Get the property name.
 MetaValue getValue(org.jboss.beans.info.spi.BeanInfo beanInfo, ManagedProperty property, Serializable object)
          Get a value
 ManagedObject initManagedObject(Serializable object, String name, String nameType)
          Create a managed object from the given object
 void populateManagedObject(ManagedObject managedObject, Serializable object)
          Populate the managed object
protected  void populateValues(ManagedObjectImpl managedObject, Serializable object)
          Populate the values
 void setBuilder(Class<?> clazz, ManagedObjectBuilder builder)
          Set a managed object builder
<T extends Serializable>
void
setInstanceClassFactory(Class<T> clazz, InstanceClassFactory<T> factory)
          Set the InstanceClassFactory for an instance type.
 void setNameTransformers(Class<?> clazz, RuntimeComponentNameTransformer transformer)
           
 void setNameTransformers(org.jboss.reflect.spi.TypeInfo type, RuntimeComponentNameTransformer transformer)
           
 void setValue(org.jboss.beans.info.spi.BeanInfo beanInfo, ManagedProperty property, Serializable object, MetaValue value)
          Set a value
 
Methods inherited from class org.jboss.managed.api.factory.ManagedObjectFactory
getInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MANAGED_OBJECT_META_TYPE

public static final GenericMetaType MANAGED_OBJECT_META_TYPE
The managed object meta type

Constructor Detail

AbstractManagedObjectFactory

public AbstractManagedObjectFactory()
Method Detail

createManagedProperty

public static ManagedProperty createManagedProperty(Class<? extends ManagedProperty> factory,
                                                    Fields fields)
Create a ManagedProperty by looking to the factory for ctor(Fields)

Parameters:
factory - - the ManagedProperty implementation class
fields - - the fields to pass to the ctor
Returns:
the managed property if successful, null otherwise

createManagedObject

public <T extends Serializable> ManagedObject createManagedObject(Class<T> clazz)
Description copied from class: ManagedObjectFactory
Create a shell managed object from the given class

Specified by:
createManagedObject in class ManagedObjectFactory
Type Parameters:
T - the class
Parameters:
clazz - the class
Returns:
the managed object

initManagedObject

public ManagedObject initManagedObject(Serializable object,
                                       String name,
                                       String nameType)
Description copied from class: ManagedObjectFactory
Create a managed object from the given object

Specified by:
initManagedObject in class ManagedObjectFactory
Parameters:
object - the object
name - - the name of the managed object. If null, the name will be derived from the object annotations or attachment name.
nameType - - the name of the managed object. If null, the name will be derived from the object annotations or default to "".
Returns:
the managed object
See Also:
ManagementObjectID

setBuilder

public void setBuilder(Class<?> clazz,
                       ManagedObjectBuilder builder)
Description copied from class: ManagedObjectFactory
Set a managed object builder

Specified by:
setBuilder in class ManagedObjectFactory
Parameters:
clazz - the class
builder - the builder (null to remove the builder)

setInstanceClassFactory

public <T extends Serializable> void setInstanceClassFactory(Class<T> clazz,
                                                             InstanceClassFactory<T> factory)
Description copied from class: ManagedObjectFactory
Set the InstanceClassFactory for an instance type.

Specified by:
setInstanceClassFactory in class ManagedObjectFactory
Type Parameters:
T - the class type
Parameters:
clazz - the class
factory - - the factory used to obtain the class to scan for management annotations.

setNameTransformers

public void setNameTransformers(Class<?> clazz,
                                RuntimeComponentNameTransformer transformer)

setNameTransformers

public void setNameTransformers(org.jboss.reflect.spi.TypeInfo type,
                                RuntimeComponentNameTransformer transformer)

getManagedObjectClass

public Class<? extends Serializable> getManagedObjectClass(Serializable instance)
Default InstanceClassFactory implementation simply returns the instance class.

Specified by:
getManagedObjectClass in interface InstanceClassFactory<Serializable>
Parameters:
instance - - the instance a ManagedObject is to be created for.
Returns:
the Class that represents the root ManagedObject.

createSkeletonManagedObject

protected <T extends Serializable> ManagedObject createSkeletonManagedObject(Class<T> clazz)
Create a skeleton managed object

Type Parameters:
T - the type
Parameters:
clazz - the clazz
Returns:
the skeleton managed object, null if clazz is not marked as a ManagementObject. ManagementObject

buildManagedObject

public ManagedObject buildManagedObject(Class<? extends Serializable> clazz)
The ManagedObjectBuilder.buildManagedObject implementation. This is based on the org.jboss.managed.api.annotation.* package annotations.

Specified by:
buildManagedObject in interface ManagedObjectBuilder
Parameters:
clazz - the attachment class
Returns:
the ManagementObject if clazz is properly annotated, null if it does not have a ManagementObject annotation.

createDefaultManagedProperty

protected ManagedProperty createDefaultManagedProperty(Fields fields)
Create default MangedProperty instance. Override this method for different default.

Parameters:
fields - the fields
Returns:
new ManagedProperty instance

createObject

public void createObject(ManagedObject managedObject,
                         Class<? extends Serializable> clazz)
Description copied from interface: ManagedObjectPopulator
Create a new underlying object

Specified by:
createObject in interface ManagedObjectPopulator<Serializable>
Parameters:
managedObject - the managed object
clazz - the class

populateManagedObject

public void populateManagedObject(ManagedObject managedObject,
                                  Serializable object)
Description copied from interface: ManagedObjectPopulator
Populate the managed object

Specified by:
populateManagedObject in interface ManagedObjectPopulator<Serializable>
Parameters:
managedObject - the managed object
object - the object used to populate the managed object

createUnderlyingObject

protected Serializable createUnderlyingObject(ManagedObjectImpl managedObject,
                                              Class<? extends Serializable> clazz)
Create the underlying object

Parameters:
managedObject - the managed object
clazz - the class
Returns:
the object

populateValues

protected void populateValues(ManagedObjectImpl managedObject,
                              Serializable object)
Populate the values

Parameters:
managedObject - the managed object
object - the object

getPropertyName

protected String getPropertyName(ManagedProperty property)
Get the property name.

Parameters:
property - managed property
Returns:
property name

getComponentName

public Object getComponentName(org.jboss.beans.info.spi.BeanInfo beanInfo,
                               ManagedProperty property,
                               Serializable object,
                               MetaValue value)
Description copied from interface: InstanceClassFactory
Get the runtime component name.

Specified by:
getComponentName in interface InstanceClassFactory<Serializable>
Parameters:
beanInfo - managed object's bean info
property - managed property
object - attachment
value - original value
Returns:
meta value

getValue

public MetaValue getValue(org.jboss.beans.info.spi.BeanInfo beanInfo,
                          ManagedProperty property,
                          Serializable object)
Get a value

Specified by:
getValue in interface InstanceClassFactory<Serializable>
Parameters:
beanInfo - the bean info
property - the property
object - the object
Returns:
the meta value

setValue

public void setValue(org.jboss.beans.info.spi.BeanInfo beanInfo,
                     ManagedProperty property,
                     Serializable object,
                     MetaValue value)
Set a value

Specified by:
setValue in interface InstanceClassFactory<Serializable>
Parameters:
beanInfo - the bean info
property - the property
object - the object
value - the meta value

getManagedOperation

protected ManagedOperation getManagedOperation(org.jboss.reflect.spi.MethodInfo methodInfo,
                                               ManagementOperation opAnnotation)
Parameters:
methodInfo -
opAnnotation -
Returns:
the managed operation

getBuilder

protected ManagedObjectBuilder getBuilder(Class<?> clazz)
Get the builder for a class

Parameters:
clazz - the class
Returns:
the builder

getInstanceClassFactory

public <T extends Serializable> InstanceClassFactory<T> getInstanceClassFactory(Class<T> clazz)
Get the instance factory for a class

Specified by:
getInstanceClassFactory in class ManagedObjectFactory
Type Parameters:
T - the class type
Parameters:
clazz - the class
Returns:
the InstanceClassFactory

getComponentNameTransformer

protected RuntimeComponentNameTransformer getComponentNameTransformer(org.jboss.reflect.spi.TypeInfo type)
                                                               throws Throwable
Get component name transformer.

Parameters:
type - the type info
Returns:
transformer instance
Throws:
Throwable - for any error

getPopulator

protected ManagedObjectPopulator<Serializable> getPopulator(Class<?> clazz)
Get the populator for a class

Parameters:
clazz - the class
Returns:
the populator

getAsCollection

protected Collection<?> getAsCollection(Object value)

getManagedProperty

protected ManagedProperty getManagedProperty(Class<? extends ManagedProperty> factory,
                                             Fields fields)
Look for ctor(Fields)

Parameters:
factory - - the ManagedProperty implementation class
fields - - the fields to pass to the ctor
Returns:
the managed property


Copyright © 2008 JBoss Inc.. All Rights Reserved.