Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 320369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:44:50+00:00 2026-05-12T08:44:50+00:00

With relationship aspects implemented in AspectJ I can associate objects of two types in

  • 0

With relationship aspects implemented in AspectJ I can associate objects of two types in the following way (see code example below). I would like to transfer this concept to .net. Can you point me towards a .net weaver implementation that will allow me to do this or something similar?

Relationship aspects are designed by Pearce & Noble. Read more about the concept and implementation here: http://homepages.ecs.vuw.ac.nz/~djp/RAL/index.html

Im fairly new to AOP and my limited knowledge is obtained from playing around with AspectJ. I have identified that the design benefits from AspectJ’s capabilities of supporting intertype declarations and generic types, as well as being able to group weaving rules and advice within the unit of an “aspect”.

An example of associating Student and Course objects using a (simplified) relationship aspect:

public class Course02 {
    public String title;
    public Course02(String title)   {this.title = title;    }
}

public class Student02 {
    public String name;
    public Student02(String name)   {this.name = name;  }
}

public aspect Attends02 extends SimpleStaticRel02<Student02, Course02> {}

public abstract aspect SimpleStaticRel02<FROM,TO>{ 

    public static interface Fwd{}
    public static interface Bwd{}

    declare parents : FROM implements Fwd;
    declare parents : TO implements Bwd;

    final private HashSet Fwd.fwd = new HashSet();
    final private HashSet Bwd.bwd = new HashSet();

    public boolean add(FROM _f, TO _t) {
        Fwd f = (Fwd) _f;
        Bwd t = (Bwd) _t;

        f.fwd.add(_t); // from adder to i fwd hashset
        return t.bwd.add(_f); // to adder from i bwd hashset
    }  

    public void printFwdCount(FROM _f)
    {
        Fwd f = (Fwd) _f;
        System.out.println("Count forward is: " + f.fwd.size());
    }

    public void printBwdCount(TO _t)
    {
        Bwd b  = (Bwd) _t;
        System.out.println("Count backward is: " + b.bwd.size());
    }

}

public class TestDriver {

    public TestDriver() {

        Course02 comp205 = new Course02("comp205");
        Course02 comp206 = new Course02("comp206");
        Student02 Joe = new Student02("Joe");
        Student02 Andreas = new Student02("Andreas");

        Attends02.aspectOf().add(Joe, comp205);
        Attends02.aspectOf().add(Joe, comp206);

        Attends02.aspectOf().printFwdCount(Andreas);
        Attends02.aspectOf().printFwdCount(Joe);
        Attends02.aspectOf().printBwdCount(comp206);
    }

    public static void main(String[] args) {
        new TestDriver();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T08:44:50+00:00Added an answer on May 12, 2026 at 8:44 am

    I’m not familiar with relationship aspects, but have you looked at PostSharp? It’s the top dog among aspect weavers for .NET. My guess is they support relationship aspects.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In reference to these two questions (see links below) and the Google AppEngine doc,
A one to many relationship between two tables should be implemented with two or
I have the following relationship between two domain classes: class Emp { String name
I have a relationship between two tables, authors and styles. Every author is associated
In a 1-M relationship, in the many side of the relationship I can pull
I have the following relationship User --> has_many: Articles Article --> belongs_to: User I
When adding a relationship between two tables, I am offered the choice of adding
Suppose I have a relationship 1 to N, for example Student , College. Student
We have the following relationship for our data: Users Have and belong to many
I have this relationship where User can create a document(trip) and invite other users

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.