Simple Weather Source Code
The simple weather command-line application consists of the following five Java classes:
org.sonatype.mavenbook.weather.MainThe
Mainclass contains a staticmain()function, and is the entry point for this system.org.sonatype.mavenbook.weather.WeatherThe
Weatherclass is a straightforward Java bean that holds the location of our weather report and some key facts, such as the temperature and humidity.org.sonatype.mavenbook.weather.YahooRetrieverThe
YahooRetrieverclass connects to Yahoo! Weather and returns anInputStreamof the data from the feed.org.sonatype.mavenbook.weather.YahooParserThe
YahooParserclass parses the XML from Yahoo! Weather, and returns aWeatherobject.org.sonatype.mavenbook.weather.WeatherFormatterThe
WeatherFormatterclass takes aWeatherobject, creates aVelocityContext, and evaluates a Velocity template.
Although we won’t dwell on the code here, we will provide all
the necessary code for you to get the example working. We assume that
most readers have downloaded the examples that accompany this book,
but we’re also mindful of those who may wish to follow the example in
this chapter step-by-step. The sections that follow list classes in
the simple-weather project. Each of these classes
should be placed in the same package:
org.sonatype.mavenbook.weather.
Let’s remove the App and the
AppTest classes created by
archetype:create and add our new package. In a
Maven project, all of a project’s source code is stored in src/main/java. From ...