how to do static crosscutting (adding of member-variables) across multiple classes? [message #35854] |
Wed, 19 May 2004 05:28  |
Eclipse User |
|
|
|
Hi all,
first: sorry for the cross-posting, but since nobody responded in the
AspectJ-NG (which doesn't seem too lively, anyway) I thought I try my
luck here.
I am trying to get rid of some clutter in our code that only hinders
readability and is never correctly updated anyway, which should sound
familiar to many of you:
For legal reasons we need to have a line
--------------------
public final static String COPYRIGHT = "bla bla...";
--------------------
in each class. The idea is, that this string constant makes it into
the final class-file and thus - when the file is displayed/dumped -
the origin of the file becomes visible.
This - I thought - should be a perfect case for an aspect: define a
pointcut that matches ALL classes within and below a certain package
and add said variable to each matching class as a static variable.
But how do I specify such a pointcut? It's clearly a static, not a
dynamic pointcut, but which pointcut type matches a class? And how do
I reference that class in the advice???
I tried e.g. this:
public aspect AddCopyRightString {
public pointcut allActClasses(Class x):
staticinitialization(com.mycompany..*) && this(x);
/**
* add a static copyright String member to each class:
*/
public final static String x.COPYRIGHT = "bla bla...";
}
.... but this only yields an error saying "x can not be resolved". How
do I get a reference to the matching class?
Another approach I tried:
public aspect AddCopyRightString {
/**
* add a static copyright String member to each class:
*/
public final static String com.mycompany..*.COPYRIGHT = "bla
bla...";
}
yielded: "Syntax error on tokens, JavaIdentifier expected instead".
Any help in better understanding how to apply AspectJ to such cases
would be highly appreciated!
Michael
|
|
|
Re: how to do static crosscutting (adding of member-variables) across multiple classes? [message #35889 is a reply to message #35854] |
Wed, 19 May 2004 09:26   |
Eclipse User |
|
|
|
This is a multi-part message in MIME format.
------=_NextPart_000_0025_01C43DB5.AC935C50
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
The following variant works during runtime, i.e. can request the =
copyright-string's value from each and every class, but - alas, in this =
case - the string's value is not actually copied into each classfile and =
thus this does not fulfil my requirement. :-(
------------------
public aspect AddCopyRightString=20
{
public interface HasCopyRightString {
// add a static copyright String member to each class:=20
public final static String COPYRIGHT =3D "bla bla...";
}
declare parents: (com.mycompany..* && // all classes in and under =
com.tivoli.act
!com.mycompany.AddCopyRightString) // except this =
aspect (to prevent recursion)...
implements HasCopyRightString; // ...will =
implement the above interface
}
------------------
I also experimented with static aspects, i.e.:
------------------
public aspect AddCopyRightString=20
{
public interface HasCopyRightString {
static aspect Impl {
// add a static copyright String member to each class:=20
public final static String COPYRIGHT =3D "bla bla...";
// ^^^^^^ not allowed...
}
}
declare parents: (com.mycompany..* && // all classes in and under =
com.tivoli.act
!com.mycompany.AddCopyRightString) && // except =
this aspect=20
!com.mycompany.AddCopyRightString.Impl) // and =
this aspect (to prevent recursion)...
implements HasCopyRightString; // ...will =
implement the above interface
}
------------------
but alas, static fields are not supported in static aspects. And I am =
not sure either, whether this would mean that the string's value would =
actually be "woven" into each class file.
Still seeking an "aspectized" solution for this. Any ideas?
Michael
"Michael Moser" <mmo@zurich.ibm.com> wrote in message =
news:c8f8ta$rjl$1@eclipse.org...
> ...
"Michael Moser" <mmo@zurich.ibm.com> wrote in message =
news:c8daa0$l6s$1@eclipse.org...
> ...
------=_NextPart_000_0025_01C43DB5.AC935C50
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1400" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff background=3D"">
<DIV><FONT face=3DArial size=3D2>The following variant works during =
runtime, i.e.=20
can request the copyright-string's value from each and every class, but =
- alas,=20
in this case - the string's value is not actually copied into each =
classfile and=20
thus this does not fulfil my requirement. :-(</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV><FONT face=3DArial =
size=3D2>
<DIV>------------------<BR><FONT face=3DCourier>public aspect =
AddCopyRightString=20
<BR>{<BR> public interface HasCopyRightString=20
{<BR> // add a static =
copyright String=20
member to each class: <BR> =
public=20
final static String COPYRIGHT =3D "bla bla...";<BR> =20
}<BR><BR> declare parents: (com.mycompany..* =
&& // all=20
classes in and under=20
com.tivoli.act<BR> &=
nbsp; & nbsp; =20
!com.mycompany.AddCopyRightString) // except this aspect (to prevent=20
recursion)...<BR> &n=
bsp; &n bsp; =20
implements HasCopyRightString; // ...will implement the above=20
interface<BR>}<BR></FONT>------------------</DIV>
<DIV><BR>I also experimented with static aspects, i.e.:</DIV>
<DIV><BR><FONT face=3DCourier><FONT=20
face=3DArial>------------------</FONT></FONT></DIV>
<DIV><FONT face=3DCourier>public aspect AddCopyRightString=20
<BR>{<BR> public interface HasCopyRightString=20
{<BR> static aspect Impl=20
{<BR> // =
add a=20
static copyright String member to each class: <BR> =20
public final static String =
COPYRIGHT=20
=3D "bla bla...";</FONT></DIV>
<DIV><FONT=20
face=3DCourier> &nbs=
p; // &n bsp; &n b=
sp;=20
^^^^^^ not allowed...</FONT></DIV>
<DIV><FONT face=3DCourier> =20
}<BR> }</FONT></DIV>
<DIV><FONT face=3DCourier> declare parents: =
(com.mycompany..*=20
&& // all classes in and under=20
com.tivoli.act<BR> &=
nbsp; & nbsp; =20
!com.mycompany.AddCopyRightString) && // except this=20
aspect <BR> &nb=
sp; &nb sp; =20
!com.mycompany.AddCopyRightString.Impl) // and this aspect (to prevent=20
recursion)...<BR> &n=
bsp; &n bsp; =20
implements HasCopyRightString; // ...will implement the above=20
interface<BR>}</FONT></DIV>
<DIV><FONT face=3DCourier><FONT =
face=3DArial>------------------</FONT></FONT></DIV>
<DIV><FONT face=3DCourier><FONT face=3DArial>but alas, static fields are =
not=20
supported in static aspects. And I am not sure either, whether this =
would mean=20
that the string's value would actually be "woven" into each class=20
file.</FONT></FONT></DIV>
<DIV> </DIV>
<DIV>Still seeking an "aspectized" solution for this. Any=20
ideas?<BR>Michael</DIV>
<DIV> </DIV>
<DIV><BR>"Michael Moser" <mmo@zurich.ibm.com> wrote in message <A=20
href=3D"news:c8f8ta$rjl$1@eclipse.org">news:c8f8ta$rjl$1@eclipse.org</A>.=
...</DIV>
<DIV>> ...<BR><BR>"Michael Moser" <mmo@zurich.ibm.com> wrote in =
message=20
<A=20
href=3D"news:c8daa0$l6s$1@eclipse.org">news:c8daa0$l6s$1@eclipse.org</A>.=
...</DIV>
<DIV>> ...</FONT></DIV></BODY></HTML>
------=_NextPart_000_0025_01C43DB5.AC935C50--
|
|
|
Re: how to do static crosscutting (adding of member-variables) across multiple classes? [message #37053 is a reply to message #35889] |
Tue, 01 June 2004 13:38  |
Eclipse User |
|
|
|
This is a multi-part message in MIME format.
------=_NextPart_000_0019_01C44810.099DA720
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Coming back to this issue: defining an intertype for a specific class =
works:
public aspect AddCopyRightString=20
{
// add a static copyright String member to a specific class:=20
public final static String package.someClass.COPYRIGHT =3D "bla =
bla...";
}
while defining the same for all classes in a package does not:
public aspect AddCopyRightString=20
{
// add a static copyright String member to each class in a package:=20
public final static String package.*.COPYRIGHT =3D "bla bla...";
}
nor does it for a subset of classes:
public aspect AddCopyRightString=20
{
// add a static copyright String member to a subset of classes:=20
public final static String package.SomePrefix*.COPYRIGHT =3D "bla =
bla...";
}
IMHO this is a bug or at least a severe inconsistency in AspectJ!
Since for pointcuts one can specify wildcards (see "AspectJ in Action", =
page 69) like e.g.:
javax..* to specify any type in or below the java package=20
or e.g.
javax..*Model+ to specify each class in package java or subpackages =
of it whose names end in "Model" and all it derived classes.
so one should be able to use the same technique to define inter-type =
declarations, i.e. e.g.
public int javax..*.someMember =3D 0;
or=20
public int javax..*Model+.someMember =3D 10;
Any hope on the horizon that this will be possible anytime soon? Or is =
there any "deeper" reason for this inconsistency?=20
Michael
------=_NextPart_000_0019_01C44810.099DA720
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1400" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff background=3D"">
<DIV><FONT face=3DArial size=3D2>Coming back to this issue: </FONT><FONT =
face=3DArial=20
size=3D2>defining an intertype for a specific class works:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT =
face=3DCourier></FONT></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3DCourier>public aspect =
AddCopyRightString=20
<BR>{<BR> // add a static copyright String member =
to a=20
specific class: <BR> public final static String=20
package.someClass.COPYRIGHT =3D "bla bla...";<BR>}</FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT =
face=3DCourier></FONT></FONT> </DIV>
<DIV><FONT face=3DCourier size=3D2>
<DIV><FONT face=3DArial size=3D2>while defining the same for all classes =
in a=20
package does not:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT =
face=3DArial></FONT></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3DCourier>public aspect =
AddCopyRightString=20
<BR>{<BR> // add a static copyright String member =
to each=20
class in a package: <BR> public final static =
String=20
package.*.COPYRIGHT =3D "bla =
bla...";<BR>}</FONT></FONT></DIV></FONT></DIV>
<DIV><FONT face=3DCourier size=3D2>
<DIV><FONT face=3DArial size=3D2><FONT =
face=3DArial></FONT></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3DCourier><FONT =
face=3DArial>nor=20
does it for a subset of classes:</FONT></FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT =
face=3DArial></FONT></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3DCourier>public aspect =
AddCopyRightString=20
<BR>{<BR> // add a static copyright String member =
to a=20
subset of classes: <BR> public final static =
String=20
package.SomePrefix*.COPYRIGHT =3D "bla=20
bla...";<BR>}</FONT></FONT></DIV></FONT></DIV>
<DIV><FONT face=3DCourier size=3D2></FONT> </DIV>
<DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>IMHO this is a bug or at least a =
severe=20
inconsistency in AspectJ!<BR></DIV></FONT><FONT face=3DArial =
size=3D2></FONT>
<DIV><FONT face=3DArial size=3D2>Since for pointcuts one can specify=20
wildcards (see "AspectJ in Action", page 69) like =
e.g.:</FONT></DIV>
<DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><FONT=20
face=3DCourier>javax..*</FONT> to specify any type in =
or below=20
the java package </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>or e.g.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT=20
face=3DCourier>javax..*Model+</FONT> to specify each =
class in=20
package java or subpackages of it whose names end in "Model" =
and all=20
it derived classes.</FONT><FONT face=3DArial =
size=3D2></DIV></DIV></FONT>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3DCourier><FONT =
face=3DArial>so=20
one should be able to use the same technique to define inter-type=20
declarations, i.e. </FONT></FONT></FONT><FONT face=3DArial=20
size=3D2>e.g.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DCourier size=3D2>public int javax..*.someMember =3D =
0;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>or </FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3DCourier><FONT =
face=3DArial><FONT=20
face=3DCourier size=3D2><FONT face=3DCourier size=3D2>public </FONT>int=20
javax..*Model+.someMember =3D 10;</DIV>
<DIV>
<DIV>
<DIV><FONT=20
face=3DArial></FONT> </DIV></FONT></DIV></FONT ></FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3DCourier><FONT=20
face=3DArial></FONT></FONT></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3DCourier><FONT =
face=3DArial>Any hope on the=20
horizon that this will be possible anytime soon? =
</FONT></FONT></FONT><FONT=20
face=3DArial size=3D2><FONT face=3DCourier><FONT face=3DArial>Or is =
there any "deeper"=20
reason for this inconsistency? </FONT></FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT =
face=3DCourier><BR></FONT>Michael</DIV></DIV>
<DIV></FONT> </DIV></BODY></HTML>
------=_NextPart_000_0019_01C44810.099DA720--
|
|
|
Re: how to do static crosscutting (adding of member-variables) across multiple classes? [message #579718 is a reply to message #35854] |
Wed, 19 May 2004 09:26  |
Eclipse User |
|
|
|
This is a multi-part message in MIME format.
------=_NextPart_000_0025_01C43DB5.AC935C50
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
The following variant works during runtime, i.e. can request the =
copyright-string's value from each and every class, but - alas, in this =
case - the string's value is not actually copied into each classfile and =
thus this does not fulfil my requirement. :-(
------------------
public aspect AddCopyRightString=20
{
public interface HasCopyRightString {
// add a static copyright String member to each class:=20
public final static String COPYRIGHT =3D "bla bla...";
}
declare parents: (com.mycompany..* && // all classes in and under =
com.tivoli.act
!com.mycompany.AddCopyRightString) // except this =
aspect (to prevent recursion)...
implements HasCopyRightString; // ...will =
implement the above interface
}
------------------
I also experimented with static aspects, i.e.:
------------------
public aspect AddCopyRightString=20
{
public interface HasCopyRightString {
static aspect Impl {
// add a static copyright String member to each class:=20
public final static String COPYRIGHT =3D "bla bla...";
// ^^^^^^ not allowed...
}
}
declare parents: (com.mycompany..* && // all classes in and under =
com.tivoli.act
!com.mycompany.AddCopyRightString) && // except =
this aspect=20
!com.mycompany.AddCopyRightString.Impl) // and =
this aspect (to prevent recursion)...
implements HasCopyRightString; // ...will =
implement the above interface
}
------------------
but alas, static fields are not supported in static aspects. And I am =
not sure either, whether this would mean that the string's value would =
actually be "woven" into each class file.
Still seeking an "aspectized" solution for this. Any ideas?
Michael
"Michael Moser" <mmo@zurich.ibm.com> wrote in message =
news:c8f8ta$rjl$1@eclipse.org...
> ...
"Michael Moser" <mmo@zurich.ibm.com> wrote in message =
news:c8daa0$l6s$1@eclipse.org...
> ...
------=_NextPart_000_0025_01C43DB5.AC935C50
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1400" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff background=3D"">
<DIV><FONT face=3DArial size=3D2>The following variant works during =
runtime, i.e.=20
can request the copyright-string's value from each and every class, but =
- alas,=20
in this case - the string's value is not actually copied into each =
classfile and=20
thus this does not fulfil my requirement. :-(</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV><FONT face=3DArial =
size=3D2>
<DIV>------------------<BR><FONT face=3DCourier>public aspect =
AddCopyRightString=20
<BR>{<BR> public interface HasCopyRightString=20
{<BR> // add a static =
copyright String=20
member to each class: <BR> =
public=20
final static String COPYRIGHT =3D "bla bla...";<BR> =20
}<BR><BR> declare parents: (com.mycompany..* =
&& // all=20
classes in and under=20
com.tivoli.act<BR> &=
nbsp; & nbsp; =20
!com.mycompany.AddCopyRightString) // except this aspect (to prevent=20
recursion)...<BR> &n=
bsp; &n bsp; =20
implements HasCopyRightString; // ...will implement the above=20
interface<BR>}<BR></FONT>------------------</DIV>
<DIV><BR>I also experimented with static aspects, i.e.:</DIV>
<DIV><BR><FONT face=3DCourier><FONT=20
face=3DArial>------------------</FONT></FONT></DIV>
<DIV><FONT face=3DCourier>public aspect AddCopyRightString=20
<BR>{<BR> public interface HasCopyRightString=20
{<BR> static aspect Impl=20
{<BR> // =
add a=20
static copyright String member to each class: <BR> =20
public final static String =
COPYRIGHT=20
=3D "bla bla...";</FONT></DIV>
<DIV><FONT=20
face=3DCourier> &nbs=
p; // &n bsp; &n b=
sp;=20
^^^^^^ not allowed...</FONT></DIV>
<DIV><FONT face=3DCourier> =20
}<BR> }</FONT></DIV>
<DIV><FONT face=3DCourier> declare parents: =
(com.mycompany..*=20
&& // all classes in and under=20
com.tivoli.act<BR> &=
nbsp; & nbsp; =20
!com.mycompany.AddCopyRightString) && // except this=20
aspect <BR> &nb=
sp; &nb sp; =20
!com.mycompany.AddCopyRightString.Impl) // and this aspect (to prevent=20
recursion)...<BR> &n=
bsp; &n bsp; =20
implements HasCopyRightString; // ...will implement the above=20
interface<BR>}</FONT></DIV>
<DIV><FONT face=3DCourier><FONT =
face=3DArial>------------------</FONT></FONT></DIV>
<DIV><FONT face=3DCourier><FONT face=3DArial>but alas, static fields are =
not=20
supported in static aspects. And I am not sure either, whether this =
would mean=20
that the string's value would actually be "woven" into each class=20
file.</FONT></FONT></DIV>
<DIV> </DIV>
<DIV>Still seeking an "aspectized" solution for this. Any=20
ideas?<BR>Michael</DIV>
<DIV> </DIV>
<DIV><BR>"Michael Moser" <mmo@zurich.ibm.com> wrote in message <A=20
href=3D"news:c8f8ta$rjl$1@eclipse.org">news:c8f8ta$rjl$1@eclipse.org</A>.=
...</DIV>
<DIV>> ...<BR><BR>"Michael Moser" <mmo@zurich.ibm.com> wrote in =
message=20
<A=20
href=3D"news:c8daa0$l6s$1@eclipse.org">news:c8daa0$l6s$1@eclipse.org</A>.=
...</DIV>
<DIV>> ...</FONT></DIV></BODY></HTML>
------=_NextPart_000_0025_01C43DB5.AC935C50--
|
|
|
Re: how to do static crosscutting (adding of member-variables) across multiple classes? [message #580432 is a reply to message #35889] |
Tue, 01 June 2004 13:38  |
Eclipse User |
|
|
|
This is a multi-part message in MIME format.
------=_NextPart_000_0019_01C44810.099DA720
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Coming back to this issue: defining an intertype for a specific class =
works:
public aspect AddCopyRightString=20
{
// add a static copyright String member to a specific class:=20
public final static String package.someClass.COPYRIGHT =3D "bla =
bla...";
}
while defining the same for all classes in a package does not:
public aspect AddCopyRightString=20
{
// add a static copyright String member to each class in a package:=20
public final static String package.*.COPYRIGHT =3D "bla bla...";
}
nor does it for a subset of classes:
public aspect AddCopyRightString=20
{
// add a static copyright String member to a subset of classes:=20
public final static String package.SomePrefix*.COPYRIGHT =3D "bla =
bla...";
}
IMHO this is a bug or at least a severe inconsistency in AspectJ!
Since for pointcuts one can specify wildcards (see "AspectJ in Action", =
page 69) like e.g.:
javax..* to specify any type in or below the java package=20
or e.g.
javax..*Model+ to specify each class in package java or subpackages =
of it whose names end in "Model" and all it derived classes.
so one should be able to use the same technique to define inter-type =
declarations, i.e. e.g.
public int javax..*.someMember =3D 0;
or=20
public int javax..*Model+.someMember =3D 10;
Any hope on the horizon that this will be possible anytime soon? Or is =
there any "deeper" reason for this inconsistency?=20
Michael
------=_NextPart_000_0019_01C44810.099DA720
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1400" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff background=3D"">
<DIV><FONT face=3DArial size=3D2>Coming back to this issue: </FONT><FONT =
face=3DArial=20
size=3D2>defining an intertype for a specific class works:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT =
face=3DCourier></FONT></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3DCourier>public aspect =
AddCopyRightString=20
<BR>{<BR> // add a static copyright String member =
to a=20
specific class: <BR> public final static String=20
package.someClass.COPYRIGHT =3D "bla bla...";<BR>}</FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT =
face=3DCourier></FONT></FONT> </DIV>
<DIV><FONT face=3DCourier size=3D2>
<DIV><FONT face=3DArial size=3D2>while defining the same for all classes =
in a=20
package does not:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT =
face=3DArial></FONT></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3DCourier>public aspect =
AddCopyRightString=20
<BR>{<BR> // add a static copyright String member =
to each=20
class in a package: <BR> public final static =
String=20
package.*.COPYRIGHT =3D "bla =
bla...";<BR>}</FONT></FONT></DIV></FONT></DIV>
<DIV><FONT face=3DCourier size=3D2>
<DIV><FONT face=3DArial size=3D2><FONT =
face=3DArial></FONT></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3DCourier><FONT =
face=3DArial>nor=20
does it for a subset of classes:</FONT></FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT =
face=3DArial></FONT></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3DCourier>public aspect =
AddCopyRightString=20
<BR>{<BR> // add a static copyright String member =
to a=20
subset of classes: <BR> public final static =
String=20
package.SomePrefix*.COPYRIGHT =3D "bla=20
bla...";<BR>}</FONT></FONT></DIV></FONT></DIV>
<DIV><FONT face=3DCourier size=3D2></FONT> </DIV>
<DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>IMHO this is a bug or at least a =
severe=20
inconsistency in AspectJ!<BR></DIV></FONT><FONT face=3DArial =
size=3D2></FONT>
<DIV><FONT face=3DArial size=3D2>Since for pointcuts one can specify=20
wildcards (see "AspectJ in Action", page 69) like =
e.g.:</FONT></DIV>
<DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><FONT=20
face=3DCourier>javax..*</FONT> to specify any type in =
or below=20
the java package </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>or e.g.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT=20
face=3DCourier>javax..*Model+</FONT> to specify each =
class in=20
package java or subpackages of it whose names end in "Model" =
and all=20
it derived classes.</FONT><FONT face=3DArial =
size=3D2></DIV></DIV></FONT>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3DCourier><FONT =
face=3DArial>so=20
one should be able to use the same technique to define inter-type=20
declarations, i.e. </FONT></FONT></FONT><FONT face=3DArial=20
size=3D2>e.g.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DCourier size=3D2>public int javax..*.someMember =3D =
0;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>or </FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3DCourier><FONT =
face=3DArial><FONT=20
face=3DCourier size=3D2><FONT face=3DCourier size=3D2>public </FONT>int=20
javax..*Model+.someMember =3D 10;</DIV>
<DIV>
<DIV>
<DIV><FONT=20
face=3DArial></FONT> </DIV></FONT></DIV></FONT ></FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3DCourier><FONT=20
face=3DArial></FONT></FONT></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3DCourier><FONT =
face=3DArial>Any hope on the=20
horizon that this will be possible anytime soon? =
</FONT></FONT></FONT><FONT=20
face=3DArial size=3D2><FONT face=3DCourier><FONT face=3DArial>Or is =
there any "deeper"=20
reason for this inconsistency? </FONT></FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT =
face=3DCourier><BR></FONT>Michael</DIV></DIV>
<DIV></FONT> </DIV></BODY></HTML>
------=_NextPart_000_0019_01C44810.099DA720--
|
|
|
Powered by
FUDForum. Page generated in 0.07248 seconds