Package org.jgroups.annotations

Examples of org.jgroups.annotations.Property


      // iterate overall properties marked by @Property
      for(int i = 0; i < objects.size(); i++) {
       
        // get the Property annotation
        AccessibleObject ao = objects.get(i) ;
        Property annotation = ao.getAnnotation(Property.class) ;
            if (annotation == null) {
              throw new IllegalArgumentException("@Property annotation is required for checking dependencies;" +
                  " annotation is missing for Field/Method " + ao.toString()) ;
            }
       
        String dependsClause = annotation.dependsUpon() ;
        if (dependsClause.trim().length() == 0)
          continue ;
       
        // split dependsUpon specifier into tokens; trim each token; search for token in list
        StringTokenizer st = new StringTokenizer(dependsClause, ",") ;
        while (st.hasMoreTokens()) {
          String token = st.nextToken().trim() ;
         
          // check that the string representing a property name is in the list
          boolean found = false ;
          Set<String> keyset = props.keySet();
          for (Iterator<String> iter = keyset.iterator(); iter.hasNext();) {
            if (iter.next().equals(token)) {
              found = true ;
              break ;
            }
          }
          if (!found) {
            throw new IllegalArgumentException("@Property annotation " + annotation.name() +
                " has an unresolved dependsUpon property: " + token) ;
          }
        }
      }
     
View Full Code Here


        }
    }

    public static void resolveAndInvokePropertyMethod(Object obj, Method method, Map<String,String> props) throws Exception {
      String methodName=method.getName();
        Property annotation=method.getAnnotation(Property.class);
      if(annotation != null && isSetPropertyMethod(method)) {
        String propertyName=PropertyHelper.getPropertyName(method) ;
        String propertyValue=props.get(propertyName);

            // if there is a systemProperty attribute defined in the annotation, set the property value from the system property
            String tmp=grabSystemProp(method.getAnnotation(Property.class));
            if(tmp != null)
                propertyValue=tmp;

            if(propertyName != null && propertyValue != null) {
                String deprecated_msg=annotation.deprecatedMessage();
                if(deprecated_msg != null && deprecated_msg.length() > 0) {
                    log.warn(method.getDeclaringClass().getSimpleName() + "." + methodName + " has been deprecated : " +
                            deprecated_msg);
                }
            }
View Full Code Here

            }
        }
    }

    public static void resolveAndAssignField(Object obj, Field field, Map<String,String> props) throws Exception {
        Property annotation=field.getAnnotation(Property.class);
      if(annotation != null) {
        String propertyName = PropertyHelper.getPropertyName(field, props) ;
        String propertyValue=props.get(propertyName);

            // if there is a systemProperty attribute defined in the annotation, set the property value from the system property
            String tmp=grabSystemProp(field.getAnnotation(Property.class));
            if(tmp != null)
                propertyValue=tmp;

            if(propertyName != null && propertyValue != null) {
                String deprecated_msg=annotation.deprecatedMessage();
                if(deprecated_msg != null && deprecated_msg.length() > 0) {
                    log.warn(field.getDeclaringClass().getSimpleName() + "." + field.getName() + " has been deprecated: " +
                            deprecated_msg);
                }
            }
View Full Code Here

        this.properties = properties ;
        this.stringValue = stringValue ;
        this.convertedValue = convertedValue ;
       
        // set the property name
        Property annotation=fieldOrMethod.getAnnotation(Property.class);       
        if (isField())
            propertyName=PropertyHelper.getPropertyName((Field)fieldOrMethod, properties) ;
        else
            propertyName=PropertyHelper.getPropertyName((Method)fieldOrMethod) ;
       
View Full Code Here

          throw new IllegalArgumentException("Cannot get property name: field is null") ;
        }
        if (props == null) {
          throw new IllegalArgumentException("Cannot get property name: properties map is null") ;
        }       
        Property annotation=field.getAnnotation(Property.class);
        if (annotation == null) {
          throw new IllegalArgumentException("Cannot get property name for field " +
              field.getName() + " which is not annotated with @Property") ;
        }
        String propertyName=field.getName();
        if(props.containsKey(annotation.name())) {
          propertyName=annotation.name();
          boolean isDeprecated=annotation.deprecatedMessage().length() > 0;
          if(isDeprecated && log.isWarnEnabled()) {
            log.warn(propertyName + " has been deprecated: " + annotation.deprecatedMessage());
          }
        }
        return propertyName ;
      }
