Java Login

About javalogin.com

Hello guys,
javalogin.com is for Java and J2EE developers, all examples are simple and easy to understand 

It is developed and maintained by Vaibhav Sharma. The views expressed on this website are his own and do not necessarily reflect the views of his former, current or future employers. I am professional Web development. I work for an IT company as Senior Consultant. Primary I write about spring, hibernate and web-services. I am trying to present here new technologies.


     << Previous
Next >>     


Wildcard

There are two types of wildcards you can use within pointcut expressions

  • * Is a regular wildcard that matches zero or more characters. It can be used within any type expression, field, or method name, but not in an annotation expression
  • .. Is used to specify any number of parameters in an constructor or method expression. .. following a package-name is used to specify all classes from within a given package ut not within sub-packages. e.g org.vtechn.. matches org.vtechnology.model and org.acme.Bar

Wildcard Expressions Examples

Some examples of common pointcut expressions are given below.

  • the execution of any public method:
    execution(public * *(..))
  • the execution of any method with a name beginning with "set":
    execution(* set*(..))
  • the execution of any method defined by the AccountService interface:
    execution(* com.xyz.service.AccountService.*(..))
  • the execution of any method defined in the service package:
    execution(* com.xyz.service..(..))
  • the execution of any method defined in the service package or a sub-package:
    execution(* com.xyz.service...(..))
  • any join point (method execution only in Spring AOP) within the service package:
    within(com.xyz.service.*)
  • any join point (method execution only in Spring AOP) within the service package or a sub-package:
    within(com.xyz.service..*)
  • any join point (method execution only in Spring AOP) where the proxy implements the AccountService interface:
    this(com.xyz.service.AccountService)
    this is more commonly used in a binding form :- see the following section on advice for how to make the proxy object available in the advice body.
  • any join point (method execution only in Spring AOP) where the target object implements the AccountService interface:
    target(com.xyz.service.AccountService)
    target is more commonly used in a binding form :- see the following section on advice for how to make the target object available in the advice body.
  • any join point (method execution only in Spring AOP) which takes a single parameter, and where the argument passed at runtime is Serializable:
    args(java.io.Serializable)
    args is more commonly used in a binding form :- see the following section on advice for how to make the method arguments available in the advice body.
    Note that the pointcut given in this example is different to execution(* *(java.io.Serializable)): the args version matches if the argument passed at runtime is Serializable, the execution version matches if the method signature declares a single parameter of type Serializable.
  • any join point (method execution only in Spring AOP) where the target object has an @Transactional annotation:
    @target(org.springframework.transaction.annotation.Transactional)
    @target can also be used in a binding form :- see the following section on advice for how to make the annotation object available in the advice body.
  • any join point (method execution only in Spring AOP) where the declared type of the target object has an @Transactional annotation:
    @within(org.springframework.transaction.annotation.Transactional)
    @within can also be used in a binding form :- see the following section on advice for how to make the annotation object available in the advice body.
  • any join point (method execution only in Spring AOP) where the executing method has an @Transactional annotation:
    @annotation(org.springframework.transaction.annotation.Transactional)
    @annotation can also be used in a binding form :- see the following section on advice for how to make the annotation object available in the advice body.
  • any join point (method execution only in Spring AOP) which takes a single parameter, and where the runtime type of the argument passed has the @Classified annotation:
    @args(com.xyz.security.Classified)
    @args can also be used in a binding form :- see the following section on advice for how to make the annotation object(s) available in the advice body.
  • any join point (method execution only in Spring AOP) on a Spring bean named tradeService:
    bean(tradeService)
  • any join point (method execution only in Spring AOP) on Spring beans having names that match the wildcard expression *Service:
    bean(*Service)

     << Previous
Next >>