Package org.jboss.managed.api

Examples of org.jboss.managed.api.ManagedProperty


  
  public void build(DeploymentUnit unit, Set<String> outputs, Map<String, ManagedObject> managedObjects) throws DeploymentException {
    if (isBuildManagedObject()) {
      ManagedObject mo = managedObjects.get(TranslatorMetaDataGroup.class.getName());
      if (mo != null) {
        ManagedProperty translators = mo.getProperty("translators"); //$NON-NLS-1$
        MetaType propType = translators.getMetaType();
        if (propType.isCollection()) {
          CollectionValue value = (CollectionValue) translators.getValue();
          if (value != null) {
            for (MetaValue element:value.getElements()) {
              ManagedObject translator = (ManagedObject)((GenericValue)element).getValue();
              managedObjects.put(translator.getName(), translator);
            }
View Full Code Here


  public static ManagedProperty createProperty(String name,
      SimpleMetaType type, String displayName, String description,
      boolean mandatory, boolean readOnly, Serializable defaultValue, boolean advanced,
      boolean masked, String[] allowed) {
   
    ManagedProperty mp = createProperty(name, type, displayName, description, mandatory, readOnly, defaultValue);
    mp.setField("advanced",  SimpleValueSupport.wrap(advanced));//$NON-NLS-1$ 
    mp.setField("masked",  SimpleValueSupport.wrap(masked));//$NON-NLS-1$
    if (allowed != null) {
      HashSet<MetaValue> values = new HashSet<MetaValue>();
      for (String value:allowed) {
        values.add(SimpleValueSupport.wrap(value));
      }
      mp.setField(Fields.LEGAL_VALUES, values);
    }   
    return mp;   
  }
View Full Code Here

    Map<String, ManagedProperty> infoProps = new HashMap<String, ManagedProperty>();
   
    Object factory = attachmentClass.newInstance();
   
    for (Map.Entry<Method, TranslatorProperty> entry : props.entrySet()) {
      ManagedProperty mp = ManagedPropertyUtil.convert(factory, entry.getKey(), entry.getValue());
      infoProps.put(mp.getName(), mp);
    }
    return infoProps;
  }
View Full Code Here

    TranslatorMetaData translator = new TranslatorMetaData();
        this.mof.setInstanceClassFactory(TranslatorMetaData.class, new TranslatorMetadataICF(this.mof));
        ManagedObject mo = mof.initManagedObject(translator, "teiid", "translator"); //$NON-NLS-1$ //$NON-NLS-2$   

    for (ManagedProperty mp : values.getProperties().values()) {
      ManagedProperty dsProp = mo.getProperty(mp.getName());
      if (dsProp != null) {
        if (mp.getValue() != null) {
          dsProp.setValue(mp.getValue());
        }
       
        if(mp.isMandatory() && mp.getValue() == null && mp.getDefaultValue() == null) {
          throw new DeploymentException(RuntimePlugin.Util.getString("required_property_not_exists", mp.getName())); //$NON-NLS-1$
        }
View Full Code Here

      List<ManagedObject> models = (List<ManagedObject>)MetaValueFactory.getInstance().unwrap(property.getValue());
      for(ManagedObject managedModel:models) {
        String modelName = ManagedUtil.getSimpleValue(managedModel, "name", String.class); //$NON-NLS-1$
        ModelMetaData model = vdb.getModel(modelName);
       
            ManagedProperty sourceMappings = managedModel.getProperty("sourceMappings");//$NON-NLS-1$
            if (sourceMappings != null){
                List<ManagedObject> mappings = (List<ManagedObject>)MetaValueFactory.getInstance().unwrap(sourceMappings.getValue());
                for (ManagedObject mo:mappings) {
                    String name = ManagedUtil.getSimpleValue(mo, "name", String.class);//$NON-NLS-1$
                    String jndiName = ManagedUtil.getSimpleValue(mo, "connectionJndiName", String.class);//$NON-NLS-1$
                    String translatorName = ManagedUtil.getSimpleValue(mo, "translatorName", String.class);//$NON-NLS-1$
                    model.addSourceMapping(name, translatorName, jndiName);
                }
            }       
      }           
    }
    else if (property.getName().equals("JAXBProperties")) { //$NON-NLS-1$
      List<ManagedObject> properties = (List<ManagedObject>)MetaValueFactory.getInstance().unwrap(property.getValue());
      for (ManagedObject managedProperty:properties) {
        vdb.addProperty(ManagedUtil.getSimpleValue(managedProperty, "name", String.class), ManagedUtil.getSimpleValue(managedProperty, "value", String.class)); //$NON-NLS-1$ //$NON-NLS-2$
      }
    }
    else if (property.getName().equals("dataPolicies")) { //$NON-NLS-1$
      List<ManagedObject> policies = (List<ManagedObject>)MetaValueFactory.getInstance().unwrap(property.getValue());
      for(ManagedObject managedPolicy:policies) {
        String policyName = ManagedUtil.getSimpleValue(managedPolicy, "name", String.class); //$NON-NLS-1$
        Boolean anyAuthenticated = ManagedUtil.getSimpleValue(managedPolicy, "anyAuthenticated", Boolean.class); //$NON-NLS-1$
        DataPolicyMetadata policy = vdb.getDataPolicy(policyName);
        policy.setAnyAuthenticated(Boolean.TRUE.equals(anyAuthenticated));
            ManagedProperty mappedRoleNames = managedPolicy.getProperty("mappedRoleNames");//$NON-NLS-1$
            if (mappedRoleNames != null){
                List<String> roleNames = (List<String>)MetaValueFactory.getInstance().unwrap(mappedRoleNames.getValue());
                policy.setMappedRoleNames(roleNames);
            }       
      }
    }   
    else if (property.getName().equals("overrideTranslators")) { //$NON-NLS-1$
      List<ManagedObject> translators = (List<ManagedObject>)MetaValueFactory.getInstance().unwrap(property.getValue());
      for (ManagedObject translator:translators) {
        VDBTranslatorMetaData translatorInstance = vdb.getTranslator(translator.getName());
        ManagedProperty mp = translator.getProperty("property"); //$NON-NLS-1$
        List<PropertyMetadata> properties = (List<PropertyMetadata>)MetaValueFactory.getInstance().unwrap(mp.getValue());
        for (PropertyMetadata managedProperty:properties) {
          translatorInstance.addProperty(managedProperty.getName(), managedProperty.getValue());
        }
      }
    }
View Full Code Here

    }
    return null;
 
 
  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$
     }
     return null;
View Full Code Here

     }
     return null;
 
 
  public static Properties getPropertiesValue(ManagedCommon mc, String prop) {
     ManagedProperty mp = mc.getProperty(prop);
     if (mp != null) {
       MetaType metaType = mp.getMetaType();
       if (metaType.isProperties()) {
         return (PropertiesMetaValue)mp.getValue();
       }
       else if (metaType.isComposite()) {
        Properties props = new Properties();
        MapCompositeValueSupport map = (MapCompositeValueSupport) mp.getValue();
        MapCompositeMetaType type = map.getMetaType();
        for (String key : type.keySet()) {
          MetaValue value = map.get(key);
          props.setProperty(key, stringValue(value));
        }
View Full Code Here

     }
     return null;
 
 
  public static <T> void getCollectionValue(ManagedCommon mc, String prop, Collection<T> list, Class<T> expectedType) {
     ManagedProperty mp = mc.getProperty(prop);
     if (mp != null) {
       MetaType metaType = mp.getMetaType();
       if (metaType.isCollection()) {
         CollectionValue collectionValue = (CollectionValue)mp.getValue();
         for(MetaValue value:collectionValue.getElements()) {
           if (value.getMetaType().isSimple()) {
             SimpleValue simpleValue = (SimpleValue)value;
             list.add(expectedType.cast(simpleValue.getValue()));
           }
View Full Code Here

  public <T> T buildAdminObject(ManagedCommon mc, Class<T> clazz) {
    try {
      Object t = clazz.newInstance();     
          ManagedObject mo = mof.initManagedObject(t, "teiid", "translator"); //$NON-NLS-1$ //$NON-NLS-2$   
      for (ManagedProperty mp : mc.getProperties().values()) {
        ManagedProperty dsProp = mo.getProperty(mp.getName());
        if (dsProp != null) {
          if (mp.getValue() != null) {
            dsProp.setValue(mp.getValue());
          }
        }
      } 
      return clazz.cast(t);
    } catch (InstantiationException e) {
View Full Code Here

  }
 
  private void populate() {
    super.start();

    ManagedProperty mp = this.getProperties().get("connection-definition");//$NON-NLS-1$ 
    mp.setValue(ManagedUtil.wrap(SimpleMetaType.STRING, "javax.sql.DataSource"));//$NON-NLS-1$ 

    mp = this.getProperties().get("dsType");//$NON-NLS-1$ 
    mp.setValue(ManagedUtil.wrap(SimpleMetaType.STRING, "local-tx-datasource"));//$NON-NLS-1$ 
   
    ManagedPropertyImpl dsTypeMP = buildConfigProperty();
    addProperty(dsTypeMP);
   
    addProperty(ConnectorTemplateInfo.buildTemplateProperty(getName()));
View Full Code Here

TOP

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

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.