Hi,

I'm trying to write a simple tracing annotation but have problems 
declaring it against a type due to compile errors. Basically I get the 
error depending on which combination of @Target annotation attributes I 
specify. For example TYPE and CONSTRUCTOR work together but not TYPE and 
METHOD as shown below. I would eventually like to apply the Tracing 
annotation to all ElementTypes.

1. The pojo I would like to declare the annotations against

public class MyPojo {
        public static void calculate() {
        }
}


2. The annotation I would like to apply is as follows:

@Retention(RetentionPolicy.RUNTIME)
@Target( { ElementType.TYPE, ElementType.METHOD})
public @interface Tracing {
        LoggingLevel level() default LoggingLevel.DEBUG;
}


3. The aspect that applies the annotation to MyPojo and MyPojo.calculate()

public aspect ConfigureTracing {
        declare @type : MyPojo : @Tracing(level = LoggingLevel.DEBUG); // 
compile error!!!
        declare @method : * MyPojo.calculate() : @TestAnnotation;
}


4. Here is the LoggingLevel enumeration I wrote, since I couldn't find one 
in log4j:

public enum LoggingLevel {
        ALL(Level.ALL), DEBUG(Level.DEBUG), ERROR(Level.ERROR), 
FATAL(Level.FATAL), INFO(
                        Level.INFO), OFF(Level.OFF), WARN(Level.WARN);
        private final Level level;
        private LoggingLevel(Level level) {
                this.level = level;
        }
        public Level getLevel() {
                return level;
        }
}

However when I compile it using aspectj tools 1.5.3 I get the following 
error message: "[ERROR] DEBUG cannot be resolved", which refers to my 
LoggingLevel.DEBUG enum constant. Could it be some sort of class loader 
issue where only some of my enumeration constants aren't yet available?

As a bonus question, I would like to specify something like the 
ConfigureTracing aspect above in an aop.xml file for runtime weaving, this 
way I don't have to hard code the annotations at build time. However in 
the docs for aop.xml I couldn't find any way to declare annotations, so is 
there some other strategy I can use to achive this?

Thanks for any help
- Ashley

---

This e-mail may contain confidential and/or privileged information. If you are 
not the intended recipient (or have received this e-mail in error) please 
notify the sender immediately and delete this e-mail. Any unauthorized copying, 
disclosure or distribution of the material in this e-mail is strictly forbidden.

Please refer to http://www.db.com/en/content/eu_disclosures.htm for additional 
EU corporate and regulatory disclosures.
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to