View Full Code Here

     
      public static String getPropertyName(Method method) throws IllegalArgumentException {
        if (method == null) {
          throw new IllegalArgumentException("Cannot get property name: field is null") ;
        }
        Property annotation=method.getAnnotation(Property.class);
        if (annotation == null) {
          throw new IllegalArgumentException("Cannot get property name for method " +
              method.getName() + " which is not annotated with @Property") ;
        }       
        String propertyName=annotation.name().length() > 0? annotation.name() : method.getName();
        propertyName=Util.methodNameToAttributeName(propertyName);
        return propertyName ;
      }
View Full Code Here

        if (field == null)
          throw new IllegalArgumentException("Cannot get converted value: Field is null") ;
        if (props == null)
          throw new IllegalArgumentException("Cannot get converted value: Properties is null") ;

        Property annotation=field.getAnnotation(Property.class);
        if (annotation == null) {
          throw new IllegalArgumentException("Cannot get property name for field " +
              field.getName() + " which is not annotated with @Property") ;
        }
      String propertyName = getPropertyName(field, props) ;
      String name = obj instanceof Protocol? ((Protocol)obj).getName() : obj.getClass().getName();

        PropertyConverter propertyConverter=(PropertyConverter)annotation.converter().newInstance();
        if(propertyConverter == null) {           
          throw new Exception("Could not find property converter for field " + propertyName
              + " in " + name);
        }
        Object converted = null ;
View Full Code Here

            if(obj == null)
                throw new IllegalArgumentException("Cannot get converted value: Object is null");
            if(field == null)
                throw new IllegalArgumentException("Cannot get converted value: Field is null");

            Property annotation=field.getAnnotation(Property.class);
            if(annotation == null) {
                throw new IllegalArgumentException("Cannot get property name for field " +
                        field.getName() + " which is not annotated with @Property");
            }
            String propertyName=field.getName();
            String name=obj instanceof Protocol? ((Protocol)obj).getName() : obj.getClass().getName();

            PropertyConverter propertyConverter=(PropertyConverter)annotation.converter().newInstance();
            if(propertyConverter == null) {
                throw new Exception("Could not find property converter for field " + propertyName
                        + " in " + name);
            }
            Object converted=null;
View Full Code Here

          throw new IllegalArgumentException("Cannot get converted value: Method is not set property method") ;
        }
        if (props == null) {
          throw new IllegalArgumentException("Cannot get converted value: Properties is null") ;
        }
        Property annotation=method.getAnnotation(Property.class);
        if (annotation == null) {
          throw new IllegalArgumentException("Cannot get property name for method " +
              method.getName() + " which is not annotated with @Property") ;
        }
        String propertyName = getPropertyName(method) ;
        String name = obj instanceof Protocol? ((Protocol)obj).getName() : obj.getClass().getName();
        PropertyConverter propertyConverter=(PropertyConverter)annotation.converter().newInstance();
        if(propertyConverter == null) {           
          throw new Exception("Could not find property converter for method " + propertyName
              + " in " + name);
        }
        Object converted = null ;
View Full Code Here

     
        public static boolean usesDefaultConverter(Field field) throws IllegalArgumentException {
        if (field == null) {
          throw new IllegalArgumentException("Cannot check converter: field is null") ;
        }
        Property annotation=field.getAnnotation(Property.class);
        if (annotation == null) {
          throw new IllegalArgumentException("Cannot check converter for field " +
              field.getName() + " which is not annotated with @Property") ;
        }
          return annotation.converter().equals(PropertyConverters.Default.class) ;
        }
View Full Code Here

TOP

Related Classes of org.jgroups.annotations.Property

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.