Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Pointcut around constructor

For your example, you actually want the around advice to return
something -- your Calc instance.  The reason around advice requires a
return type is that you can place around advice around any method
without the client necessarily knowing that around advice is being
executed.  If the client expects a return value, then give them one,
either via capturing the return value from proceed(), the advice's own
return value.  If it makes sense to return go ahead, and if the
advised method returns void, just return null from your around advice.

HTH,
Matthew

On Wed, Jun 30, 2010 at 2:23 AM, Pawel Branc <pbranc@xxxxxxxxx> wrote:
> Hello,
> I learn aspectJ, being at the beginning.
>
> I have 2 classes. I want to send second class to another computer and
> take its object remotely.
>
> //class which will be used locally
> public class CalcExecutor
> {
>        public static void main(String[] args)
>        {
>                long num1 = Integer.parseInt(args[0]);
>                long num2 = Integer.parseInt(args[1]);
>                Calc c = new Calc();
>                System.out.println( "We add: "+num1 +" and: "+ num2 +"and obtain:
> "+c.add(num1, num2) );
>        }
> }
>
> //class which I want to send and use its object remotely
> public class Calc
> {
>        public Calc() {}
>
>        public long add(long a, long b)
>        {
>                return a + b;
>        }
> }
>
> I would like to shadow with around() advice:
> THIS
>   Calc c = new Calc();
> WITH THIS
>   Calc c = (Calc)Naming.lookup("rmi://localhost:1099/CalculatorService");
>
> I have problem with around() because it must return something. But why?
> Could You help me. Thanks a lot.
> Pawel
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>



-- 
mailto:matthew@xxxxxxxxxxxxxxx
skype:matthewadams12
yahoo:matthewadams
aol:matthewadams12
google-talk:matthewadams12@xxxxxxxxx
msn:matthew@xxxxxxxxxxxxxxx
http://matthewadams.me
http://www.linkedin.com/in/matthewadams


Back to the top