[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[List Home]
|
Re: [aspectj-users] Inter-Type Declaration Help Needed
|
- From: "Bhaskar Maddala" <maddalab@xxxxxxxxx>
- Date: Wed, 12 Dec 2007 12:07:29 -0500
- Delivered-to: aspectj-users@eclipse.org
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=n/FRbLJnaXL5t/vDgI7y9NcuaHBrtkhvpW7qY9Xnraw=; b=W3+bDQy9Ld5abBcisvU4IZlHtgzrioYOitbLt8hjY1Ij4oECyD4xGMU0SCBm/q0+FUPI0O43zqmXHi0Wf0Q1fUIqegpLZZ5Ibyp7AsiLPSQiE/psHVj8scusMVNmhZhuUfm1gU5sh62H3rjanJof/Se9NxrBVraQdxYCI7m48O8=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=HIz/vzssZy8OJ1H2huD6gDqRf+bHF6TtOj0FW/4C3hx9BrphYN18SpegaEMVRWXSmZstA7RLuNg6ochiBmztSJQY0GiOr2cFbv3x6y5ud3qIpeK1I+TD8cMVIpZ4E4flo1NIcG3pov2EkbooWmRqDUIqLH3hFGbaqhzU5QqCxnA=
My attempt at trying to implement what I understand from your
question, note though I am a newbie
public interface Foo {
public void doFoo();
}
public interface Bar {
public void doBar();
}
public class FooImpl implements Foo {
public void doFoo() {
System.out.println("you got fooed");
}
}
public class BarImpl implements Bar {
public void doBar() {
System.out.println("you got barred");
}
}
import foo.Foo;
import bar.Bar;
import bar.BarImpl;
public aspect FooBar {
declare parents : Foo extends Bar;
public void Foo.doBar() {
Bar bar = new BarImpl();
bar.doBar();
}
}
import bar.Bar;
import foo.Foo;
import foo.FooImpl;
public class Main {
public static void main(String[] args) {
Foo foo = new FooImpl();
foo.doFoo();
((Bar)foo).doBar();
}
}
Result of running Main
you got fooed
you got barred
Hope that helps
Bhaskar
On Dec 12, 2007 11:40 AM, Kevin Shale <Shale@xxxxxx> wrote:
> Hi, I am a relative newbie to AspectJ and I have a problem to solve.
>
> In Java I have two interfaces A and B which are not related to each other via extends.
>
> Each interface has a number of concrete implementation classes.
>
> I am looking for a way to use AspectJ to force every class which implements interface B to also implement interface A with methods defined in the aspect.
>
> How would I go about programming this?
>
> Best Regards
> Kevin
> _______________________________________________________________________
> Jetzt neu! Schützen Sie Ihren PC mit McAfee und WEB.DE. 3 Monate
> kostenlos testen. http://www.pc-sicherheit.web.de/startseite/?mc=022220
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>