[jboss-dev-forums] [Design of POJO Server] - Replacing system properties in metadata

adrian@jboss.org do-not-reply at jboss.com
Wed Jun 4 13:03:02 EDT 2008


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()

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4155761#4155761

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4155761



More information about the jboss-dev-forums mailing list