facebook

Using Services in Batch

  1. MyEclipse IDE
  2.  > 
  3. Spring Development
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #317901 Reply

    Anderson
    Member

    How can I execute methods of a service created with the generator of MyEclipse Spring Batch?
    Thanks for any help.
    Below is an example of what I would do.

    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.FileSystemXmlApplicationContext;
    import org.springframework.test.context.ContextConfiguration;

    public class Teste {

    /**
    * @param args
    */
    public static void main(String[] args) {
    String[] files = {“file:./resources/test-security-context.xml”,”file:./resources/test-service-context.xml”,
    “file:./resources/test-dao-context.xml”,
    “file:./resources/test-web-context.xml”};
    ApplicationContext cxt = new FileSystemXmlApplicationContext(files);

    EstadoCivilService ec = (EstadoCivilService) cxt.getBean(“EstadoCivilService”);
    ec.loadEstadoCivils();
    }

    }

    #317982 Reply

    jkennedy
    Member

    I’m not completely sure of what you are working on, or if you have a specific issue, but generally, the Services we are generating are just Spring beans and so you would take the steps you would normally take to invoke a Spring Bean given your context.

    As an example, you can look at the generated ServiceTest class which is a JUnit class that executes the Services in a JUnit context. You will see code that loads the Context files that we need in those test cases, and while your code would not have access to the JUnit infrastructure, it would likely be similar.

    Hope that helps,
    Jack

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Using Services in Batch

You must be logged in to post in the forum log in