[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] A little help with perthis/pertarget ...

Ok tried it again:

package com.xxx.aspect;

import org.slf4j.*;
import javax.ejb.*;
import com.xxx.ejb.stateless.*;
import java.util.*;

/**
* Profiles
*/
aspect ProfileAspect perthis(execution(* *Service.* (..))) {

    private long start;

        private static final Logger LOG = LoggerFactory
        .getLogger("com.ing.uds.aspect.ProfileAspect");

                pointcut services(): (execution(* *Service.* (..)));

    before(): services() {
     start =System.currentTimeMillis();
    }

    after(): services() {
        LOG.debug("{}|{}", thisJoinPoint, Long.toString(System.currentTimeMillis()-start));
        }

}

The advise is no longer executing.

On Thu, Jul 10, 2008 at 11:20 AM, Eric Bodden <eric.bodden@xxxxxxxxxxxxxx> wrote:
aspect ProfileAspect perthis(execution(* *Service.* (..))) {...

does not work for you?

Eric

2008/7/10 Dan Bush <dan.bush@xxxxxxxxx>:
> Can anyone help me refactor this aspect so that it's not a singleton? I have
> attempted to use both perthis and pertarget but when I do, the advice no
> longer kicks in. The aspect is actually picking out all the methods on my
> EJB tier so there are multiple threads in flight here. I want an instance of
> the aspect per each thread. I was and want to simply have a "private long
> start;" instead of a "private Hashtable ht = new Hashtable();" but, I had to
> introduce the Hashtable so my singleton aspect would work properly. Here is
> my aspect as it currently exists. Again it works as expected but, I want to
> utilize perthis or pertarget as opposed to incurring the overhead with the
> Hashmap approach.
>
>
> package com.xxx.aspect;
>
> import org.slf4j.*;
> import javax.ejb.*;
> import com.xxx.ejb.stateless.*;
> import java.util.*;
>
> /**
> * Profiles
> */
> aspect ProfileAspect {
>
>     private Hashtable ht = new Hashtable();
>
>     private static final Logger LOG = LoggerFactory
>     .getLogger("com.ing.uds.
> aspect.ProfileAspect");
>
>         pointcut services(): (execution(* *Service.* (..)));
>
>     before(): services() {
>         ht.put(thisJoinPoint.getThis(), new
> Long(System.currentTimeMillis()));
>     }
>
>     after(): services() {
>         LOG.debug("{}|{}", thisJoinPoint,
> Long.toString(System.currentTimeMillis()-((Long)ht.get(thisJoinPoint.getThis())).longValue()));
>       }
>
> }
> _______________________________________________
> aspectj-dev mailing list
> aspectj-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-dev
>
>



--
Eric Bodden
Sable Research Group
McGill University, Montréal, Canada
_______________________________________________
aspectj-dev mailing list
aspectj-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-dev