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 6701095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:53:34+00:00 2026-05-26T06:53:34+00:00

i am creating an aspect class with spring aspectj as follow @Aspect public class

  • 0

i am creating an aspect class with spring aspectj as follow

@Aspect
public class AspectDemo {
  @Pointcut("execution(* abc.execute(..))")
     public void executeMethods() { }

 @Around("executeMethods()")
    public Object profile(ProceedingJoinPoint pjp) throws Throwable {
            System.out.println("Going to call the method.");
            Object output = pjp.proceed();
            System.out.println("Method execution completed.");
            return output;
    }

} 

now i want to access the property name of class abc then how to acccess it in aspect class?
i want to display name property of abc class in profile method

my abc class is as follow

public class abc{
String name;

public void setName(String n){
name=n;
}
public String getName(){
 return name;
}

public void execute(){
System.out.println("i am executing");
}
}

How can i access the name in aspect class?

  • 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-26T06:53:34+00:00Added an answer on May 26, 2026 at 6:53 am

    You need to get a reference to the target object and cast it to your class (after an instanceof check, perhaps):

    Object target = pjp.getTarget();
    if (target instanceof Abc) {
        String name = ((Abc) target).getName();
        // ...
    }
    

    The recommended approach (for performance and type safety) is to have the target mentioned in the pointcut:

    @Around("executeMethods() && target(abc)")
    public Object profile(ProceedingJoinPoint pjp, Abc abc) ....
    

    But this will only match the executions on a target of type Abc.

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

Sidebar

Related Questions

Creating Traversals for Binary Search Tree with Recursion. void inOrder(void (*inOrderPtr)(T&)) { if(this->left !=
I am creating a web application using zkoss 5.0.4, Spring 3.0.3, Hibernate 3, and
I'm creating an app where a user can subscribe/follow to different aspects of the
I am creating a very data intensive, high volume web site. Every aspect of
I am having some trouble creating a before aspect for a method that has
I am creating a wordpress theme for a record label. One aspect is the
I am currently creating a class to handle all my form data which will
Exception in thread main org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAdvisor#0': Instantiation of bean
I'm creating a dynamic class to generate various images. ImagesUtils.php <?php class ImagesUtils {
I'm busy creating a metaclass that replaces a stub function on a class with

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.