Package org.jboss.managed.api

Examples of org.jboss.managed.api.MutableManagedObject


         throw new IllegalArgumentException("Null managed object");
     
      if (managedObject instanceof MutableManagedObject == false)
         throw new IllegalStateException("Unable to create object " + managedObject.getClass().getName());
     
      MutableManagedObject managedObjectImpl = (MutableManagedObject) managedObject;
      T object = createUnderlyingObject(managedObjectImpl, clazz);
      populateManagedObject(managedObjectImpl, object, null);
   }
View Full Code Here


      else
         mo = mof.initManagedObject(value, null, metaData, moName, moNameType);
      ManagedObject parentMO = property.getManagedObject();
      if(parentMO != null && mo instanceof MutableManagedObject)
      {
         MutableManagedObject mmo = (MutableManagedObject) mo;
         mmo.setParent(parentMO);
      }
      return new GenericValueSupport(AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE, mo);
   }
View Full Code Here

   public void setOperations(Set<ManagedOperation> operations)
   {
      ManagedObject mo = getDelegate();
      if(mo instanceof MutableManagedObject)
      {
         MutableManagedObject mmo = MutableManagedObject.class.cast(mo);
         mmo.setOperations(operations);
      }
   }
View Full Code Here

   public void setProperties(Map<String, ManagedProperty> properties)
   {
      ManagedObject mo = getDelegate();
      if(mo instanceof MutableManagedObject)
      {
         MutableManagedObject mmo = MutableManagedObject.class.cast(mo);
         mmo.setProperties(properties);
      }     
   }
View Full Code Here

      }
      log.debug("Created skeleton ManagedObject: "+result);

      if(result instanceof MutableManagedObject)
      {
         MutableManagedObject mmo = (MutableManagedObject) result;
         ManagedObjectPopulator<Object> populator = getPopulator(moClass);
         populator.populateManagedObject(mmo, instance, metaData);
         // Set a default MO.name to the MO.componentName
         Boolean hasDefaultName = (Boolean) mmo.getTransientAttachment("ManagedObject.hasDefaultName");
         Object compName = mmo.getComponentName();
         if(hasDefaultName && compName != null)
         {
            String moName = compName.toString();
            mmo.setName(moName);
         }
      }

      return result;
   }
View Full Code Here

         throw new IllegalArgumentException("Null managed object");
     
      if (managedObject instanceof MutableManagedObject == false)
         throw new IllegalStateException("Unable to create object " + managedObject.getClass().getName());
     
      MutableManagedObject managedObjectImpl = (MutableManagedObject) managedObject;
      T object = createUnderlyingObject(managedObjectImpl, clazz);
      populateManagedObject(managedObjectImpl, object, null);
   }
View Full Code Here

               GenericValueSupport gv = new GenericValueSupport(AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE, bmdfMO);
               tmpBFs.add(gv);
               continue;
            }

            MutableManagedObject bmdfMMO = (MutableManagedObject) bmdfMO;
            bmdfMMO.setParent(deploymentMO);
            Map<String, ManagedProperty> oldProps = bmdfMMO.getProperties();
            ManagedProperty beansMPCheck = oldProps.get("beans");
            // If there already is a beans property assume it's correct
            if(beansMPCheck != null)
            {
               // Need to map
               continue;
            }

            Map<String, ManagedProperty> newProps = new HashMap<String, ManagedProperty>(oldProps);
            // Create a beans ManagedProperty, a list of BeanMetaData ManagedObjects
            Fields fields = getFields("beans", beansType);
            ManagedPropertyImpl beansMP = new ManagedPropertyImpl(bmdfMO, fields);
            newProps.put("beans", beansMP);

            // Create a ManagedObject for each of the beans BeanMetaData
            List<BeanMetaData> beans = bmdf.getBeans();
            if(beans != null)
            {
               for(BeanMetaData bmd : beans)
               {
                  DeploymentUnit compUnit = unit.getComponent(bmd.getName());
                  if(compUnit == null)
                  {
                     log.debug("Failed to find component for bean: "+bmd.getName());
                     continue;
                  }
                  MetaData compMetaData = compUnit.getMetaData();
                  GenericValue gv = getManagedObjectValue(bmd, compMetaData, bmdfMO);
                  if(gv != null)
                  {
                     // The component managed objects need to be in the root map
                     ManagedObject compMO = (ManagedObject) gv.getValue();
                     // Use the ManagedObject name if it's not the same as the attachmentName
                     String managedObjectName = compUnit.getName();
                     if(compMO != null && compMO.getAttachmentName() != null)
                     {
                        managedObjectName = compMO.getAttachmentName().equals(compMO.getName()) ?
                              compUnit.getName() : compMO.getName();
                     }
                     // Add the managed object
                     managedObjects.put(managedObjectName, compMO);
                     // Add the bean MO to the beans list
                     tmpBeans.add(gv);
                  }
               }
            }
            GenericValue[] beanMOs = new GenericValue[tmpBeans.size()];
            tmpBeans.toArray(beanMOs);
            CollectionValueSupport values = new CollectionValueSupport(beansType, beanMOs);
            beansMP.setValue(values);
            // Update the bean factory properties
            bmdfMMO.setProperties(newProps);
         }
      }
      GenericValue[] mos = new GenericValue[tmpBFs.size()];
      tmpBFs.toArray(mos);
      CollectionValueSupport values = new CollectionValueSupport(beansFactoryType, mos);
