8 Replies Latest reply on Jun 6, 2008 9:41 AM by Scott Stark

    Replacing system properties in metadata

    Adrian Brock Master

      Brian asked on another thread about automatically replacing system properties on
      annotations.

      First, I suppose if we were going to do this, it would need a meta annotation
      to trigger the behaviour otherwise it would be doing a lot of work unnecessarily.

      e.g.

      @org.jboss.metadata.spi.Replaceable
      public @interface Clustered
      {
       String partition() default = "${jboss.parition.name:DefaultDomain";
      }
      


      Then we could add something to MetaDataRetrievalToMetaDataBridge
      that does the replacement, e.g.

      
       public <T extends Annotation> T getAnnotation(Class<T> annotationType)
       {
       if (annotationType == null)
       throw new IllegalArgumentException("Null annotationType");
       AnnotationItem<T> item = retrieval.retrieveAnnotation(annotationType);
       if (item == null)
       return null;
      - return item.getValue();
      + T result = item.getValue();
      + if (annotationType.hasAnnotation(Replaceable.class))
      + result = checkReplaceable(result);
      + return result;
       }
      


      Where checkReplaceable() either
      1) creates a new annotation from the original one with system properties replaced.
      2) wraps the annotation in a dynamic proxy that implements the annotation interface
      and does the replacement lazily

      Similar code would be required for getAnnotations()