Local Reference : XML Bean « Spring « Java

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Class
8. Collections Data Structure
9. Data Type
10. Database SQL JDBC
11. Design Pattern
12. Development Class
13. EJB3
14. Email
15. Event
16. File Input Output
17. Game
18. Generics
19. GWT
20. Hibernate
21. I18N
22. J2EE
23. J2ME
24. JDK 6
25. JNDI LDAP
26. JPA
27. JSP
28. JSTL
29. Language Basics
30. Network Protocol
31. PDF RTF
32. Reflection
33. Regular Expressions
34. Scripting
35. Security
36. Servlets
37. Spring
38. Swing Components
39. Swing JFC
40. SWT JFace Eclipse
41. Threads
42. Tiny Application
43. Velocity
44. Web Services SOA
45. XML
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java » Spring » XML BeanScreenshots 
Local Reference

File: context.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
 "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>

  <bean id="weatherService" class="WeatherServiceImpl">
    <property name="weatherDao">
      <ref local="weatherDao"/>
    </property>
  </bean>

  <bean id="weatherDao" class="StaticDataWeatherDaoImpl">
  </bean>

</beans>


File: Main.java

import java.util.Date;
import java.util.GregorianCalendar;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

class Main {
  public static void main(String args[]) throws Exception {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("context.xml");
    WeatherService ws = (WeatherServicectx.getBean("weatherService");

    Double high = ws.getHistoricalHigh(new GregorianCalendar(200401).getTime());

    System.out.println("High was: " + high);
  }
}

class StaticDataWeatherDaoImpl implements WeatherDao {
  public WeatherData find(Date date) {
    WeatherData wd = new WeatherData();
    wd.setDate((Datedate.clone());
    return wd;
  }

  public WeatherData save(Date date) {
    System.out.println("save");
    return null;
  }

  public WeatherData update(Date date) {
    System.out.println("update");
    return null;
  }
}

interface WeatherService {
  Double getHistoricalHigh(Date date);
}

class WeatherServiceImpl implements WeatherService {
  private WeatherDao weatherDao;

  public void setWeatherDao(WeatherDao weatherDao) {
    this.weatherDao = weatherDao;
  }

  public Double getHistoricalHigh(Date date) {
    return null;
  }
}

interface WeatherDao {
  WeatherData find(Date date);

  WeatherData save(Date date);

  WeatherData update(Date date);
}

class WeatherData {

  Date date;


  public Date getDate() {
    return date;
  }

  public void setDate(Date date) {
    this.date = date;
  }


}




           
       
Spring-LocalReference.zip( 2,895 k)
Related examples in the same category
1. XML Bean Injection
2. Reference another bean and set property
3. Static Factory
4. Serach By Base Package
5. throw RequiredPropertyNotSetException
6. Properties File Based Spring Bean
7. Non Static Factory
8. Link With DataSource
9. Inheritance Demo
10. HierarchicalBeanFactory Demo
11. Filtered By Annotation
12. destroy method
13. dependency check Demo
14. Custom InitializationMethod
15. component scan
16. Component Scan and scope
17. Component Filter Assignable
18. implements BeanNameAware
19. Bean Lifecycle Initializing
20. Bean Lifecycle DisposableBean
21. Autowiring
22. Alias Bean Demo
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.