Source Code : Local Reference

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

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 = (WeatherService) ctx.getBean("weatherService");

    Double high = ws.getHistoricalHigh(new GregorianCalendar(2004, 0, 1).getTime());

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

class StaticDataWeatherDaoImpl implements WeatherDao {
  public WeatherData find(Date date) {
    WeatherData wd = new WeatherData();
    wd.setDate((Date) date.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;
  }


}




           
       

Thank with us