Examples of ManagedProperty


Examples of br.gov.frameworkdemoiselle.annotation.ManagedProperty

      .append("get")
      .append(field.getName().substring(0, 1).toUpperCase())
      .append(field.getName().substring(1));
   
    //Se propriedade está anotada como WRITE-ONLY, ignora essa etapa.
    ManagedProperty annotation = field.getAnnotation(ManagedProperty.class);
    if (annotation.accessLevel() == ManagedPropertyAccess.WRITE_ONLY){
      return null;
    }

    Method getterMethod;
View Full Code Here

Examples of javax.faces.bean.ManagedProperty

      Set<Map.Entry<String, Field>> managedPropertyEntrySet = managedPropertyFields.entrySet();

      for (Map.Entry<String, Field> managedPropertyMapEntry : managedPropertyEntrySet) {
        String managedPropertyName = managedPropertyMapEntry.getKey();
        Field managedPropertyField = managedPropertyMapEntry.getValue();
        ManagedProperty managedPropertyAnnotation = managedPropertyField.getAnnotation(ManagedProperty.class);
        String managedPropertyExpression = managedPropertyAnnotation.value();

        if ((managedPropertyExpression != null) && (managedPropertyExpression.length() > 0)) {
          managedPropertyInjector.inject(managedBean, managedPropertyName, managedPropertyField.getType(),
            managedPropertyExpression);
        }
View Full Code Here

Examples of org.apache.myfaces.config.element.ManagedProperty

        ELResolver elResolver = facesContext.getApplication().getELResolver();
        ELContext elContext = facesContext.getELContext();

        while (managedProperties.hasNext())
        {
            ManagedProperty property = (ManagedProperty) managedProperties.next();
            Object value = null;

            switch (property.getType())
            {
                case ManagedProperty.TYPE_LIST:

                    // JSF 1.1, 5.3.1.3
                    // Call the property getter, if it exists.
                    // If the getter returns null or doesn't exist, create a java.util.ArrayList,
                    // otherwise use the returned Object ...
                    if (PropertyUtils.isReadable(bean, property.getPropertyName()))
                        value = elResolver.getValue(elContext, bean, property.getPropertyName());
                    value = value == null ? new ArrayList() : value;

                    if (value instanceof List)
                    {
                        initializeList(facesContext, property.getListEntries(), (List) value);

                    }
                    else if (value != null && value.getClass().isArray())
                    {
                        int length = Array.getLength(value);
                        ArrayList temp = new ArrayList(length);
                        for (int i = 0; i < length; i++)
                        {
                            temp.add(Array.get(value, i));
                        }
                        initializeList(facesContext, property.getListEntries(), temp);
                        value = Array.newInstance(value.getClass().getComponentType(), temp.size());
                        length = temp.size();

                        for (int i = 0; i < length; i++)
                        {
                            Array.set(value, i, temp.get(i));
                        }
                    }
                    else
                    {
                        value = new ArrayList();
                        initializeList(facesContext, property.getListEntries(), (List) value);
                    }

                    break;
                case ManagedProperty.TYPE_MAP:

                    // JSF 1.1, 5.3.1.3
                    // Call the property getter, if it exists.
                    // If the getter returns null or doesn't exist, create a java.util.HashMap,
                    // otherwise use the returned java.util.Map .
                    if (PropertyUtils.isReadable(bean, property.getPropertyName()))
                        value = elResolver.getValue(elContext, bean, property.getPropertyName());
                    value = value == null ? new HashMap() : value;

                    if (!(value instanceof Map))
                    {
                        value = new HashMap();
                    }

                    initializeMap(facesContext, property.getMapEntries(), (Map) value);
                    break;
                case ManagedProperty.TYPE_NULL:
                    value = null;
                    break;
                case ManagedProperty.TYPE_VALUE:
                    // check for correct scope of a referenced bean
                    if (!isInValidScope(facesContext, property, targetScope))
                    {
                        throw new FacesException("Property " + property.getPropertyName() +
                                " references object in a scope with shorter lifetime than the target scope " + targetScope);
                    }
                    value = property.getRuntimeValue(facesContext);
                    break;
            }
            Class propertyClass = null;

            if (property.getPropertyClass() == null)
            {
                propertyClass = elResolver
                        .getType(elContext, bean, property.getPropertyName());
            }
            else
            {
                propertyClass = ClassUtils
                        .simpleJavaTypeToClass(property.getPropertyClass());
            }
            if (null == propertyClass)
            {
                throw new IllegalArgumentException("unable to find the type of property " + property.getPropertyName());
            }
            Object coercedValue = coerceToType(facesContext, value, propertyClass);
            elResolver.setValue(
                    elContext, bean, property.getPropertyName(), coercedValue);
        }
    }
View Full Code Here

Examples of org.apache.myfaces.config.impl.digester.elements.ManagedProperty

        // create sessionBean referencing requestBean
        ManagedBean sessionBean = new ManagedBean();
        sessionBean.setBeanClass(TestBean.class.getName());
        sessionBean.setName("sessionBean");
        sessionBean.setScope("session");
        ManagedProperty anotherBeanProperty = new ManagedProperty();
        anotherBeanProperty.setPropertyName("anotherBean");
        anotherBeanProperty.setValue("#{requestBean}");
        sessionBean.addProperty(anotherBeanProperty);
        runtimeConfig.addManagedBean("sessionBean", sessionBean);
       
        // create requestBean
        ManagedBean requestBean = new ManagedBean();
View Full Code Here

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

Examples of org.jboss.managed.api.ManagedProperty

  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

Examples of org.jboss.managed.api.ManagedProperty

    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

Examples of org.jboss.managed.api.ManagedProperty

    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

Examples of org.jboss.managed.api.ManagedProperty

      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

Examples of org.jboss.managed.api.ManagedProperty

    }
    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
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.