Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] error Ambiguous binding - args(..) pointcut

Note that your pointcuts for JDBC calls won't match in cases where there's more than one argument, which may be ok for your program, but it would probably be better to use args(sql, ..) to match JDBC calls that take a query string as their first parameter.

Here's a work around you could use to get your program to compile until AspectJ supports this kind of binding:

public pointcut query(String sql) : 
   (JDBC.preparedStatement(*) || JDBC.preparedCall(*) ||
   JDBC.statement(*) || JDBC.addBatch(*) || JDBC.setCommand(*)) &&
   args(sql, ..); // or just args(sql); if that's what you really want

Another approach would be to not have the various JDBC pointcuts bind the sql parameter and just do it in the query pointcut, e.g., define

public pointcut preparedStatement() : 
  call(public * Connection.prepareStatement(..));



Ron Bodkin
Chief Technology Officer
New Aspects of Software
o: (415) 824-4690
m: (415) 509-2895


> ------------Original Message------------
> From: "JITESH KALYANI Shivanand" <SJitesh@xxxxxxxxxxxx>
> To: aspectj-users@xxxxxxxxxxx
> Date: Fri, Nov-12-2004 3:26 AM
> Subject: [aspectj-users] error Ambiguous binding - args(..) pointcut
>
> HI there,
>  
> ERROR:
> see also: D:\JDBC.java:17
>  see also: 
> D:\bea813\weblogic81\samples\server\examples\src\examples\ejb20\basic\beanManaged\dist\ejb20_basic_beanManaged.jar
> examples\ejb20\basic\beanManaged\AccountBean.java:127 error Ambiguous 
> binding of type java.lang.String using args(..) at this line.  Use one 
> args(..) per matched join point, see secondary source location for 
> location of extraneous args(..)
> (no source information available)
>  
> When I weave the following code with weblogic 8.1.3 beanmanaged example 
> Account entity EJB, I am getting follwoing above error,
> Please let me know what is the problem?
>  
> Regards,
> Jitesh
>  
> public aspect JDBC {
>   public pointcut getConnection() : call(public Connection 
> Driver.connect(..)) || call(public Connection DataSource.getConnection(..));
>   public pointcut closeConnection() : call(public void 
> Connection.close());
>   public pointcut commit() : call(public void Connection.commit());
>  
> //--------------------------------------------------------------------------------------------------
>  //clubbed all this in query pointcut
>  
>   public pointcut preparedStatement(String sql) : call(public * 
> Connection.prepareStatement(..)) && args(sql);
>   public pointcut preparedCall(String sql) : call(public * 
> Connection.prepareCall(..)) && args(sql);
>  
>   public pointcut statement(String sql) : call(public * 
> Statement.execute*(..)) && args(sql);
>   public pointcut addBatch(String sql) : call(public * 
> Statement.addBatch(String)) && args(sql);
>   public pointcut setCommand(String sql) : call(public * 
> RowSet.setCommand(..)) && args(sql);
>  
> //--------------------------------------------------------------------------------------------------
>  
>   public pointcut query(String sql) : JDBC.preparedStatement(sql) || 
> JDBC.preparedCall(sql) ||
>     JDBC.statement(sql) || JDBC.addBatch(sql) || JDBC.setCommand(sql);
>  
> Object around(String sql): query(sql) {
>      System.out.println("Query"+sql);   
>     //execute called method
>     res = proceed(sql);
>     return res;
> }
> Confidentiality Statement:
> 
> This message is intended only for the individual or entity to which it 
> is addressed. It may contain privileged, confidential information which 
> is exempt from disclosure under applicable laws. If you are not the 
> intended recipient, please note that you are strictly prohibited from 
> disseminating or distributing this information (other than to the intended 
> recipient) or copying this information. If you have received this 
> communication in error, please notify us immediately by return email.
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
> 
> 



Back to the top