Back Forum Reply New

How to invoke one method in second?

I'm novice in Spring. Help,please
I have 3 classes:

class First
{
public void method(String arg)
{
System.out.print(arg);
//Here
System.out.print(quot;1.1quot;);
}
}

class Second
{
public void methodWithArgs(String arg)
{
System.out.print(arg);
//Here
System.out.print(quot;2.1quot;);
}
}class Theard
{
public void HereWithArgs(String arg)
{
System.out.print(quot;Here:quot;+arg);
}
I want to invoke Theard.HereWithArgs(arg) method in plase marked //Here. give him argument arg
I want to use anything like interceptor or events or listeners or Acept or anything like this.
How to do it?

Spring AOP will not be able to help with this. Spring AOP will only be able to intercept executions of public methods in your project.

I guess, overall, I am confused.  Why not just this:class Second { public void methodWithArgs(String arg) {   System.out.print(arg);   //Here   new Theard().HereWithArgs(arg)   System.out.print(quot;2.1quot;); }
}
Originally Posted by KamilBekI'm novice in Spring. Help,please
...
I want to invoke Theard.HereWithArgs(arg) method in plase marked //Here. give him argument arg
I want to use anything like interceptor or events or listeners or Acept or anything like this.
How to do it?

You can achieve that with AspectJ weaving and 'call' pointcut. Example can be found here
¥
Back Forum Reply New