Package org.infinispan.config

Examples of org.infinispan.config.ConfigurationAttribute


   }
  
   void reflectAndInvokeAttribute(AbstractConfigurationBean bean, Method m, Element node) {    
      Class<?> parameterType = m.getParameterTypes()[0];
      // is there a ConfigurationAttribute matching the current node iterated?
      ConfigurationAttribute a = m.getAnnotation(ConfigurationAttribute.class);
      boolean matchedAttributeToSetter = a != null && a.containingElement().equals(node.getNodeName());
      boolean isConfigBean = AbstractConfigurationBean.class.isAssignableFrom(parameterType);
      if (matchedAttributeToSetter) {
         String attValue = getAttributeValue(node, a.name());
         Object methodAttributeValue = null;
         if (attValue != null && attValue.length() > 0) {
            PropertyEditor editor = PropertyEditorManager.findEditor(parameterType);
            if (editor == null) {
               throw new ConfigurationException("Could not find property editor, type="
                        + parameterType + ",method=" + m + ",attribute=" + a.name());
            }
            editor.setAsText(attValue);
            methodAttributeValue = editor.getValue();
         } else if (a.defaultValue().length() > 0) {
            methodAttributeValue = a.defaultValue();
         }
         if (methodAttributeValue != null) {
            try {
               m.invoke(bean, methodAttributeValue);
            } catch (Exception ae) {
               throw new ConfigurationException("Illegal attribute value " + attValue + ",type="
                        + parameterType + ",method=" + m + ",attribute=" + a.name(), ae);
            }
         }
      } else if (isConfigBean) {
         AbstractConfigurationBean childBean = findAndInstantiateBean(node);
         boolean foundMatchingChild = childBean != null
View Full Code Here


                     }
                     sb.append("\n");
                  }
                  sb.append("</p>");
                  for (Method m : clazz.getMethods()) {
                     ConfigurationAttribute a = m.getAnnotation(ConfigurationAttribute.class);
                     boolean childElement = a != null && a.containingElement().equals(ce.name());
                     if (childElement && !createdAttributes) {
                        // Attributes
                        sb.append("<table class=\"bodyTable\"> ");
                        sb.append("<tr class=\"a\"><th>Attribute</th><th>Type</th><th>Default</th><th>Description</th></tr>\n");
                        createdAttributes = true;
                     }
                     if (childElement) {
                        sb.append("<tr class=\"b\">");
                        sb.append("<td>").append("<code>" + a.name() +"</code>").append("</td>\n");
                       
                        //if allowed values specified for attribute, use it
                        if (a.allowedValues().length() > 0) {
                           sb.append("<td>").append("<code>" + a.allowedValues()+"</code>").append("</td>\n");
                        }
                        //otherwise, reflect method and use parameter as allowed value
                        else if (isSetterMethod(m)) {
                           sb.append("<td>").append("<code>" + m.getParameterTypes()[0].getSimpleName() + "</code>").append("</td>\n");
                        }
                       
                        //if default value specified in annotation use it
                        if (a.defaultValue().length() > 0) {
                           sb.append("<td>").append(a.defaultValue()).append("</td>\n");
                        }

                        //otherwise reflect that field and read default value
                        else {
                           try {
                              //reflect default value
                              Object matchingFieldValue = matchingFieldValue(m);
                              sb.append("<td>").append(matchingFieldValue).append("</td>\n");
                           } catch (Exception e) {
                              sb.append("<td>").append("N/A").append("</td>\n");
                           }
                        }                  
                        if(a.description().length() >0)
                           sb.append("<td>").append(a.description()).append("</td>\n");
                        else
                           sb.append("<td>").append("todo").append("</td>\n");
          
                        sb.append("</tr>\n");
                     }
View Full Code Here

TOP

Related Classes of org.infinispan.config.ConfigurationAttribute

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.