I wrote some console client for a simple application. To be more flexible, I thought it would be nice to depend only on java.io.Input-/OutputStreaminstead of direct access to System.in/out.
I renamed the class ConsoleClientto StreamClient, added setters, and made sure that System.in/outinstance fields were used instead of fields .
Currently, my client code is as follows:
ApplicationContext appCtx = new ClassPathXmlApplicationContext("...");
StreamClient cc = (StreamClient) appCtx.getBean("streamClient");
cc.setInputStream(System.in);
cc.setOutputStream(System.out);
cc.run();
Question:
Is there a way to move lines 3 and 4 into the Spring configuration (preferably, embedding the constructor)?
Thank you for your time.
source
share