Changes

Jump to: navigation, search

Teams Winter 2011/team2/project

3,813 bytes added, 17:50, 16 April 2011
no edit summary
For this project, we are going to create a weather service program using the osgi framework. This project will contain three bundles: Consumer, Interface and Provider bundles. The Interface bundle will contain a set of interface and classes used by both Consumer and Provider. The Provider bundle will provide a service to return weather information for a selected city. The Consumer bundle will use the service reference to get weather information from the Provider and display in a GUI window based on Java Swing Library.
==Prerequisites==
*Download [http://www.eclipse.org/downloads/packages/eclipse-classic-362/heliossr2 Eclipse]
 
==Steps==
=Prepare eclipse=
</syntaxhighlight>
2. Provider's implementation. The provider's implementation class WeatherImplementation.java uses a webservice from http://www.worldweatheronline.com/ get weather information. You will need to subscribe to their website to get an apikey to request and get weather information. Worldweatheronline.com provides data in both json and xml. We will use xml format in this project.
Thanks to http://www.java-tips.org/java-se-tips/javax.xml.parsers/how-to-read-xml-file-in-java.html for the tips on parsing xml.
<syntaxhighlight lang="java">
}
</syntaxhighlight>
 
 
3. XML Format of weather received.
<syntaxhighlight lang="xml">
 
<?xml version="1.0" encoding="UTF-8"?>
<data>
<request>
<type>City</type>
<query>Toronto, Canada</query>
</request>
<current_condition>
<observation_time>09:14 PM</observation_time>
<temp_C>4</temp_C>
<temp_F>39</temp_F>
<weatherCode>296</weatherCode>
<weatherIconUrl><![CDATA[http://www.worldweatheronline.com/images/wsymbols01_png_64/wsymbol_0017_cloudy_with_light_rain.png]]></weatherIconUrl>
<weatherDesc><![CDATA[Light rain]]></weatherDesc>
<windspeedMiles>30</windspeedMiles>
<windspeedKmph>48</windspeedKmph>
<winddirDegree>70</winddirDegree>
<winddir16Point>ENE</winddir16Point>
<precipMM>5.2</precipMM>
<humidity>93</humidity>
<visibility>10</visibility>
<pressure>1001</pressure>
<cloudcover>100</cloudcover>
</current_condition>
<weather>
<date>2011-04-16</date>
<tempMaxC>8</tempMaxC>
<tempMaxF>47</tempMaxF>
<tempMinC>2</tempMinC>
<tempMinF>36</tempMinF>
<windspeedMiles>27</windspeedMiles>
<windspeedKmph>43</windspeedKmph>
<winddirection>E</winddirection>
<winddir16Point>E</winddir16Point>
<winddirDegree>92</winddirDegree>
<weatherCode>302</weatherCode>
<weatherIconUrl><![CDATA[http://www.worldweatheronline.com/images/wsymbols01_png_64/wsymbol_0018_cloudy_with_heavy_rain.png]]></weatherIconUrl>
<weatherDesc><![CDATA[Moderate rain]]></weatherDesc>
<precipMM>25.5</precipMM>
</weather>
<weather>
<date>2011-04-17</date>
<tempMaxC>6</tempMaxC>
<tempMaxF>42</tempMaxF>
<tempMinC>0</tempMinC>
<tempMinF>32</tempMinF>
<windspeedMiles>26</windspeedMiles>
<windspeedKmph>42</windspeedKmph>
<winddirection>WSW</winddirection>
<winddir16Point>WSW</winddir16Point>
<winddirDegree>239</winddirDegree>
<weatherCode>116</weatherCode>
<weatherIconUrl><![CDATA[http://www.worldweatheronline.com/images/wsymbols01_png_64/wsymbol_0002_sunny_intervals.png]]></weatherIconUrl>
<weatherDesc><![CDATA[Partly Cloudy ]]></weatherDesc>
<precipMM>0.4</precipMM>
</weather>
<weather>
<date>2011-04-18</date>
<tempMaxC>10</tempMaxC>
<tempMaxF>49</tempMaxF>
<tempMinC>-1</tempMinC>
<tempMinF>31</tempMinF>
<windspeedMiles>21</windspeedMiles>
<windspeedKmph>33</windspeedKmph>
<winddirection>SW</winddirection>
<winddir16Point>SW</winddir16Point>
<winddirDegree>231</winddirDegree>
<weatherCode>113</weatherCode>
<weatherIconUrl><![CDATA[http://www.worldweatheronline.com/images/wsymbols01_png_64/wsymbol_0001_sunny.png]]></weatherIconUrl>
<weatherDesc><![CDATA[Sunny]]></weatherDesc>
<precipMM>0.0</precipMM>
</weather>
<weather>
<date>2011-04-19</date>
<tempMaxC>4</tempMaxC>
<tempMaxF>39</tempMaxF>
<tempMinC>1</tempMinC>
<tempMinF>34</tempMinF>
<windspeedMiles>23</windspeedMiles>
<windspeedKmph>36</windspeedKmph>
<winddirection>NE</winddirection>
<winddir16Point>NE</winddir16Point>
<winddirDegree>39</winddirDegree>
<weatherCode>122</weatherCode>
<weatherIconUrl><![CDATA[http://www.worldweatheronline.com/images/wsymbols01_png_64/wsymbol_0004_black_low_cloud.png]]></weatherIconUrl>
<weatherDesc><![CDATA[Overcast ]]></weatherDesc>
<precipMM>13.9</precipMM>
</weather>
</data>
</syntaxhighlight>
[[Image:ecl500_team2-project_output1project_output01.png]]
[[Image:ecl500_team2-project_output2project_output02.png]]
[[Image:ecl500_team2-project_output3project_output03.png]]
1
edit

Navigation menu