Package org.jboss.managed.spi.factory

Examples of org.jboss.managed.spi.factory.InstanceClassFactory


            if (value instanceof MetaValue == false)
               metaValue = getValueFactory().create(value, propertyInfo.getType());
            else
               metaValue = (MetaValue)value;

            InstanceClassFactory icf = getObjectFactory().getInstanceClassFactory(attachment.getClass());
            BeanInfo beanInfo = propertyInfo.getBeanInfo();
            icf.setValue(beanInfo, this, attachment, metaValue);
         }
      }
   }
View Full Code Here


   {
      if (object == null)
         throw new IllegalArgumentException("Null object");

      Class<? extends Serializable> clazz = object.getClass();
      InstanceClassFactory icf = getInstanceClassFactory(clazz);
      Class<? extends Serializable> moClass;
      try
      {
         moClass = icf.getManagedObjectClass(object);
      }
      catch(ClassNotFoundException e)
      {
         return null;
      }
View Full Code Here

    * @param object the object
    */
   @SuppressWarnings("unchecked")
   protected void populateValues(ManagedObjectImpl managedObject, Serializable object)
   {
      InstanceClassFactory icf = getInstanceClassFactory(object.getClass());
      Class moClass;
      try
      {
         moClass = icf.getManagedObjectClass(object);
      }
      catch(ClassNotFoundException e)
      {
         throw new IllegalStateException(e);
      }
      BeanInfo beanInfo = configuration.getBeanInfo(moClass);

      Object componentName = null;
      Map<String, ManagedProperty> properties = managedObject.getProperties();
      if (properties != null && properties.size() > 0)
      {
         for (ManagedProperty property : properties.values())
         {
            MetaValue value = icf.getValue(beanInfo, property, object);
            if (value != null)
               property.setField(Fields.VALUE, value);
            /* Need to look for a ManagementObjectID at the property level which
               defines the ManagedObject id name from the property value.
             */
            Map<String, Annotation> annotations = property.getAnnotations();
            if (annotations == null)
               continue;
            ManagementObjectID id = (ManagementObjectID) annotations.get(ManagementObjectID.class.getName());
            if (id != null)
            {
               if (value == null || value.getMetaType().isSimple() == false)
               {
                  log.warn("Cannot create String name from non-Simple property: "
                        +property+", value="+value);
                  continue;
               }
               SimpleValue svalue = (SimpleValue) value;
               String name = "" + svalue.getValue();
               managedObject.setName(name);
            }
            ManagementRuntimeRef runtimeRef = (ManagementRuntimeRef) annotations.get(ManagementRuntimeRef.class.getName());
            if (runtimeRef != null)
            {
               componentName = icf.getComponentName(beanInfo, property, object, value);
               // let's try this as well
               if (componentName == null && icf != this)
                  componentName = getComponentName(beanInfo, property, object, value);
            }
         }
      }
      if (componentName == null)
         componentName = icf.getComponentName(null, null, object, null);
      // set it, even if it's null
      managedObject.setComponentName(componentName);
   }
View Full Code Here

   @SuppressWarnings("unchecked")
   public <T extends Serializable> InstanceClassFactory<T> getInstanceClassFactory(Class<T> clazz)
   {
      synchronized (instanceFactories)
      {
         InstanceClassFactory factory = instanceFactories.get(clazz);
         if (factory != null)
            return factory;
      }
      return (InstanceClassFactory<T>)this;
   }
View Full Code Here

   {
      if (object == null)
         throw new IllegalArgumentException("Null object");

      Class<? extends Serializable> clazz = object.getClass();
      InstanceClassFactory icf = getInstanceClassFactory(clazz);
      Class<? extends Serializable> moClass;
      try
      {
         moClass = icf.getManagedObjectClass(object);
      }
      catch(ClassNotFoundException e)
      {
         return null;
      }
View Full Code Here

    * @param object the object
    */
   @SuppressWarnings("unchecked")
   protected void populateValues(ManagedObjectImpl managedObject, Serializable object)
   {
      InstanceClassFactory icf = getInstanceClassFactory(object.getClass());
      Class moClass;
      try
      {
         moClass = icf.getManagedObjectClass(object);
      }
      catch(ClassNotFoundException e)
      {
         throw new IllegalStateException(e);
      }
      BeanInfo beanInfo = configuration.getBeanInfo(moClass);

      Object componentName = null;
      Map<String, ManagedProperty> properties = managedObject.getProperties();
      if (properties != null && properties.size() > 0)
      {
         for (ManagedProperty property : properties.values())
         {
            MetaValue value = icf.getValue(beanInfo, property, object);
            if (value != null)
               property.setField(Fields.VALUE, value);
            /* Need to look for a ManagementObjectID at the property level which
               defines the ManagedObject id name from the property value.
             */
            Map<String, Annotation> annotations = property.getAnnotations();
            if (annotations == null)
               continue;
            ManagementObjectID id = (ManagementObjectID) annotations.get(ManagementObjectID.class.getName());
            if (id != null)
            {
               if (value == null || value.getMetaType().isSimple() == false)
               {
                  log.warn("Cannot create String name from non-Simple property: "
                        +property+", value="+value);
                  continue;
               }
               SimpleValue svalue = (SimpleValue) value;
               String name = "" + svalue.getValue();
               managedObject.setName(name);
            }
            ManagementRuntimeRef runtimeRef = (ManagementRuntimeRef) annotations.get(ManagementRuntimeRef.class.getName());
            if (runtimeRef != null)
            {
               componentName = icf.getComponentName(beanInfo, property, object, value);
               // let's try this as well
               if (componentName == null && icf != this)
                  componentName = getComponentName(beanInfo, property, object, value);
            }
         }
      }
      if (componentName == null)
         componentName = icf.getComponentName(null, null, object, null);
      // set it, even if it's null
      managedObject.setComponentName(componentName);
   }
View Full Code Here

   @SuppressWarnings("unchecked")
   public <T extends Serializable> InstanceClassFactory<T> getInstanceClassFactory(Class<T> clazz)
   {
      synchronized (instanceFactories)
      {
         InstanceClassFactory factory = instanceFactories.get(clazz);
         if (factory != null)
            return factory;
      }
      return (InstanceClassFactory<T>)this;
   }
View Full Code Here

            else
               metaValue = (MetaValue)value;

            if (metaValue == null || metaValue.getMetaType().isTable() == false)
            {
               InstanceClassFactory icf = getObjectFactory().getInstanceClassFactory(attachment.getClass());
               BeanInfo beanInfo = propertyInfo.getBeanInfo();
               icf.setValue(beanInfo, this, attachment, metaValue);
            }
         }
      }
   }
View Full Code Here

      if (propertyInfo != null)
      {
         Object attachment = getManagedObject().getAttachment();
         if (attachment != null)
         {
            InstanceClassFactory icf = getMOFactory().getInstanceClassFactory(attachment.getClass());
            BeanInfo beanInfo = propertyInfo.getBeanInfo();
            icf.setValue(beanInfo, this, attachment, value);
         }
      }
   }
View Full Code Here

      {
         Object attachment = getManagedObject().getAttachment();
         if (attachment != null)
         {
            MetaValue metaValue = value;
            InstanceClassFactory icf = getMOFactory().getInstanceClassFactory(attachment.getClass());
            BeanInfo beanInfo = propertyInfo.getBeanInfo();
            icf.setValue(beanInfo, this, attachment, metaValue);
         }
      }
   }
View Full Code Here

TOP

Related Classes of org.jboss.managed.spi.factory.InstanceClassFactory

Copyright © 2018 www.massapicom. 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.