Hello All,
I am new to Spring and I need a little help on Injection mechanism for the below code.
I have a Server.java,In that I have a main() like below
And my Application context looks like below,Code:private static Server serverNode1; private static URI serverNode1ConfigURI; public static void main(String[] args) throws Exception { String server1 = "config-server.xml"; Class<Server> t = Server.class; server1 = t.getClassLoader().getResource(server1).toString(); ApplicationContext ac = new ClassPathXmlApplicationContext( "applicationContext.xml"); Server server = (Server) ac.getBean("server"); server.setUp(server1); server.testBasicFlow(); // server.tearDown(); } public void setUp(String serverNode1ConfigURL) throws Exception { try { serverNode1ConfigURI = new URI(serverNode1ConfigURL); serverNode1 = new Server(); serverNode1.init( new FileInputStream(new File(serverNode1ConfigURI)), "SERVER1"); serverNode1.start(); } catch (Throwable e) { e.printStackTrace(); } }
My AIM is to convert my existing Java project to Spring frame work.In that scenario I am converting one by one object into the spring frame work.Code:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <bean id="server" class="com.glass.diameter.stack.functional.rf.base.Server"/> </beans>
Can you any one help me how to inject the setUp () ?
I hope you understood my scenario.


Reply With Quote