[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] Basic AspectJ question
|
You need to modify your aspect :
aspect PathChannelHack {
after(PathChanInst pathchannel) : set(private CircPathInst
parentPathInst) && this(pathchannel) {
pathchannel.setParentPathHumid(pathchannel.getParentPathInst().getPathHumId());
}
}
I suggest that you get this working with a standalone example first
and then weave into the jar (binary weaving).
-Ramnivas
On Thu, Dec 4, 2008 at 11:18 AM, Sebestyén Zoltán <szoli2@xxxxxxxxxxx> wrote:
> Hi,
>
> I've got the following problem (I've got JDK 1.5 + AspectJ 1.5.3). There's
> a class for which I can't modify the source however I've got to have an
> extra field which should be updated whenever an certain other field is set.
> I tried to create a small aspect for that without any success. Could please
> someone show me how to do it? I'd like to have this modification in the
> class file since it's part of a JAR used in several projects so the
> solutions should be portable.
> The field in question is only set in the constructor and it's setter method.
> Both fields have setter and getter methods.
>
> The relevant source is the following:
>
> ...
>
> /** @author Hibernate CodeGenerator */
> public class PathChanInst implements Serializable {
>
> ...
> /** This is the source field, it should be monitored. */
> private CircPathInst parentPathInst;
>
> /** The extra field, it should be updated whenever parentPathInst is
> changed */
> private String parentPathHumid;
> ...
>
> /** full constructor */
> public PathChanInst(...) {
> ...
> // Here's the first occasion, after that should parentPathHumid set.
> this.parentPathInst = parentPathInst;
> ...
> }
>
> ...
>
> public void setParentPathInst(CircPathInst parentPathInst) {
>
> // Here's the second occasion, after that should parentPathHumid set.
> this.parentPathInst = parentPathInst;
> }
> }
>
> The aspect I did:
>
> aspect PathChannelHack {
>
> after(PathChanInst pathchannel) : set(private CircPathInst
> parentPathInst) {
>
> pathchannel.setParentPathHumid(pathchannel.getParentPathInst().getPathHumId());
> }
> }
>
>
> Thanks in advance,
>
> Zoltan
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>