Without using interfaces
----------------------------------------------------------------------------
package spring.example2;
public class StringProducer {
private String data="Test data ";
public String produce(){
return data+" : TIME - "+new java.util.Date();
}
}
package spring.example2;
public class StringConsumer {
public void consume(String s){
System.out.println("DATA CONSUMED : "+s);
}
}
------------------------------------------------------------------------------
package spring.example2;
//It does not user interfaces
import org.springframework.beans.factory.support.BeanDefinitionReader;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader;
import org.springframework.core.io.ClassPathResource;
public class Executor {
public static void main(String ar[]){
DefaultListableBeanFactory bf=new DefaultListableBeanFactory();
BeanDefinitionReader reader=new PropertiesBeanDefinitionReader(bf);
ClassPathResource cpr=new ClassPathResource("spring/example2/producer-consumer.properties");
reader.loadBeanDefinitions(cpr);
StringProducer producer=(StringProducer)bf.getBean("producer");
StringConsumer consumer=(StringConsumer)bf.getBean("consumer");
consumer.consume(producer.produce());
}
}
------------------------------------------------------------------------------
producer.(class)=spring.example2.StringProducer
consumer.(class)=spring.example2.StringConsumer
----------------------------------------------------------------------------
package spring.example2;
public class StringProducer {
private String data="Test data ";
public String produce(){
return data+" : TIME - "+new java.util.Date();
}
}
package spring.example2;
public class StringConsumer {
public void consume(String s){
System.out.println("DATA CONSUMED : "+s);
}
}
------------------------------------------------------------------------------
package spring.example2;
//It does not user interfaces
import org.springframework.beans.factory.support.BeanDefinitionReader;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader;
import org.springframework.core.io.ClassPathResource;
public class Executor {
public static void main(String ar[]){
DefaultListableBeanFactory bf=new DefaultListableBeanFactory();
BeanDefinitionReader reader=new PropertiesBeanDefinitionReader(bf);
ClassPathResource cpr=new ClassPathResource("spring/example2/producer-consumer.properties");
reader.loadBeanDefinitions(cpr);
StringProducer producer=(StringProducer)bf.getBean("producer");
StringConsumer consumer=(StringConsumer)bf.getBean("consumer");
consumer.consume(producer.produce());
}
}
------------------------------------------------------------------------------
producer.(class)=spring.example2.StringProducer
consumer.(class)=spring.example2.StringConsumer
Comments