Announcement Announcement Module
Collapse
No announcement yet.
@BeforeStep in abstract class Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • @BeforeStep in abstract class

    I want to do following thing but spring is throwing a exception.

    Code:
    public abstract class myAbstractClass{
    
        @BeforeStep
        public void doSomething()
    
    }
    
    public class myClass extends myAbstractClass{
        
        public void doSomething(){
              //Do something here
        }
    Its throwing the following exception
    Code:
    Caused by: java.lang.IllegalArgumentException: found more than one method on target class [myClass] with the annotation type [BeforeStep].
    Now the exception goes away if I put the @BeforeStep in my concrete class. However, I want to enforce whoever extends myAbstractClass to make sure that doSomething method executed before the step. I know I can implement StepExecutionListener but I will be only using beforeStep method which means I will be implementing afterStep with nothing in the method body but that's just not nice though. Anyone has solution to this?

  • #2
    We could fix that in the framework if you raise a JIRA ticket. In the meantime you'll have to use the interface. You base class only has to implement one extra method and make it final for exactly the same behaviour, so it doesn't seem like a big deal.

    Comment


    • #3
      inheritance

      Personally, I consider it being useful doing inheritance within readers, processors or writers and adjusting/enhancing the @BeforeStep / @AfterStep methods. This should not be limited on abstract classes.

      What about the JIRA ticket? If not established yet, I would like to do so.


      Thanks


      Penny_Wise

      Comment

      Working...
      X