View Full Code Here

   {
      String name = bmd.getName();
      ManagedObject mo = mof.initManagedObject(bmd, null, metaData, name, null);
      if(parentMO != null && mo instanceof MutableManagedObject)
      {
         MutableManagedObject mmo = (MutableManagedObject) mo;
         mmo.setParent(parentMO);
         Map<String, ManagedProperty> oldProps = mmo.getProperties();
         Map<String, ManagedProperty> newProps = new HashMap<String, ManagedProperty>(oldProps);
         // Add a state property
         Fields stateFields = getFields("state", ControllerStateMetaType.TYPE);
         ManagedPropertyImpl stateMP = new ManagedPropertyImpl(mmo, stateFields);
         newProps.put("state", stateMP);
         mmo.setProperties(newProps);
      }
      return new GenericValueSupport(AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE, mo);
   }
View Full Code Here

               Map<String, Annotation> moAnns = bmdMO.getAnnotations();
               ManagementObject mo = (ManagementObject) moAnns.get(ManagementObject.class.getName());
               // Reset the name to the bean name rather than the attachment name
               if(bmdMO instanceof MutableManagedObject)
               {
                  MutableManagedObject mmo = (MutableManagedObject) bmdMO;
                  // Reset the name to the bean name if its the attachment name
                  if(mmo.getName().equals(mmo.getAttachmentName()))
                     mmo.setName(bmd.getName());
                  mmo.setParent(kdMO);
                  // Add an alias property
                  Set<Object> bmdAliases = bmd.getAliases();
                  Map<String, ManagedProperty> oldProps = mmo.getProperties();
                  Map<String, ManagedProperty> newProps = new HashMap<String, ManagedProperty>(oldProps);
                  if(bmdAliases != null && bmdAliases.size() > 0)
                  {
                     ArrayMetaType aliasType = new ArrayMetaType(SimpleMetaType.STRING, false);
                     DefaultFieldsImpl fields = getFields("alias", aliasType);
                     fields.setDescription("Aliases of the bean");
                     String[] aliases = new String[bmdAliases.size()];
                     Iterator<?> i = bmdAliases.iterator();
                     for(int n = 0; i.hasNext(); n++)
                     {
                        aliases[n] = i.next().toString();
                     }
                     ArrayValueSupport value = new ArrayValueSupport(aliasType, aliases);
                     fields.setValue(value);
                     ManagedPropertyImpl aliasesMP = new ManagedPropertyImpl(bmdMO, fields);
                     newProps.put("alias", aliasesMP);
                  }
                  // Add a state property
                  DefaultFieldsImpl stateFields = getFields("state", ControllerStateMetaType.TYPE);
                  stateFields.setViewUse(new ViewUse[]{ViewUse.STATISTIC});
                  EnumValue stateValue = getState(bmd.getName(), kernel);
                  stateFields.setValue(stateValue);
                  stateFields.setDescription("The bean controller state");
                  ManagedPropertyImpl stateMP = new ManagedPropertyImpl(mmo, stateFields);
                  newProps.put("state", stateMP);
                  // Update the properties
                  mmo.setProperties(newProps);
               }
               log.debug("Created ManagedObject: "+bmdMO+" for bean: "+bmd.getName());
               kdMOs.put(bmd.getName(), bmdMO);

            }
            // Create the ManagedDeployment
            ManagedDeployment md = mgtDeploymentCreator.build(deploymentUnit, kdMOs, null);
            if(firstDeployment == null)
               firstDeployment = md;
            // Create the ManagedComponents
            for(ManagedObject bmdMO : kdMOs.values())
            {
               if(bmdMO.getAttachmentName().equals(KernelDeployment.class.getName()))
                  continue;

               ComponentType type = KnownComponentTypes.MCBean.Any.getType();
               Map<String, Annotation> moAnns = bmdMO.getAnnotations();
               ManagementComponent mc = (ManagementComponent) moAnns.get(ManagementComponent.class.getName());
               if(mc != null)
               {
                  type = new ComponentType(mc.type(), mc.subtype());
               }
               ManagedComponentImpl comp = new ManagedComponentImpl(type, md, bmdMO);
               md.addComponent(bmdMO.getName(), comp);
               log.debug("Created ManagedComponent("+comp.getName()+") of type: "
                     +type
                     +" for MO: "+bmdMO.getName()
                     +", componentName: "+bmdMO.getComponentName());              
            }

            if(md != null)
               bootstrapMDs.put(kd.getName(), md);
         }

         // Add other Server managed objects
         if(firstDeployment != null)
         {
            ComponentType type = new ComponentType("MCBean", "MCServer");
            ManagedObject serverMO = mof.initManagedObject(mcserver, null);
            if (serverMO.getOperations() != null && serverMO.getOperations().size() == 0)
            {
               ManagedOperationImpl shutdown = new ManagedOperationImpl("Shutdown the server", "shutdown");
               if(serverMO instanceof MutableManagedObject)
               {
                  HashSet<ManagedOperation> ops = new HashSet<ManagedOperation>();
                  ops.add(shutdown);
                  MutableManagedObject mmo = MutableManagedObject.class.cast(serverMO);
                  mmo.setOperations(ops);
               }
            }
            ManagedComponentImpl serverComp = new ManagedComponentImpl(type, firstDeployment, serverMO);
            firstDeployment.addComponent("MCServer", serverComp);
            try
View Full Code Here

      }
      log.debug("Created skeleton ManagedObject: "+result);

      if(result instanceof MutableManagedObject)
      {
         MutableManagedObject mmo = (MutableManagedObject) result;
         ManagedObjectPopulator<Object> populator = getPopulator(moClass);
         populator.populateManagedObject(mmo, instance, metaData);
      }

      return result;
View Full Code Here

TOP

Related Classes of org.jboss.managed.api.MutableManagedObject

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.