Package org.jboss.managed.spi.factory

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


    * @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
/*     */         {
/* 120 */           metaValue = getMetaValueFactory().create(value);
/*     */         }
/*     */
/* 123 */         InstanceClassFactory icf = getMOFactory().getInstanceClassFactory(attachment.getClass());
/* 124 */         BeanInfo beanInfo = propertyInfo.getBeanInfo();
/* 125 */         icf.setValue(beanInfo, this, attachment, metaValue);
/*     */       }
/*     */     }
/*     */   }
View Full Code Here

/*     */         else
/*     */         {
/* 116 */           metaValue = getMetaValueFactory().create(value);
/*     */         }
/*     */
/* 119 */         InstanceClassFactory icf = getMOFactory().getInstanceClassFactory(attachment.getClass());
/* 120 */         BeanInfo beanInfo = propertyInfo.getBeanInfo();
/* 121 */         icf.setValue(beanInfo, this, attachment, metaValue);
/*     */       }
/*     */     }
/*     */   }
View Full Code Here

/*     */         else {
/* 105 */           metaValue = (MetaValue)value;
/*     */         }
/* 107 */         if ((metaValue == null) || (!metaValue.getMetaType().isTable()))
/*     */         {
/* 109 */           InstanceClassFactory icf = getObjectFactory().getInstanceClassFactory(attachment.getClass());
/* 110 */           BeanInfo beanInfo = propertyInfo.getBeanInfo();
/* 111 */           icf.setValue(beanInfo, this, attachment, metaValue);
/*     */         }
/*     */       }
/*     */     }
/*     */   }
View Full Code Here

/*     */   public ManagedObject initManagedObject(Serializable object, String name, String nameType)
/*     */   {
/* 153 */     if (object == null) {
/* 154 */       throw new IllegalArgumentException("Null object");
/* 156 */     }Class clazz = object.getClass();
/* 157 */     InstanceClassFactory icf = getInstanceClassFactory(clazz);
/*     */     Class moClass;
/*     */     try { moClass = icf.getManagedObjectClass(object);
/*     */     }
/*     */     catch (ClassNotFoundException e)
/*     */     {
/* 165 */       return null;
/*     */     }
View Full Code Here

/*     */     }
/* 559 */     throw new RuntimeException("Unable to create new object for " + managedObject + " clazz=" + clazz, t);
/*     */   }
/*     */
/*     */   protected void populateValues(ManagedObjectImpl managedObject, Serializable object) {
/* 572 */     InstanceClassFactory icf = getInstanceClassFactory(object.getClass());
/*     */     Class moClass;
/*     */     try {
/* 576 */       moClass = icf.getManagedObjectClass(object);
/*     */     }
/*     */     catch (ClassNotFoundException e)
/*     */     {
/* 580 */       throw new IllegalStateException(e);
/*     */     }
/* 582 */     BeanInfo beanInfo = configuration.getBeanInfo(moClass);
/*     */
/* 584 */     Object componentName = null;
/* 585 */     Map properties = managedObject.getProperties();
/* 586 */     if ((properties != null) && (properties.size() > 0))
/*     */     {
/* 588 */       for (ManagedProperty property : properties.values())
/*     */       {
/* 590 */         MetaValue value = icf.getValue(beanInfo, property, object);
/* 591 */         if (value != null) {
/* 592 */           property.setField("value", value);
/*     */         }
/*     */
/* 596 */         Map annotations = property.getAnnotations();
/* 597 */         if (annotations == null)
/*     */           continue;
/* 599 */         ManagementObjectID id = (ManagementObjectID)annotations.get(ManagementObjectID.class.getName());
/* 600 */         if (id != null)
/*     */         {
/* 602 */           if ((value == null) || (!value.getMetaType().isSimple()))
/*     */           {
/* 604 */             log.warn("Cannot create String name from non-Simple property: " + property + ", value=" + value);
/*     */
/* 606 */             continue;
/*     */           }
/* 608 */           SimpleValue svalue = (SimpleValue)value;
/* 609 */           String name = "" + svalue.getValue();
/* 610 */           managedObject.setName(name);
/*     */         }
/* 612 */         ManagementRuntimeRef runtimeRef = (ManagementRuntimeRef)annotations.get(ManagementRuntimeRef.class.getName());
/* 613 */         if (runtimeRef != null)
/*     */         {
/* 615 */           componentName = icf.getComponentName(beanInfo, property, object, value);
/*     */
/* 617 */           if ((componentName == null) && (icf != this))
/* 618 */             componentName = getComponentName(beanInfo, property, object, value);
/*     */         }
/*     */       }
/*     */     }
/* 622 */     if (componentName == null) {
/* 623 */       componentName = icf.getComponentName(null, null, object, null);
/*     */     }
/* 625 */     managedObject.setComponentName(componentName);
/*     */   }
View Full Code Here

/*     */
/*     */   public <T extends Serializable> InstanceClassFactory<T> getInstanceClassFactory(Class<T> clazz)
/*     */   {
/* 883 */     synchronized (this.instanceFactories)
/*     */     {
/* 885 */       InstanceClassFactory factory = (InstanceClassFactory)this.instanceFactories.get(clazz);
/* 886 */       if (factory != null)
/* 887 */         return factory;
/*     */     }
/* 889 */     return this;
/*     */   }
View Full Code Here

   {
      if (instance == null)
         throw new IllegalArgumentException("instance cannot be null");

      Class<?> clazz = instance.getClass();
      InstanceClassFactory icf = defaultInstanceFactory;
      if(instanceType != null && instanceType != clazz)
         icf = getInstanceClassFactory(instanceType, metaData);
      if(icf == defaultInstanceFactory)
         icf = getInstanceClassFactory(clazz, metaData);

      Class<Object> moClass;
      try
      {
         moClass = icf.getManagedObjectClass(instance);
      }
      catch(ClassNotFoundException e)
      {
         log.debug("Failed to load class for ManagedObject", e);
         return null;
View Full Code Here

    */
   @SuppressWarnings("unchecked")
   public <X> InstanceClassFactory<X> getInstanceClassFactory(Class<X> clazz,
         MetaData metaData)
   {
      InstanceClassFactory defaultFactory = defaultInstanceFactory;
      if(metaData != null)
      {
         InstanceClassFactory mdrFactory = metaData.getMetaData(InstanceClassFactory.class);
         if(mdrFactory != null)
            defaultFactory = mdrFactory;
      }
      InstanceClassFactory<X> factory = (InstanceClassFactory<X>)
         Utility.getInstanceClassFactory(clazz, instanceFactories,
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.