Solved! Thanks!

Wes Isberg wrote:
> 
> There is no "this" in a static context (main).  
> 
> Wes
> 
>> ------------Original Message------------
>> From: Giacomo82 <[EMAIL PROTECTED]>
>> To: [email protected]
>> Date: Tue, Oct-24-2006 2:13 AM
>> Subject: [aspectj-users] AspectJ and RMI problem
>>
>> 
>> Hi, I just started using AspectJ three weeks ago and now I came across 
>> a
>> little problem (I'm guessing it's really really easy but I just can't 
>> see
>> the error I'm making).
>> I'm starting to use AspectJ to do some logging of RMI applications. In
>> particular I created the classic Hello World example in RMI. But I 
>> quickly
>> came across a problem when creating my Aspect.
>> 
>> To understand the problem I'll post the RMI server and the aspect I 
>> wrote: 
>> 
>> here is the Server:
>> 
>> package server;
>> import java.rmi.Naming;
>> import java.rmi.RMISecurityManager;
>> import java.rmi.RemoteException;
>> import java.rmi.server.UnicastRemoteObject;
>> 
>> public class ServerEngine extends UnicastRemoteObject implements 
>> Compute {
>> 
>>      public ServerEngine() throws RemoteException {
>>              super();
>>      }
>> 
>>      public String executeTask_1() {
>>              return "Hello!";
>>      }
>>      
>>      public static void main(String[] args) {
>>              if (System.getSecurityManager() == null) {
>>                      System.setSecurityManager(new RMISecurityManager());
>>              }
>>              try {
>>                      ServerEngine engine = new ServerEngine();
>>                      Naming.rebind("Hello", engine);
>>              System.out.println("ServerEngine bound");
>>          } 
>>              catch (Exception e) {
>>                      System.err.println("ServerEngine exception: " + 
>> e.getMessage());
>>              e.printStackTrace();
>>          }
>>      }
>> 
>> }
>> 
>> And here is the aspect:
>> 
>> package myRMIAspect;
>> import java.rmi.registry.*;
>> import java.rmi.Naming;
>> 
>> public aspect MyRMIAspect {
>>      
>>      //Tracks the call to rebind
>>      pointcut rebindMethod ():
>>              call (* Naming.rebind(..));
>> 
>>      before(Object caller): rebindMethod() && this(caller) { 
>>              //Do some actions that I need fo my application
>>              }       
>> }
>> 
>> The problem is that I keep having the same warning for that aspect that
>> says: advice in [Name of .aj file] has not been applied[Hi, I just 
>> started
>> using AspectJ three weeks ago and now I came across a little problem 
>> (I'm
>> guessing it's really really easy but I just can't see the error I'm 
>> making).
>> I'm starting to use AspectJ to do some logging of RMI applications. In
>> particular I created the classic Hello World example in RMI. But I 
>> quickly
>> came across a problem when creating my Aspect.
>> To understand the problem I'll post the RMI server and the aspect I 
>> wrote: 
>> 
>> here is the Server:
>> 
>> package server;
>> import java.rmi.Naming;
>> import java.rmi.RMISecurityManager;
>> import java.rmi.RemoteException;
>> import java.rmi.server.UnicastRemoteObject;
>> 
>> public class ServerEngine extends UnicastRemoteObject implements 
>> Compute {
>> 
>>      public ServerEngine() throws RemoteException {
>>              super();
>>      }
>> 
>>      public String executeTask_1() {
>>              return "Hello!";
>>      }
>>      
>>      public static void main(String[] args) {
>>              if (System.getSecurityManager() == null) {
>>                      System.setSecurityManager(new RMISecurityManager());
>>              }
>>              try {
>>                      ServerEngine engine = new ServerEngine();
>>                      Naming.rebind("Hello", engine);
>>              System.out.println("ServerEngine bound");
>>          } 
>>              catch (Exception e) {
>>                      System.err.println("ServerEngine exception: " + 
>> e.getMessage());
>>              e.printStackTrace();
>>          }
>>      }
>> 
>> }
>> 
>> And here is the aspect:
>> 
>> package myRMIAspect;
>> import java.rmi.registry.*;
>> import java.rmi.Naming;
>> 
>> public aspect MyRMIAspect {
>>      
>>      //Tracks the call to rebind
>>      pointcut rebindMethod ():
>>              call (* Naming.rebind(..));
>> 
>>      before(Object caller): rebindMethod() && this(caller) { 
>>              //Do some actions that I need fo my application
>>              }       
>> }
>> 
>> The problem is that I keep having the same warning for that 
>> before(Object
>> caller)....etc aspect that says: advice in [Name of .aj file] has not 
>> been
>> applied[Xlint:adviceDidNotMatch]
>> Obviously the problem is with the use of the this() pointcut 
>> designator,
>> because if I don't use it, there are no warnings. But I really need it 
>> since
>> I have to know the caller of the rmi method "rebind()" for the work I'm
>> doing.
>> I really don't know what the problem is, since used almost the same 
>> advice
>> many times in another application that wasn't using RMI (a 
>> client-server
>> application using only sockets)
>> 
>> Can somebody please help me?? 
>> Thanks!
>> Giacomo
>> -- 
>> View this message in context: 
>> http://www.nabble.com/AspectJ-and-RMI-problem-tf2497194.html#a6961010
>> Sent from the AspectJ - users mailing list archive at Nabble.com.
>> 
>> _______________________________________________
>> aspectj-users mailing list
>> [email protected]
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>> 
> 
> _______________________________________________
> aspectj-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
> 
> 

-- 
View this message in context: 
http://www.nabble.com/AspectJ-and-RMI-problem-tf2497194.html#a6973347
Sent from the AspectJ - users mailing list archive at Nabble.com.

_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to