1 package org.apache.stratum.messenger;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 import org.apache.commons.configuration.Configuration;
21 import org.apache.commons.messenger.MessengerManager;
22 import org.apache.stratum.lifecycle.Configurable;
23 import org.apache.stratum.lifecycle.Initializable;
24
25 /***
26 * This class is the Messenger component. It is an adaptor that allows the ComponentLoader to startup MessengerManager. Client
27 * code wishing to use Messenger should ask MessengerManager directly for Messenger instances.
28 *
29 * @author <a href="mailto:eric@dobbse.net">Eric Dobbs</a>
30 * @version $Id: MessengerComponent.java 264191 2005-08-29 18:07:52Z henning $
31 *
32 * @see org.apache.commons.messenger.MessengerManager
33 * @see org.apache.commons.messenger.Messenger
34 */
35 public class MessengerComponent
36 implements Configurable, Initializable
37 {
38 /*** The key for property 'messenger.xml.url' */
39 private static final String MESSENGER_XML_URL = "messenger.xml.url";
40
41 /*** The location of the Messenger.xml file */
42 private String messengerXmlUrl;
43
44 /***
45 * Configure MessengerManager. MessengerManager requires a URL to a Messenger.xml file. The messenger.properties file should
46 * define one property named 'messenger.xml.url' identifying the location of Messenger.xml.
47 *
48 * @param configuration Configuration object containing the 'messenger.xml.url' property
49 */
50 public void configure(Configuration configuration)
51 {
52 messengerXmlUrl = configuration.getString(MESSENGER_XML_URL);
53 }
54
55 /***
56 * Initialize the MessengerManager.
57 *
58 * @exception Exception is thrown if the file defined in 'messenger.xml.url' can't be found. JMSException will be thrown if
59 * MessengerManager.configure is unhappy with the value from 'messenger.xml.url'
60 */
61 public void initialize()
62 throws Exception
63 {
64 if (messengerXmlUrl == null)
65 {
66 throw new Exception("Can't find property '" + MESSENGER_XML_URL + "' in the properties file");
67 }
68
69 MessengerManager.configure(messengerXmlUrl);
70 }
71 }