-1

Helly everybody,

im searching for a way to extend every Methode in a Class with sample Code.

Language: Java

IDE: IntelliJ

The Idea:

I want to do a Security-Check before every funktion which could be called in a class and don't want to implement every function like:

public boolean myFun(){
    securityCheck();
    return Whateva;
}

I searched for annotation solutions but i cant find a possible interpretation. The Idea is that no one of my group Members can miss the securityCheck and there is no option (if bad coded or not) to bypass the check if used this Class.

I hope you can show me the right way.

kind regards

Max11251
  • 31
  • 2

1 Answers1

1

Have a look at the concept of Aspect-oriented Programming (AOP) but depending on your specific use case this might be overkill.

As a start you can read upon AspectJ for Java.

officer
  • 2,080
  • 1
  • 20
  • 29