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.hello;
8
9 /**
10 * <code>Greeter</code> expects a valid <code>NameString</code> object. If invalid,
11 * an exception is created and returned. The outbound router will filter exceptions
12 * as user errors and return the messages to the original requester accordingly.
13 */
14 public class Greeter
15 {
16 private String greeting = "";
17
18 public Greeter()
19 {
20 greeting = LocaleMessage.getGreetingPart1();
21 }
22
23 public Object greet(NameString person)
24 {
25 Object payload = person;
26 if (person.isValid())
27 {
28 person.setGreeting(greeting);
29 }
30 else
31 {
32 payload = new Exception(LocaleMessage.getInvalidUserNameError());
33 }
34 return payload;
35 }
36 }