Examples of MetaType


Examples of org.jboss.metatype.api.types.MetaType

 
  public static <T> T getSimpleValue(ManagedComponent mc, String prop,
      Class<T> expectedType) {
    ManagedProperty mp = mc.getProperty(prop);
    if (mp != null) {
      MetaType metaType = mp.getMetaType();
      if (metaType.isSimple()) {
        SimpleValue simpleValue = (SimpleValue) mp.getValue();
        return expectedType.cast((simpleValue != null) ? simpleValue
            .getValue() : null);
      } else if (metaType.isEnum()) {
        EnumValue enumValue = (EnumValue) mp.getValue();
        return expectedType.cast((enumValue != null) ? enumValue
            .getValue() : null);
      }
      throw new IllegalStateException(prop + " is not a simple type"); //$NON-NLS-1$
View Full Code Here

Examples of org.jboss.metatype.api.types.MetaType

  }

  public static <T> T getSimpleValue(MetaValue prop,
      Class<T> expectedType) {
    if (prop != null) {
      MetaType metaType = prop.getMetaType();
      if (metaType.isSimple()) {
        SimpleValue simpleValue = (SimpleValue) prop;
        return expectedType.cast((simpleValue != null) ? simpleValue
            .getValue() : null);
      } else if (metaType.isEnum()) {
        EnumValue enumValue = (EnumValue) prop;
        return expectedType.cast((enumValue != null) ? enumValue
            .getValue() : null);
      }
      throw new IllegalStateException(prop + " is not a simple type"); //$NON-NLS-1$
View Full Code Here

Examples of org.jboss.metatype.api.types.MetaType

 
  public static <T> T getSimpleValue(ManagedCommon mc, String prop,
      Class<T> expectedType) {
    ManagedProperty mp = mc.getProperty(prop);
    if (mp != null) {
      MetaType metaType = mp.getMetaType();
      if (metaType.isSimple()) {
        SimpleValue simpleValue = (SimpleValue) mp.getValue();
        return expectedType.cast((simpleValue != null) ? simpleValue
            .getValue() : null);
      } else if (metaType.isEnum()) {
        EnumValue enumValue = (EnumValue) mp.getValue();
        return expectedType.cast((enumValue != null) ? enumValue
            .getValue() : null);
      }
      throw new IllegalArgumentException(prop + " is not a simple type"); //$NON-NLS-1$
View Full Code Here

Examples of org.jboss.metatype.api.types.MetaType

      propertyAdapter = PropertyAdapterFactory.getPropertyAdapter(metaValue);

      propertyAdapter.populateMetaValueFromProperty(configuration.getSimple(propertyDefinition.getName()), metaValue, propertyDefinition);
      managedProperty.setValue(metaValue);
    } else {
      MetaType metaType = managedProperty.getMetaType();
      propertyAdapter = PropertyAdapterFactory.getPropertyAdapter(metaType);
      LOG.trace("Converting property " + propertyDefinition.getName()   + " with definition " + propertyDefinition   + " to MetaValue of type " + metaType + "..."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
      metaValue = propertyAdapter.convertToMetaValue(configuration.getSimple(propertyDefinition.getName()),propertyDefinition, metaType);
      managedProperty.setValue(metaValue);
    }
View Full Code Here

Examples of org.jboss.metatype.api.types.MetaType

      LOG.debug("Cannot update default value on non-simple property definition " //$NON-NLS-1$
              + propertyDefinition + "(default value is " //$NON-NLS-1$
              + defaultValue + ")."); //$NON-NLS-1$
      return;
    }
    MetaType metaType = defaultValue.getMetaType();
    if (!metaType.isSimple() && !metaType.isEnum()) {
      LOG.debug("Cannot update default value on " + propertyDefinition //$NON-NLS-1$
          + ", because default value's type (" + metaType //$NON-NLS-1$
          + ") is not simple or enum."); //$NON-NLS-1$
      return;
    }
    PropertyDefinitionSimple propertyDefinitionSimple = (PropertyDefinitionSimple) propertyDefinition;
    if (metaType.isSimple()) {
      SimpleValue defaultSimpleValue = (SimpleValue) defaultValue;
      Serializable value = defaultSimpleValue.getValue();
      propertyDefinitionSimple.setDefaultValue((value != null) ? value.toString() : null);
    } else { // defaultValueMetaType.isEnum()
      EnumValue defaultEnumValue = (EnumValue) defaultValue;
View Full Code Here

Examples of org.jboss.metatype.api.types.MetaType

    }
  }

  public static MetaType convertPropertyDefinitionToMetaType(
      PropertyDefinition propDef) {
    MetaType memberMetaType;
    if (propDef instanceof PropertyDefinitionSimple) {
      PropertySimpleType propSimpleType = ((PropertyDefinitionSimple) propDef)
          .getType();
      memberMetaType = convertPropertySimpleTypeToSimpleMetaType(propSimpleType);
    } else if (propDef instanceof PropertyDefinitionList) {
      // TODO (very low priority, since lists of lists are not going to be
      // at all common)
      memberMetaType = null;
    } else if (propDef instanceof PropertyDefinitionMap) {
      Map<String, PropertyDefinition> memberPropDefs = ((PropertyDefinitionMap) propDef)
          .getPropertyDefinitions();
      if (memberPropDefs.isEmpty())
        throw new IllegalStateException(
            "PropertyDefinitionMap doesn't contain any member PropertyDefinitions."); //$NON-NLS-1$
      // NOTE: We assume member prop defs are all of the same type, since
      // for MapCompositeMetaTypes, they have to be.
      PropertyDefinition mapMemberPropDef = memberPropDefs.values()
          .iterator().next();
      MetaType mapMemberMetaType = convertPropertyDefinitionToMetaType(mapMemberPropDef);
      memberMetaType = new MapCompositeMetaType(mapMemberMetaType);
    } else {
      throw new IllegalStateException(
          "List member PropertyDefinition has unknown type: " //$NON-NLS-1$
              + propDef.getClass().getName());
View Full Code Here

Examples of org.jboss.metatype.api.types.MetaType

    return memberMetaType;
  }

  private static MetaType convertPropertySimpleTypeToSimpleMetaType(
      PropertySimpleType memberSimpleType) {
    MetaType memberMetaType;
    Class memberClass;
    switch (memberSimpleType) {
    case BOOLEAN:
      memberClass = Boolean.class;
      break;
View Full Code Here

Examples of org.jboss.metatype.api.types.MetaType

      assertNotNull("poolJndiName", poolJndiName);
      assertNotNull("poolJndiName.value", poolJndiName.getValue());

      ManagedProperty securityDomain = props.get("security-domain");
      assertNotNull("security-domain", securityDomain);
      MetaType securityDomainType = securityDomain.getMetaType();
      assertTrue("security-domain type is a GenericMetaType", securityDomainType instanceof CompositeMetaType);
      log.debug("security-domain type: "+securityDomainType);
      MetaValue securityDomainValue = securityDomain.getValue();
      assertTrue("security-domain value is a GenericValue", securityDomainValue instanceof CompositeValue);
      log.debug("security-domain value: "+securityDomainValue);
View Full Code Here

Examples of org.jboss.metatype.api.types.MetaType

      assertEquals("InvalidPropertys: "+invalidValues, 0, invalidValues.size());

      // Validate more details on specific properties
      ManagedProperty securityDomain = props.get("security-domain");
      assertNotNull("security-domain", securityDomain);
      MetaType securityDomainType = securityDomain.getMetaType();
      assertTrue("security-domain type("+securityDomainType+") is a GenericMetaType", securityDomainType instanceof CompositeMetaType);
      log.debug("security-domain type: "+securityDomainType);
   }
View Full Code Here

Examples of org.jboss.metatype.api.types.MetaType

      assertNotNull(queue);
      assertEquals("testCreateQueue", queue.getName());

      ManagedProperty bindings = queue.getProperty("bindings");
      assertNotNull(bindings);
      MetaType bindingsType = bindings.getMetaType();
      assertEquals(ArrayMetaType.getArrayType(SimpleMetaType.STRING), bindingsType);
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.