01: /*
02: * $Id: ExpressionEvaluatorProcessor.java 11282 2008-03-08 21:08:08Z rossmason $
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: package org.mule.registry;
11:
12: import org.mule.api.lifecycle.Disposable;
13: import org.mule.api.registry.ObjectProcessor;
14: import org.mule.util.expression.ExpressionEvaluator;
15: import org.mule.util.expression.ExpressionEvaluatorManager;
16:
17: /**
18: * Registers ExpressionEvaluators with the {@link org.mule.util.expression.ExpressionEvaluatorManager} so that they will
19: * be resolved at run-time.
20: * {@link org.mule.util.expression.ExpressionEvaluator} objects are used to execute property expressions (usually on the
21: * current message) at run-time to extract a dynamic value.
22: */
23: public class ExpressionEvaluatorProcessor implements ObjectProcessor,
24: Disposable {
25: public ExpressionEvaluatorProcessor() {
26: ExpressionEvaluatorManager.clearEvaluators();
27: }
28:
29: public Object process(Object object) {
30: if (object instanceof ExpressionEvaluator) {
31: ExpressionEvaluatorManager
32: .registerEvaluator((ExpressionEvaluator) object);
33: }
34: return object;
35: }
36:
37: /**
38: * A lifecycle method where implementor should free up any resources. If an
39: * exception is thrown it should just be logged and processing should continue.
40: * This method should not throw Runtime exceptions.
41: */
42: public void dispose() {
43: ExpressionEvaluatorManager.clearEvaluators();
44: }
45: }
|