Class WeatherComponent

java.lang.Object
org.xmpp.component.AbstractComponent
org.jivesoftware.weather.WeatherComponent
All Implemented Interfaces:
org.xmpp.component.Component

public class WeatherComponent extends org.xmpp.component.AbstractComponent
This component provides weather information obtained from http://weather.noaa.gov. Each request will generate an HTTP request to the above URL. The JWeather library was used for getting weather information in the METAR format.

Note: This code shouldn't be considered ready for production since it generate an HTTP request for each received request. Therefore, it won't scale much.

Author:
Gaston Dombiak
  • Field Summary

    Fields inherited from class org.xmpp.component.AbstractComponent

    compMan, jid, NAMESPACE_DISCO_INFO, NAMESPACE_DISCO_ITEMS, NAMESPACE_ENTITY_TIME, NAMESPACE_LAST_ACTIVITY, NAMESPACE_XMPP_PING
  • Constructor Summary

    Constructors
    Constructor
    Description
    WeatherComponent(String name, String serverDomain)
    Create a new component which provides weather information.
  • Method Summary

    Modifier and Type
    Method
    Description
     
     
     
    protected void
    handleMessage(org.xmpp.packet.Message message)
    Handle a receied message and answer the weather information of the requested station id.

    Methods inherited from class org.xmpp.component.AbstractComponent

    discoInfoFeatureNamespaces, discoInfoIdentityCategory, discoInfoIdentityCategoryType, getJID, handleDiscoInfo, handleDiscoItems, handleEntityTime, handleIQError, handleIQGet, handleIQResult, handleIQSet, handleLastActivity, handlePing, handlePresence, initialize, postComponentShutdown, postComponentStart, preComponentShutdown, preComponentStart, processPacket, send, servesLocalUsersOnly, shutdown, start

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • WeatherComponent

      public WeatherComponent(String name, String serverDomain)
      Create a new component which provides weather information.
      Parameters:
      name - The name of this component.
      serverDomain - The XMPP domain to which this component is registered to.
  • Method Details

    • getName

      public String getName()
      Specified by:
      getName in interface org.xmpp.component.Component
      Specified by:
      getName in class org.xmpp.component.AbstractComponent
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in interface org.xmpp.component.Component
      Specified by:
      getDescription in class org.xmpp.component.AbstractComponent
    • getDomain

      public String getDomain()
      Overrides:
      getDomain in class org.xmpp.component.AbstractComponent
    • handleMessage

      protected void handleMessage(org.xmpp.packet.Message message)
      Handle a receied message and answer the weather information of the requested station id. The request must be made using Message packets where the body of the message should be the station id.

      Note: I don't know the list of valid station ids so if you find the list please send it to me so I can add it to this example.

      Overrides:
      handleMessage in class org.xmpp.component.AbstractComponent
      Parameters:
      message - the Message requesting information about a certain station id.