Package org.jboss.managed.spi.factory

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


    PropertyInfo propertyInfo = getField(Fields.PROPERTY_INFO,PropertyInfo.class);
    if (propertyInfo != null) {
      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


      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

   {
      XADSInstanceClassFactory icf = new XADSInstanceClassFactory();
      XADataSourceDeploymentMetaData xads = new XADataSourceDeploymentMetaData();
      ManagedPropertyImpl property = new ManagedPropertyImpl("xa-datasource-properties");
      icf.getValue(null, property, null, xads);
      InstanceClassFactory icfref = icf;
      Serializable x = xads;
      icfref.getValue(null, property, null, x);
   }
View Full Code Here

   {
      XADSInstanceClassFactory icf = new XADSInstanceClassFactory();
      XADataSourceDeploymentMetaData xads = new XADataSourceDeploymentMetaData();
      ManagedPropertyImpl property = new ManagedPropertyImpl("xa-datasource-properties");
      icf.getValue(null, property, null, xads);
      InstanceClassFactory icfref = icf;
      Serializable x = xads;
      icfref.getValue(null, property, null, x);
   }
View Full Code Here

      {
         Object attachment = getManagedObject().getAttachment();
         if (attachment != null)
         {
            ManagedObjectFactory mof = getObjectFactory();
            InstanceClassFactory icf = mof.getInstanceClassFactory(attachment.getClass(), null);
            BeanInfo beanInfo = propertyInfo.getBeanInfo();
            icf.setValue(beanInfo, this, attachment, value);
         }
      }
      // Update the field value only after it has been written to the attachment
      super.setValue(value);
   }
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

   @SuppressWarnings("unchecked")
   public static InstanceClassFactory getInstanceClassFactory(Class<?> clazz,
         Map<Class<?>, InstanceClassFactory<?>> instanceFactories,
         InstanceClassFactory defaultInstanceFactory, MetaData metaData)
   {
      InstanceClassFactory defaultFactory = defaultInstanceFactory;
      if(metaData != null)
      {
         InstanceClassFactory mdrFactory = metaData.getMetaData(InstanceClassFactory.class);
         if(mdrFactory != null)
            defaultFactory = mdrFactory;
      }
     
      synchronized (instanceFactories)
      {
         Class<?> c = clazz;
         InstanceClassFactory factory = instanceFactories.get(c);
         while(factory == null && c != null && c != Object.class)
         {
            // First check for interfaces
            Class<?>[] ifaces = c.getInterfaces();
            if(ifaces != null)
            {
               for(Class<?> i : ifaces)
               {
                  factory = instanceFactories.get(i);
                  if(factory != null)
                     break;
               }
            }
            // Next look at superclasses
            if(factory == null)
            {
               c = c.getSuperclass();
               factory = instanceFactories.get(c);
            }
         }
         if (factory != null)
            return factory;
      }
      InstanceClassFactory factory = defaultFactory;
      return factory;
   }
View Full Code Here

    */
   @SuppressWarnings("unchecked")
   protected void populateValues(MutableManagedObject managedObject, T object,
         MetaData metaData)
   {
      InstanceClassFactory icf = getInstanceClassFactory(object.getClass(), metaData);
      Class moClass;
      try
      {
         moClass = icf.getManagedObjectClass(object);
      }
      catch(ClassNotFoundException e)
      {
         throw new IllegalStateException(e);
      }
     
      BeanInfo beanInfo = managedObject.getTransientAttachment(BeanInfo.class);
      if(beanInfo == null)
         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 = null;
            try
            {
               value = icf.getValue(beanInfo, property, metaData, object);
            }
            catch(Throwable t)
            {
               if(log.isTraceEnabled())
                  log.trace("Failed to access value for property: "+property, t);
            }

            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 && metaData == null)
               continue;
           
            ManagementObjectID id = getAnnotation(ManagementObjectID.class, annotations, metaData);
            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 = id.prefix() + svalue.getValue() + id.suffix();
               log.debug("Created name: "+name+" from property: "+property.getName());
               managedObject.setName(name);
            }
            ManagementRuntimeRef runtimeRef = getAnnotation(ManagementRuntimeRef.class, annotations, metaData);
            if (runtimeRef != null)
            {
               componentName = icf.getComponentName(beanInfo, property, object, value);
               if(componentName == null && defaultInstanceFactory != null)
               {
                  InstanceClassFactory dicf = defaultInstanceFactory;
                  componentName = dicf.getComponentName(beanInfo, property, object, value);
               }
            }
         }
      }
      if (componentName == null)
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.