Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Thursday, November 22, 2007

java code for Non Singleton

/*
Pro Spring
By Rob Harrop
Jan Machacek
ISBN: 1-59059-461-4
Publisher: Apress
*/


///////////////////////////////////////////////////////////////////////////////////////
//File: beans.xml






Value







///////////////////////////////////////////////////////////////////////////////////////
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.FileSystemResource;

public class NonSingleton {

public static void main(String[] args) {

BeanFactory factory = new XmlBeanFactory(new FileSystemResource(
"build/beans.xml"));

String s1 = (String)factory.getBean("nonSingleton");
String s2 = (String)factory.getBean("nonSingleton");

System.out.println("Identity Equal?: " + (s1 ==s2));
System.out.println("Value Equal:? " + s1.equals(s2));
System.out.println(s1);
System.out.println(s2);
}
}

No comments: