From: "Rob Withers" <reefed...@gmail.com>
Date: Thu, 11 Oct 2012 10:42:25 -0400
Local: Thurs, Oct 11 2012 10:42 am
Subject: RE: Aspect logging in Guice?
I did find the Annotations solution.
What would my own Matcher look like, perhaps using reflection and AspectJ
Thanks,
Rob
From: google-guice@googlegroups.com [mailto:google-guice@googlegroups.com]
You can write your own matche and use it instead of passing Matchers.any().
On 10/10/2012 05:37 AM, Rob Withers wrote:
The first one you point to is a “Built-in Binding”. However, I do not see
The second link on Custom Injections scans for a Logger in each class, so
Here is the class I came up with, below. My problem is that I don’t see how
public class WhisperModule extends AbstractMurmurModule {
@Override
protected void configure() {
…
bindInterceptor(Matchers.subclassesOf(WhisperTerminal.class),
}
}
public class LoggingInterceptor implements MethodInterceptor {
private Logger logger;
public LoggingInterceptor() {
PropertyConfigurator.configure("log4j.properties");
logger = Logger.getLogger(LoggingInterceptor.class);
}
public Object invoke(MethodInvocation methodInvocation) throws Throwable
String header = methodInvocation.getThis().getClass()
+ ":" + methodInvocation.getMethod().getName();
logger.info(header + " invocation");
Object result = null;
try {
result = methodInvocation.proceed();
logger.info(header + " return: " + result);
return result;
} catch (Exception ex) {
logger.error(header, ex);
throw ex;
}
}
}
Thanks,
Rob
From: google-guice@googlegroups.com [mailto:google-guice@googlegroups.com]
Something like that
Or you could inject your own loggers with type listeners
-- Cédric
facility in core guice or an extension I could use? Thanks,
-- -- -- -- You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||