473,406 Members | 2,371 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,406 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 1886

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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.