<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FSpring%2FIoC_Resource</id>
		<title>Java/Spring/IoC Resource - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FSpring%2FIoC_Resource"/>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Spring/IoC_Resource&amp;action=history"/>
		<updated>2026-04-21T13:39:55Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Spring/IoC_Resource&amp;diff=6601&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Spring/IoC_Resource&amp;diff=6601&amp;oldid=prev"/>
				<updated>2010-06-01T06:16:40Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 06:16, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Spring/IoC_Resource&amp;diff=6600&amp;oldid=prev</id>
		<title> в 18:01, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Spring/IoC_Resource&amp;diff=6600&amp;oldid=prev"/>
				<updated>2010-05-31T18:01:44Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== File System Resource Demo ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Pro Spring&lt;br /&gt;
By Rob Harrop&lt;br /&gt;
Jan Machacek&lt;br /&gt;
ISBN: 1-59059-461-4&lt;br /&gt;
Publisher: Apress&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
//File: beans.xml&lt;br /&gt;
&amp;lt;!DOCTYPE beans PUBLIC &amp;quot;-//SPRING//DTD BEAN//EN&amp;quot; &amp;quot;http://www.springframework.org/dtd/spring-beans.dtd&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;beans&amp;gt;&lt;br /&gt;
    &amp;lt;bean id=&amp;quot;oracle&amp;quot; name=&amp;quot;wiseworm&amp;quot; class=&amp;quot;BookwormOracle&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
