Results 1 to 3 of 3

Thread: @BeforeStep in abstract class

  1. #1
    Join Date
    Mar 2011
    Posts
    9

    Default @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. #2
    Join Date
    Jun 2005
    Posts
    4,230

    Default

    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.

  3. #3
    Join Date
    May 2008
    Posts
    10

    Default 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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •