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