473,320 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

AspectJ: Can I get access to the variables inside a method surround with around joinp

nathj
938 Expert 512MB
Ok, let me expand a bit, hopefully that will make te question clearer.

I am learning AspectJ by refactoring some existing code. The curret plan is to handle logging via Aspects and then move on to timers. At present I am still working on the logging side of things.

So far this has been fairly simple and I have the following code:
Expand|Select|Wrap|Line Numbers
  1. public aspect MyLogger extends BaseAspect {
  2.     declare precedence : *, MyLogger ;
  3.     declare warning : (get(* System.out)||get(* System.err)) && withinScope() : "Don't use System.out.";
  4.  
  5.     MyLogger() {
  6.  
  7.     }
  8.  
  9.     pointcut sercoManagerLogging(): target(org.esf.adapters.serco.SercoManager) && withinScope();
  10.  
  11.     pointcut translatorLogging(): target(org.esf.adapters.serco.SercoBBTranslator) && withinScope();
  12.  
  13.     pointcut translateLogging(): execution(public void translate*(..)) && translatorLogging();
  14.  
  15.     pointcut addRoleLogging(): execution(public String addInst*(..)) && translatorLogging();
  16.  
  17.     pointcut callRoleLogging(): execution(public void *AddInst*(..)) && translatorLogging();
  18.  
  19.     before(): sercoManagerLogging() {
  20.         pkgLogger.info("SercoLOGGING before method="
  21.                 + thisJoinPointStaticPart.getSignature());
  22.     }
  23.  
  24.     before(): translateLogging(){
  25.         pkgLogger.info("TranslateLOGGING before method="
  26.                 + thisJoinPointStaticPart.getSignature());
  27.     }
  28.  
  29.     after(): translateLogging(){
  30.         pkgLogger.info("TranslateLOGGING after method="
  31.                 + thisJoinPointStaticPart.getSignature());
  32.     }
  33.  
  34.     String around(): addRoleLogging(){
  35.         String information = proceed();
  36.         pkgLogger.info("addRoleLOGGING around method="
  37.                 + thisJoinPointStaticPart.getSignature() + " " + information);
  38.         return information;
  39.     }
  40.  
  41.     before(): callRoleLogging(){
  42.         pkgLogger.info("callRoleLogging before method="
  43.                 + thisJoinPointStaticPart.getSignature());
  44.     }
  45. }
  46.  
In the String around():aroundRoleLogging() I am using a return value to log the information from the method. This return isn't really necessary for the business logic of the process - I've added it to get the logging I want.

Within the actual method I have a number of variables that handle process counts. Is it possible to access these values from within the aspect code so that I don't have to have the otherwose unnecessary return?

Hopefully the question is a bit clearer now. I have tried reading up on this and found no way ofachieving what I want, then again I have also struggled to put this into a suitable search string for Google.

Any help here is greatly appreciated.

Cheers
nathj
Mar 5 '10 #1
0 1871

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Andrew Phillipo | last post by:
This message doesn't seem to have filtered through - so I'm going to post again. I am trying to write an aspectj aspect that does the following. For all setters, before() it should check the...
8
by: Corey Lubin | last post by:
someGlobal=1 class Original: def foo(self): # Make use of someGlobal from original import * someGlobal=2
20
by: Olav.NET | last post by:
I am a .NET/C++ developer who is supposed to do some work with Access. I do not know much about it except for the DB part. Questions: *1* I am looking for INTENSIVE books to get quickly up to...
6
by: Kobu | last post by:
Do the "larger" input functions like scanf, gets, fgets use fgetc to take input or an operating system call function like read() (I know it could be any "way", but I'm trying to find out how it's...
4
by: Dean | last post by:
I finally got class session variables to work by putting the following in global.asax in the session_start: dim myDBComp as DBComp = new DBComp........ session("myDBComp") = myDBComp In each...
37
by: Joergen Bech | last post by:
(Slightly religious question): Suppose I have the following class: ---snip--- Public Class MyClass Private _MyVariable As Integer Public Property MyVariable() As Integer Get
2
by: Nigel Molesworth | last post by:
I'm doing a Java course. Having gone through the use of accessor (setter and getter) methods for instance variables, it goes on to say: "For reasons that cannot be elaborated upon here, it is...
2
by: Michael Bialowas | last post by:
Hello all, I have been searching the net endlessly and found this ng, so I thought I would give a try. Anyways, I have a few problems I am trying to implement a combo box which presently contains...
9
by: JT | last post by:
Here is the overall structure I will be referring to: End-program ProvideWorkFlow.dll Forms and methods that properly manipulate calls to methods in AccessUtils AccessUtils (a web service)...
7
by: farhaaad | last post by:
Hi everybody, I just wanted to know if i can make a form in excel (the same as access forms), so when i enter data in excel form it goes to a table in access ? I mean when i enter a value in a...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.