Override protected methods called from private method of parent

Viewed 121

I have a class that runs tons of logic and exposes protected methods to allow inheriting classes to change the regular flow. I'm using Spring Framework to define my components.

Here's a code example of the Parent class exposing a methods called influence that I can override in the Child class:

@Component
public class Parent {
   public void someLogic(...) {
      ...
      do();
   }

   private void do(...) {
      this.influence(...);
      ...
   }

   protected void influence(...) {
      ... // regular flow
   }
} 
@Component
public class Child extends Parent {

   @Override
   protected void influence(...) {
      ... // MY FLOW
   }
}

When running the code, I see that my class isn't being called even though it's being initialised. I narrowed it down to the protected method not being called when accessed from a private method but I couldn't find any explanation of this online.

Why is my code not being called? How can I overpass this obstacle?

0 Answers
Related