public interface Oracle {&lt;br /&gt;
    public String defineMeaningOfLife();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
public class Encyclopedia {&lt;br /&gt;
}&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
public class BookwormOracle implements Oracle {&lt;br /&gt;
    private Encyclopedia enc;&lt;br /&gt;
    public void setEncyclopedia(Encyclopedia enc) {&lt;br /&gt;
        this.enc = enc;&lt;br /&gt;
    }&lt;br /&gt;
    public String defineMeaningOfLife() {&lt;br /&gt;
        return &amp;quot;Encyclopedia&amp;quot;s are a waste of money - use the Internet&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;&lt;br /&gt;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;&lt;br /&gt;
import org.springframework.core.io.FileSystemResource;&lt;br /&gt;
public class XmlConfig {&lt;br /&gt;
    public static void main(String[] args) {&lt;br /&gt;
        DefaultListableBeanFactory factory = new DefaultListableBeanFactory();&lt;br /&gt;
        XmlBeanDefinitionReader rdr = new XmlBeanDefinitionReader(factory);&lt;br /&gt;
        rdr.loadBeanDefinitions(new FileSystemResource(&amp;quot;build/beans.xml&amp;quot;));&lt;br /&gt;
        Oracle oracle = (Oracle)factory.getBean(&amp;quot;oracle&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Message Source ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Pro Spring&lt;br /&gt;
By Rob Harrop&lt;br /&gt;
Jan Machacek&lt;br /&gt;
ISBN: 1-59059-461-4&lt;br /&gt;
Publisher: Apress&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&amp;lt;!DOCTYPE beans PUBLIC &amp;quot;-//SPRING//DTD BEAN//EN&amp;quot; &amp;quot;http://www.springframework.org/dtd/spring-beans.dtd&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;beans&amp;gt;&lt;br /&gt;
    &amp;lt;bean id=&amp;quot;messageSource&amp;quot; class=&amp;quot;org.springframework.context.support.ResourceBundleMessageSource&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;property name=&amp;quot;basenames&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;list&amp;gt;&lt;br /&gt;
                    &amp;lt;value&amp;gt;buttons&amp;lt;/value&amp;gt;&lt;br /&gt;
                    &amp;lt;value&amp;gt;labels&amp;lt;/value&amp;gt;&lt;br /&gt;
                &amp;lt;/list&amp;gt;    &lt;br /&gt;
            &amp;lt;/property&amp;gt;&lt;br /&gt;
    &amp;lt;/bean&amp;gt;&lt;br /&gt;
&amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
import java.util.Locale;&lt;br /&gt;
import org.springframework.context.ApplicationContext;&lt;br /&gt;
import org.springframework.context.support.FileSystemXmlApplicationContext;&lt;br /&gt;
public class MessageSourceDemo {&lt;br /&gt;
    public static void main(String[] args) {&lt;br /&gt;
        ApplicationContext ctx = new FileSystemXmlApplicationContext(&lt;br /&gt;
                &amp;quot;build/messageSource.xml&amp;quot;);&lt;br /&gt;
        Locale english = Locale.ENGLISH;&lt;br /&gt;
        Locale czech = new Locale(&amp;quot;cs&amp;quot;, &amp;quot;CZ&amp;quot;);&lt;br /&gt;
        System.out.println(ctx.getMessage(&amp;quot;msg&amp;quot;, null, english));&lt;br /&gt;
        System.out.println(ctx.getMessage(&amp;quot;msg&amp;quot;, null, czech));&lt;br /&gt;
        &lt;br /&gt;
        System.out.println(ctx.getMessage(&amp;quot;nameMsg&amp;quot;, new Object[] { &amp;quot;Rob&amp;quot;,&lt;br /&gt;
                &amp;quot;Harrop&amp;quot; }, english));&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
          &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Spring Load Resource from file, classpath and URL ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Pro Spring&lt;br /&gt;
By Rob Harrop&lt;br /&gt;
Jan Machacek&lt;br /&gt;
ISBN: 1-59059-461-4&lt;br /&gt;
Publisher: Apress&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
//File: events.xml&lt;br /&gt;
&amp;lt;!DOCTYPE beans PUBLIC &amp;quot;-//SPRING//DTD BEAN//EN&amp;quot; &amp;quot;http://www.springframework.org/dtd/spring-beans.dtd&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;beans&amp;gt;&lt;br /&gt;
    &amp;lt;bean id=&amp;quot;publisher&amp;quot; class=&amp;quot;Publisher&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;bean id=&amp;quot;messageEventListener&amp;quot; class=&amp;quot;MessageEventListener&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/beans&amp;gt;&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
import org.springframework.context.ApplicationEvent;&lt;br /&gt;
&lt;br /&gt;
public class MessageEvent extends ApplicationEvent {&lt;br /&gt;
    private String msg;&lt;br /&gt;
    public MessageEvent(Object source, String msg) {&lt;br /&gt;
        super(source);&lt;br /&gt;
        this.msg = msg;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public String getMessage() {&lt;br /&gt;
        return msg;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
import org.springframework.context.ApplicationEvent;&lt;br /&gt;
import org.springframework.context.ApplicationListener;&lt;br /&gt;
public class MessageEventListener implements ApplicationListener {&lt;br /&gt;
   &lt;br /&gt;
    public void onApplicationEvent(ApplicationEvent event) {&lt;br /&gt;
       if(event instanceof MessageEvent) {&lt;br /&gt;
           MessageEvent msgEvt = (MessageEvent)event;&lt;br /&gt;
           System.out.println(&amp;quot;Received: &amp;quot; + msgEvt.getMessage());&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
import org.springframework.beans.BeansException;&lt;br /&gt;
import org.springframework.context.ApplicationContext;&lt;br /&gt;
import org.springframework.context.ApplicationContextAware;&lt;br /&gt;
import org.springframework.context.support.FileSystemXmlApplicationContext;&lt;br /&gt;
public class Publisher implements ApplicationContextAware {&lt;br /&gt;
    private ApplicationContext ctx;&lt;br /&gt;
    public static void main(String[] args) {&lt;br /&gt;
        ApplicationContext ctx = new FileSystemXmlApplicationContext(&lt;br /&gt;
                &amp;quot;build/events.xml&amp;quot;);&lt;br /&gt;
        Publisher pub = (Publisher) ctx.getBean(&amp;quot;publisher&amp;quot;);&lt;br /&gt;
        pub.publish(&amp;quot;Hello World!&amp;quot;);&lt;br /&gt;
        pub.publish(&amp;quot;The quick brown fox jumped over the lazy dog&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public void setApplicationContext(ApplicationContext applicationContext)&lt;br /&gt;
            throws BeansException {&lt;br /&gt;
        this.ctx = applicationContext;&lt;br /&gt;
    }&lt;br /&gt;
    public void publish(String message) {&lt;br /&gt;
        ctx.publishEvent(new MessageEvent(this, message));&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
import org.springframework.context.ApplicationContext;&lt;br /&gt;
import org.springframework.context.support.FileSystemXmlApplicationContext;&lt;br /&gt;
import org.springframework.core.io.Resource;&lt;br /&gt;
public class ResourceDemo {&lt;br /&gt;
    public static void main(String[] args) throws Exception{&lt;br /&gt;
        ApplicationContext ctx = new FileSystemXmlApplicationContext(&lt;br /&gt;
        &amp;quot;build/events.xml&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
        Resource res1 = ctx.getResource(&amp;quot;file:///c:/test.txt&amp;quot;);&lt;br /&gt;
        displayInfo(res1);&lt;br /&gt;
        Resource res2 = ctx.getResource(&amp;quot;classpath:lib/commons-logging.jar&amp;quot;);&lt;br /&gt;
        displayInfo(res2);&lt;br /&gt;
        Resource res3 = ctx.getResource(&amp;quot;http://www.google.co.uk&amp;quot;);&lt;br /&gt;
        displayInfo(res3);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    private static void displayInfo(Resource res) throws Exception{&lt;br /&gt;
        System.out.println(res.getClass());&lt;br /&gt;
        System.out.println(res.getURL().getContent());&lt;br /&gt;
        System.out.println(&amp;quot;&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>