org.glassfish.gmbal.logex
Class WrapperGenerator
java.lang.Object
org.glassfish.gmbal.logex.WrapperGenerator
public class WrapperGenerator
- extends Object
Given an annotated interface, return a Proxy that implements that interface.
Interface must be annotated with @ExceptionWrapper( String idPrefix, String loggerName ).
id prefix defaults to empty, loggerName defaults to the package name of the annotated
class.
The behavior of the implementation of each method on the interface is determined
in part by its return type as follows:
- void. Such a method can only log a message.
- String. Such a method may log a message, and also returns the message.
- A subclass of Exception. Such a method may log a message, and also returns
an exception containing the message.
Each method may be annotated as follows:
- @Message( String value ). This defines the message to be placed in a resource
bundle (generated at build time by a separate tool). The key to the resource
bundle is .. The message is prepended with the
idPrefix and the id from the @Log annotation (if @Log is present, otherwise nothing
is prepended to the message). If this annotation is not present, a default message
is created from the method name and the arguments.
- @Log( LogLevel level, int id ). The presence of this annotation indicates that
a log record must be generated, and logger IF the appropriate logger is enabled at
the given level (note that LogLevel is an enum used for the annotation, each member
of which returns the java.util.logging.Level from a getLevel() method).
In addition, the @Chain annotation may be used on a method parameter (whose type
must be a subclass of Throwable) of a method that returns an exception
to indicate that the parameter should be the cause of the returned exception.
All other method parameters are used as arguments in formatting the message.
- Author:
- ken
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
makeWrapper
public static <T> T makeWrapper(Class<T> cls)
Copyright © 2005-2015 Oracle Corporation. All Rights Reserved.