Results 1 to 6 of 6

Thread: Caching private method

  1. #1
    Join Date
    Dec 2007
    Posts
    3

    Default Caching private method

    Hi,

    I have a bean like this:

    public class Class1 {
    private Class2 methodA(String abc) {
    //hello
    }
    public Class2 methodA() {
    methodA("hello");
    }
    }

    Now, I need to cache only the private method.

    Can anyone suggest a solution for this?

    Thanks,
    Nishchal

  2. #2
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    The private method is not going to be invoked from outside the class. Therefore Spring AOP cannot help you, due to its proxy-based approach. You will need AspectJ to advise private methods.

    See here for further information.

  3. #3
    Join Date
    Dec 2007
    Posts
    3

    Default

    I tried doing caching using AspectJ. I am new to AOP itself, and so I encountering a lot of errors.
    I have attached my spring-application xml and ehcache xml file here. Also attached are the two Java files. Can you please look into these and let me know where I am going wrong?

    Thanks,
    Nishchal
    Attached Files Attached Files

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    You are still using Spring AOP, although based on the AspectJ support. When Andreas said you need to use AspectJ he meant you need AspectJ loadtime or compile time weaving.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5
    Join Date
    Dec 2007
    Posts
    3

    Default

    I didn't understand it. Can you give me some examples which I can follow or any link that could guide me on this?

    Thanks,
    Nishchal

  6. #6
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    The reference guide is quite clear on this. I suggest you read the according chapter.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •