File: hello.xml
"http://www.springframework.org/dtd/spring-beans.dtd">
class="helloimpl">
Good Morning!...
File: helloclient.java
import java.io.*;
import org.springframework.beans.factory.*;
import org.springframework.beans.factory.xml.*;
import org.springframework.core.io.*;
public class helloclient
{
public static void main(String args[]) throws Exception
{
try
{
System.out.println("point1");
Resource res = new ClassPathResource("hello.xml");
System.out.println("point2");
BeanFactory factory = new XmlBeanFactory(res);
System.out.println("point3");
hello bean1 = (hello)factory.getBean("hello");
String s = bean1.sayhello("Joe");
System.out.println(s);
}catch(Exception e1){System.out.println(""+e1);}
}
}
File: helloimpl.java
public class helloimpl implements hello
{
private String greeting;
public helloimpl()
{
}
public helloimpl(String a)
{
greeting=a;
}
public String sayhello(String s)
{
return greeting+s;
}
public void setGreeting(String a)
{
greeting=a;
}
}
File: hello.java
public interface hello
{
public String sayhello(String a);
}
Spring-SpringClassPathResourceDemo.zip( 1,480 k)