View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.example.stockquote;
8   
9   import org.mule.config.i18n.MessageFactory;
10  
11  /**
12   * <code>LocaleMessage</code> is a convenience interface for retrieving
13   * internationalised strings from resource bundles. The actual work is done by
14   * the {@link MessageFactory} in core.
15   */
16  public class LocaleMessage extends MessageFactory
17  {
18      private static final LocaleMessage factory = new LocaleMessage();
19      
20      /**
21       * Note that the messages for this example are not in mule's standard
22       * META-INF/services/org/mule/i18n folder but in a different resource bundle.
23       */
24      private static final String BUNDLE_PATH = "messages.stockquote-example-messages";
25  
26      public static String getStockQuoteMessage(String symbol, String name, String date, String last, 
27          String change, String open, String high, String low, String volume, String previousClose)
28      {
29          String[] params = { symbol, name, date, last, change, open, high,
30              low, volume, previousClose };
31          return factory.getString(BUNDLE_PATH, 1, params);
32      }
33  
34      @Override
35      protected ClassLoader getClassLoader()
36      {
37          return getClass().getClassLoader();
38      }
39  }