01: /*
02: * $Id: Greeter.java 10789 2008-02-12 20:04:43Z dfeist $
03: * --------------------------------------------------------------------------------------
04: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
05: *
06: * The software in this package is published under the terms of the CPAL v1.0
07: * license, a copy of which has been included with this distribution in the
08: * LICENSE.txt file.
09: */
10:
11: package org.mule.example.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: private String greeting = "";
20:
21: public Greeter() {
22: greeting = LocaleMessage.getGreetingPart1();
23: }
24:
25: public Object greet(NameString person) {
26: Object payload = person;
27: if (person.isValid()) {
28: person.setGreeting(greeting);
29: } else {
30: payload = new Exception(LocaleMessage
31: .getInvalidUserNameError());
32: }
33: return payload;
34: }
35: }
|