Women in Technology

Hear us Roar



Article:
  An Introduction to Aspect-Oriented Programming with the Spring Framework, Part 1
Subject:   Automatic Swap of Target Class
Date:   2006-03-31 00:06:31
From:   russellmiles
Response to: Automatic Swap of Target Class

It might be worht having a look at the second article in this series (available at http://www.onjava.com/pub/a/onjava/2004/10/20/springaop2.html) and how I implemented the cuckoo's egg pattern? This pattern deals explicitly with the changing of an application's feature based on your business needs and so does some of what you are looking for
Full Threads Oldest First

Showing messages 1 through 1 of 1.

  • Automatic Swap of Target Class
    2006-04-06 01:57:53  spidercat [View]

    Hi Russ,

    Here is a better example of my question. If you look at the code using aspectJ, it is supposed to replace call at HelloWorld.say* method. An unlike what I've tried in Spring, HelloWord does not necessarily need an interface. Would you have any idea how this is done in Spring?

    // HelloWorld.java
    public class HelloWorld {
    public static void say(String message) {
    System.out.println(message);
    }

    public static void sayToPerson(String message, String name) {
    System.out.println(name + ", " + message);
    }
    }



    public aspect MannersAspect {
    pointcut callSayMessage() : call(public static void HelloWorld.say*(..));
    before() : callSayMessage() {
    System.out.println("Good day!");
    }

    after() : callSayMessage() {
    System.out.println("Thank you!");
    }
    }

    Cheers,

    Cathy