Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Aspect logging in Guice?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Rob Withers  
View profile  
 More options Oct 11 2012, 10:42 am
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
expressions to specify methods?  Is there such a duck out there?

Thanks,

Rob

From: google-guice@googlegroups.com [mailto:google-guice@googlegroups.com]
On Behalf Of Stephan Classen
Sent: Thursday, October 11, 2012 2:46 AM
To: google-guice@googlegroups.com
Subject: Re: Aspect logging in Guice?

You can write your own matche and use it instead of passing Matchers.any().
Or if it is ok for you to annotate the methods which you want to intercept
you can use the existing Matchers.annotatedWith(...)

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
this in the guice-3.0.jar.  Also, how do I use it?

The second link on Custom Injections scans for a Logger in each class, so
this does not seem to be using AOP.

Here is the class I came up with, below.  My problem is that I don’t see how
to install the pointcut to intercept a specific method in a class.  I can
bind it to all methods, but not one method.  How can I do that?

public class WhisperModule extends AbstractMurmurModule {

       @Override

       protected void configure() {

              …

bindInterceptor(Matchers.subclassesOf(WhisperTerminal.class),
Matchers.any(), new LoggingInterceptor());

       }

}

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]
On Behalf Of Cédric Beust ?
Sent: Tuesday, October 09, 2012 10:56 PM
To: google-guice@googlegroups.com
Subject: Re: Aspect logging in Guice?

Something like that
<http://code.google.com/p/google-guice/wiki/BuiltInBindings> ?

Or you could inject your own loggers with type listeners
<http://code.google.com/p/google-guice/wiki/CustomInjections> .

--

Cédric

On Tue, Oct 9, 2012 at 5:31 PM, Rob Withers <reefed...@gmail.com> wrote:

Before I run off and implement a LoggingInterceptor, is there an AOP logging
facility in core guice or an extension I could use?

Thanks,
Rob

--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-guice/-/rphjmZue5wQJ.
To post to this group, send email to google-guice@googlegroups.com.
To unsubscribe from this group, send email to
google-guice+unsubscribe@googlegroups.com
<mailto:google-guice%2Bunsubscribe@googlegroups.com> .
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.

--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to google-guice@googlegroups.com.
To unsubscribe from this group, send email to
google-guice+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.

--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to google-guice@googlegroups.com.
To unsubscribe from this group, send email to
google-guice+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.

--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to google-guice@googlegroups.com.
To unsubscribe from this group, send email to
google-guice+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.


 
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.