[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] template implementation for interface

Hi Rice -

Perhaps what Nick was saying is that this pattern needs no
new keyword "template" (nor an abstract aspect).

I typically use a tag interface, e.g., 

  interface IRunnable extends Runnable {}
  aspect A {
    public void IRunnable.run(){}
  }

then after

  declare parents C implements IRunnable;

or 

  class C implements IRunnable { .. }

you can say

  new Thread(new C());

So your observation of the pattern is a good one, but the 
implementation need not be as heavyweight as you suggest
(if I'm reading you correctly).

Wes

> ------------Original Message------------
> From: Rice Yeh <riceyeh@xxxxxxxxx>
> To: aspectj-dev@xxxxxxxxxxx
> Date: Wed, Mar-2-2005 5:21 PM
> Subject: Re: [aspectj-dev] template implementation for interface
>
> Hi,
>   No, the result is not the same. To directly using
> inter-type member declaration on the interface will
> cause the interface I changed, hence method setX(int
> x) is introduced into I which is a good result for the
> purpose of being a interface.
> 
> 
> Regards,
> Rice
> 
> 
> --- Nicholas Lesiecki <ndlesiecki@xxxxxxxxx> wrote:
> 
> > I think ITDs like
> > 
> > 		private int I.x;
> > 
> > would get the same result...
> > 
> > Nicholas Lesiecki
> > Software Craftsman, specializing in J2EE,
> > Agile Methods, and aspect-oriented programming
> > m: 520 591-1849
> > 
> > Books:
> > * Mastering AspectJ: http://tinyurl.com/66vf
> > * Java Tools for Extreme Programming:
> > http://tinyurl.com/66vt
> > 
> > Articles on AspectJ:
> > * http://tinyurl.com/66vu and
> > http://tinyurl.com/66vv
> > On Mar 2, 2005, at 9:46 AM, Rice Yeh wrote:
> > 
> > > Hi,
> > >   The final result should be
> > >
> > > public class C implements I {
> > > 	
> > > 	private int x;
> > > 	
> > > 	public int getX() {
> > > 		return this.x;
> > > 	}
> > > 	
> > > 	public void setX(int x) {
> > > 		this.x = x;
> > > 	}
> > > }
> > >
> > > Regards,
> > > Rice
> > >
> > > --- Rice Yeh <riceyeh@xxxxxxxxx> wrote:
> > >
> > >> Hi,
> > >>   When using aspectj as an extension to my
> > project,
> > >> I
> > >> have the following new idea to extend
> > >> the lanuage itself. I do not know whether anyone
> > >> else
> > >> has raised such idea before. In this
> > >> idea, I coin out a new keyword 'template', which
> > is
> > >> used as a template implementation for
> > >> some interface I. See the following example for
> > my
> > >> idea:
> > >>
> > >> Step 1:
> > >> aspect IntroduceI2T introduces the interface I to
> > >> the
> > >> template T.
> > >>
> > >> 	public interface I {
> > >> 	
> > >> 		public int getX();
> > >> 	}
> > >> 	
> > >> 	public tempalte T {
> > >> 	
> > >> 	}
> > >> 	
> > >> 	public abstract aspect IntroduceI2T {
> > >> 	
> > >> 		declare parents: T implements I;
> > >> 		
> > >> 		private int T.x;
> > >> 		
> > >> 		public int T.getX() {
> > >> 			return this.x;
> > >> 		}
> > >> 		
> > >> 		public void T.setX(int x) {
> > >> 			this.x = x;
> > >> 		}
> > >> 		
> > >> 	}
> > >>
> > >> Step 2:
> > >> Then the aspect IntroduceI2C extends
> > IntroduceI2T.
> > >> The
> > >> aspect IntroduceI2C declares another class
> > >> C extends T.
> > >>
> > >> public aspect IntroduceI2C extends IntroduceI2T {
> > >>
> > >> 	declare parents: C extends T;
> > >> }
> > >>
> > >> public class C {
> > >>
> > >> }
> > >>
> > >> Step 3:
> > >> Afer compling, the class C becomes
> > >>
> > >> public class C {
> > >> 	
> > >> 	private int x;
> > >> 	
> > >> 	public int getX() {
> > >> 		return this.x;
> > >> 	}
> > >> 	
> > >> 	public void setX(int x) {
> > >> 		this.x = x;
> > >> 	}
> > >> }
> > >>
> > >> And the interface I is not changed.
> > >>
> > >> Just an idea for discussion.
> > >>
> > >> Regards,
> > >> Rice
> > >>
> > >>
> > >>
> > >>
> > >> 	
> > >> 		
> > >> __________________________________
> > >> Celebrate Yahoo!'s 10th Birthday!
> > >> Yahoo! Netrospective: 100 Moments of the Web
> > >> http://birthday.yahoo.com/netrospective/
> > >> _______________________________________________
> > >> aspectj-dev mailing list
> > >> aspectj-dev@xxxxxxxxxxx
> > >>
> > http://dev.eclipse.org/mailman/listinfo/aspectj-dev
> > >>
> > >
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Tired of spam?  Yahoo! Mail has the best spam
> > protection around
> > > http://mail.yahoo.com
> > > _______________________________________________
> > > aspectj-dev mailing list
> > > aspectj-dev@xxxxxxxxxxx
> > >
> > http://dev.eclipse.org/mailman/listinfo/aspectj-dev
> > >
> > 
> > _______________________________________________
> > aspectj-dev mailing list
> > aspectj-dev@xxxxxxxxxxx
> > http://dev.eclipse.org/mailman/listinfo/aspectj-dev
> > 
> 
> 
> 
> 	
> 		
> __________________________________ 
> Celebrate Yahoo!'s 10th Birthday! 
> Yahoo! Netrospective: 100 Moments of the Web 
> http://birthday.yahoo.com/netrospective/
> _______________________________________________
> aspectj-dev mailing list
> aspectj-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-dev
>