View Javadoc

1   /*
2    * $Id: LocaleMessage.java 7963 2007-08-21 08:53:15Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.samples.errorhandler;
12  
13  import org.mule.config.i18n.MessageFactory;
14  import org.mule.util.ObjectUtils;
15  import org.mule.util.StringMessageUtils;
16  
17  /**
18   * <code>LocaleMessage</code> is a convenience interface for retrieving
19   * internationalised strings from resource bundles. The actual work is done by
20   * the MessageFactory in core.
21   */
22  public class LocaleMessage extends MessageFactory
23  {
24      private static final String BUNDLE_PATH = "messages.errorhandler-example-messages";
25  
26      public static String unretrievedException(Exception e)
27      {
28          return getString(BUNDLE_PATH, 1, e);
29      }
30  
31      public static String unhandledException(Class class1, Class class2)
32      {
33          return getString(BUNDLE_PATH, 2, StringMessageUtils.toString(class1), 
34              StringMessageUtils.toString(class2));
35      }
36  
37      public static String businessErrorManagerError()
38      {
39          return getString(BUNDLE_PATH, 3);
40      }
41  
42      public static String errorDetail(String detailMessage)
43      {
44          return getString(BUNDLE_PATH, 4, detailMessage);
45      }
46  
47      public static String errorClass(Class class1)
48      {
49          return getString(BUNDLE_PATH, 5, class1.getName());
50      }
51  
52      public static String handlerFailure(ExceptionHandler eh)
53      {
54          String handlerDescription = ObjectUtils.toString(eh.getClass().getName(), "null");
55          return getString(BUNDLE_PATH, 6, handlerDescription);
56      }
57  
58      public static String defaultFatalHandling(Class class1)
59      {
60          return getString(BUNDLE_PATH, 7, StringMessageUtils.toString(class1));
61      }
62  
63      public static String fatalHandling(Exception e)
64      {
65          return getString(BUNDLE_PATH, 8, e);
66      }
67  
68      public static String defaultHandling(Class class1, ExceptionHandler eh, Exception e)
69      {
70          return getString(BUNDLE_PATH, 9, StringMessageUtils.toString(class1),
71              ObjectUtils.toString(eh.getClass().getName() + " : " + e, "null"));
72      }
73  
74      public static String defaultException(Exception e)
75      {
76          return getString(BUNDLE_PATH, 10, e);
77      }
78  
79      public static String defaultHandlerException(HandlerException e)
80      {
81          return getString(BUNDLE_PATH, 11, e);
82      }
83  
84      public static String fatalException(Throwable t)
85      {
86          return getString(BUNDLE_PATH, 12, t);
87      }
88  
89      public static String businessHandlerMessage()
90      {
91          return getString(BUNDLE_PATH, 13);
92      }
93  
94      public static String defaultHandlerMessage()
95      {
96          return getString(BUNDLE_PATH, 14);
97      }
98  
99      public static String fatalHandlerMessage()
100     {
101         return getString(BUNDLE_PATH, 15);
102     }
103 
104     public static String fatalHandlerException(Throwable t)
105     {
106         return getString(BUNDLE_PATH, 16, t);
107     }
108 }