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

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Spring/Spring_Properties&amp;diff=6555&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Spring/Spring_Properties&amp;diff=6555&amp;oldid=prev"/>
				<updated>2010-06-01T06:16:29Z</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://jexp.ru/index.php?title=Java/Spring/Spring_Properties&amp;diff=6554&amp;oldid=prev</id>
		<title> в 18:01, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Spring/Spring_Properties&amp;diff=6554&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;== DependencyPull 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;
File: context.properties&lt;br /&gt;
source.(class)=SimpleMessageData&lt;br /&gt;
destination.(class)=StdoutMessageReporter&lt;br /&gt;
service.(class)=DefaultMessageService&lt;br /&gt;
service.source(ref)=source&lt;br /&gt;
service.destination(ref)=destination&lt;br /&gt;
&lt;br /&gt;
File: Main.java&lt;br /&gt;
import org.springframework.beans.factory.support.BeanDefinitionReader;&lt;br /&gt;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;&lt;br /&gt;
import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader;&lt;br /&gt;
import org.springframework.core.io.ClassPathResource;&lt;br /&gt;
import org.springframework.util.Assert;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();&lt;br /&gt;
    BeanDefinitionReader reader = new PropertiesBeanDefinitionReader(bf);&lt;br /&gt;
    reader.loadBeanDefinitions(new ClassPathResource(&amp;quot;context.properties&amp;quot;));&lt;br /&gt;
    MessageService service = (MessageService) bf.getBean(&amp;quot;service&amp;quot;);&lt;br /&gt;
    service.execute();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class DependantComponent {&lt;br /&gt;
  private MessageService service;&lt;br /&gt;
  public DependantComponent(MessageService service) {&lt;br /&gt;
    Assert.notNull(service, &amp;quot;The &amp;quot;service&amp;quot; argument must not be null.&amp;quot;);&lt;br /&gt;
    this.service = service;&lt;br /&gt;
  }&lt;br /&gt;
  public void run() {&lt;br /&gt;
    this.service.execute();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
interface MessageService {&lt;br /&gt;
  void execute();&lt;br /&gt;
}&lt;br /&gt;
class DefaultMessageService implements MessageService {&lt;br /&gt;
  private MessageData source;&lt;br /&gt;
  private MessageReporter destination;&lt;br /&gt;
  public void execute() {&lt;br /&gt;
    this.destination.write(this.source.getMessage());&lt;br /&gt;
  }&lt;br /&gt;
  public void setSource(MessageData source) {&lt;br /&gt;
    this.source = source;&lt;br /&gt;
  }&lt;br /&gt;
  public void setDestination(MessageReporter destination) {&lt;br /&gt;
    this.destination = destination;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
interface MessageReporter {&lt;br /&gt;
  void write(String message);&lt;br /&gt;
}&lt;br /&gt;
interface MessageData {&lt;br /&gt;
  String getMessage();&lt;br /&gt;
}&lt;br /&gt;
class StdoutMessageReporter implements MessageReporter {&lt;br /&gt;
  public void write(String message) {&lt;br /&gt;
    System.out.println(message);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class SimpleMessageData implements MessageData {&lt;br /&gt;
  private final String message;&lt;br /&gt;
  public SimpleMessageData() {&lt;br /&gt;
    this(&amp;quot;Hello, world&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public SimpleMessageData(String message) {&lt;br /&gt;
    this.message = message;&lt;br /&gt;
  }&lt;br /&gt;
  public String getMessage() {&lt;br /&gt;
    return this.message;&lt;br /&gt;
  }&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;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== IOC With Properties File ==&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;
File: context.properties&lt;br /&gt;
source.(class)=SimpleMessageData&lt;br /&gt;
destination.(class)=StdoutMessageReporter&lt;br /&gt;
service.(class)=DefaultMessageService&lt;br /&gt;
service.source(ref)=source&lt;br /&gt;
service.destination(ref)=destination&lt;br /&gt;
&lt;br /&gt;
File: Main.java&lt;br /&gt;
import org.springframework.beans.factory.support.BeanDefinitionReader;&lt;br /&gt;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;&lt;br /&gt;
import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader;&lt;br /&gt;
import org.springframework.core.io.ClassPathResource;&lt;br /&gt;
import org.springframework.util.Assert;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    &lt;br /&gt;
      &lt;br /&gt;
      DefaultListableBeanFactory bf = new DefaultListableBeanFactory();&lt;br /&gt;
      BeanDefinitionReader reader = new PropertiesBeanDefinitionReader(bf);&lt;br /&gt;
      reader.loadBeanDefinitions(new ClassPathResource(&amp;quot;context.properties&amp;quot;));&lt;br /&gt;
   &lt;br /&gt;
      MessageService service = (MessageService) bf.getBean(&amp;quot;service&amp;quot;);&lt;br /&gt;
    DependantComponent dc = new DependantComponent(service);&lt;br /&gt;
    dc.run();&lt;br /&gt;
    &lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class DependantComponent {&lt;br /&gt;
  private MessageService service;&lt;br /&gt;
  public DependantComponent(MessageService service) {&lt;br /&gt;
      Assert.notNull(service, &amp;quot;The &amp;quot;service&amp;quot; argument must not be null.&amp;quot;);&lt;br /&gt;
      this.service = service;&lt;br /&gt;
  }&lt;br /&gt;
  public void run() {&lt;br /&gt;
      this.service.execute();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
interface MessageService {&lt;br /&gt;
  void execute();&lt;br /&gt;
}&lt;br /&gt;
class DefaultMessageService implements MessageService {&lt;br /&gt;
  private MessageData source;&lt;br /&gt;
  private MessageReporter destination;&lt;br /&gt;
  public void execute() {&lt;br /&gt;
      this.destination.write(this.source.getMessage());&lt;br /&gt;
  }&lt;br /&gt;
  public void setSource(MessageData source) {&lt;br /&gt;
      this.source = source;&lt;br /&gt;
  }&lt;br /&gt;
  public void setDestination(MessageReporter destination) {&lt;br /&gt;
      this.destination = destination;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
interface MessageReporter {&lt;br /&gt;
  void write(String message);&lt;br /&gt;
}&lt;br /&gt;
interface MessageData {&lt;br /&gt;
  String getMessage();&lt;br /&gt;
}&lt;br /&gt;
class StdoutMessageReporter implements MessageReporter {&lt;br /&gt;
  public void write(String message) {&lt;br /&gt;
    System.out.println(message);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class SimpleMessageData implements MessageData {&lt;br /&gt;
  private final String message;&lt;br /&gt;
  public SimpleMessageData() {&lt;br /&gt;
    this(&amp;quot;Hello, world&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public SimpleMessageData(String message) {&lt;br /&gt;
    this.message = message;&lt;br /&gt;
  }&lt;br /&gt;
  public String getMessage() {&lt;br /&gt;
    return this.message;&lt;br /&gt;
  }&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;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Property File based Bean Injection ==&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;
File: context.properties&lt;br /&gt;
oracle.(class)=BookwormOracle&lt;br /&gt;
encyclopedia.(class)=HardcodedEncyclopedia&lt;br /&gt;
oracle.encyclopedia(ref)=encyclopedia&lt;br /&gt;
&lt;br /&gt;
File: Main.java&lt;br /&gt;
import java.util.HashMap;&lt;br /&gt;
import java.util.Map;&lt;br /&gt;
import org.springframework.beans.factory.support.BeanDefinitionReader;&lt;br /&gt;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;&lt;br /&gt;
import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader;&lt;br /&gt;
import org.springframework.core.io.ClassPathResource;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] a) {&lt;br /&gt;
    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();&lt;br /&gt;
    BeanDefinitionReader reader = new PropertiesBeanDefinitionReader(bf);&lt;br /&gt;
    reader.loadBeanDefinitions(new ClassPathResource(&amp;quot;context.properties&amp;quot;));&lt;br /&gt;
    Oracle oracle = (Oracle) bf.getBean(&amp;quot;oracle&amp;quot;);&lt;br /&gt;
    System.out.println(&amp;quot;Meaning of life is &amp;quot; + oracle.defineMeaningOfLife());&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
interface Oracle {&lt;br /&gt;
  String defineMeaningOfLife();&lt;br /&gt;
}&lt;br /&gt;
interface Encyclopedia {&lt;br /&gt;
  Long findLong(String entry);&lt;br /&gt;
  &lt;br /&gt;
}&lt;br /&gt;
class BookwormOracle implements Oracle {&lt;br /&gt;
  private Encyclopedia encyclopedia;&lt;br /&gt;
  public String defineMeaningOfLife() {&lt;br /&gt;
      Long ageOfUniverse = this.encyclopedia.findLong(&amp;quot;AgeOfUniverse&amp;quot;);&lt;br /&gt;
      Long constantOfLife = this.encyclopedia.findLong(&amp;quot;ConstantOfLife&amp;quot;);&lt;br /&gt;
      return String.valueOf(ageOfUniverse / constantOfLife);&lt;br /&gt;
  }&lt;br /&gt;
  public void setEncyclopedia(Encyclopedia encyclopedia) {&lt;br /&gt;
      this.encyclopedia = encyclopedia;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class HardcodedEncyclopedia implements Encyclopedia {&lt;br /&gt;
  private Map&amp;lt;String, Long&amp;gt; entryValues = new HashMap&amp;lt;String, Long&amp;gt;();&lt;br /&gt;
  public HardcodedEncyclopedia() {&lt;br /&gt;
      this.entryValues.put(&amp;quot;AgeOfUniverse&amp;quot;, 13700000000L);&lt;br /&gt;
      this.entryValues.put(&amp;quot;ConstantOfLife&amp;quot;, 326190476L);&lt;br /&gt;
  }&lt;br /&gt;
  public Long findLong(String entry) {&lt;br /&gt;
      return this.entryValues.get(entry);&lt;br /&gt;
  }&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;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Spring Properties File Based Data Injection ==&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;
File: helloworld-context.properties&lt;br /&gt;
source.(class)=SimpleMessageData&lt;br /&gt;
destination.(class)=StdoutMessageReporter&lt;br /&gt;
service.(class)=DefaultMessageService&lt;br /&gt;
service.source(ref)=source&lt;br /&gt;
service.destination(ref)=destination&lt;br /&gt;
&lt;br /&gt;
File: Main.java&lt;br /&gt;
import org.springframework.beans.factory.support.BeanDefinitionReader;&lt;br /&gt;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;&lt;br /&gt;
import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader;&lt;br /&gt;
import org.springframework.core.io.ClassPathResource;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] a) {&lt;br /&gt;
    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();&lt;br /&gt;
    BeanDefinitionReader reader = new PropertiesBeanDefinitionReader(bf);&lt;br /&gt;
    reader.loadBeanDefinitions(new ClassPathResource(&amp;quot;helloworld-context.properties&amp;quot;));&lt;br /&gt;
    MessageService service = (MessageService) bf.getBean(&amp;quot;service&amp;quot;);&lt;br /&gt;
    service.execute();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
interface MessageService {&lt;br /&gt;
  void execute();&lt;br /&gt;
}&lt;br /&gt;
class DefaultMessageService implements MessageService {&lt;br /&gt;
  private MessageData source;&lt;br /&gt;
  private MessageReporter destination;&lt;br /&gt;
  public void execute() {&lt;br /&gt;
      this.destination.write(this.source.getMessage());&lt;br /&gt;
  }&lt;br /&gt;
  public void setSource(MessageData source) {&lt;br /&gt;
      this.source = source;&lt;br /&gt;
  }&lt;br /&gt;
  public void setDestination(MessageReporter destination) {&lt;br /&gt;
      this.destination = destination;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
interface MessageReporter {&lt;br /&gt;
  void write(String message);&lt;br /&gt;
}&lt;br /&gt;
interface MessageData {&lt;br /&gt;
  String getMessage();&lt;br /&gt;
}&lt;br /&gt;
class StdoutMessageReporter implements MessageReporter {&lt;br /&gt;
  public void write(String message) {&lt;br /&gt;
    System.out.println(message);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class SimpleMessageData implements MessageData {&lt;br /&gt;
  private final String message;&lt;br /&gt;
  public SimpleMessageData() {&lt;br /&gt;
    this(&amp;quot;Hello, world&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public SimpleMessageData(String message) {&lt;br /&gt;
    this.message = message;&lt;br /&gt;
  }&lt;br /&gt;
  public String getMessage() {&lt;br /&gt;
    return this.message;&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>