Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
LifecycleStateInjectorProcessor |
|
| 1.5;1.5 |
1 | /* | |
2 | * $Id: LifecycleStateInjectorProcessor.java 19191 2010-08-25 21:05:23Z tcarlson $ | |
3 | * -------------------------------------------------------------------------------------- | |
4 | * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.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 | package org.mule.registry; | |
11 | ||
12 | import org.mule.api.MuleContext; | |
13 | import org.mule.api.context.MuleContextAware; | |
14 | import org.mule.api.lifecycle.LifecycleState; | |
15 | import org.mule.api.lifecycle.LifecycleStateAware; | |
16 | import org.mule.api.registry.InjectProcessor; | |
17 | import org.mule.api.registry.RegistrationException; | |
18 | ||
19 | /** | |
20 | * Injects the MuleContext object for objects stored in the {@link org.mule.registry.TransientRegistry} where the object registered | |
21 | * implements {@link org.mule.api.context.MuleContextAware}. | |
22 | */ | |
23 | public class LifecycleStateInjectorProcessor implements InjectProcessor | |
24 | { | |
25 | private LifecycleState state; | |
26 | ||
27 | public LifecycleStateInjectorProcessor(LifecycleState state) | |
28 | 0 | { |
29 | 0 | this.state = state; |
30 | 0 | } |
31 | ||
32 | public Object process(Object object) | |
33 | { | |
34 | 0 | if (object instanceof LifecycleStateAware) |
35 | { | |
36 | 0 | ((LifecycleStateAware)object).setLifecycleState(state); |
37 | } | |
38 | 0 | return object; |
39 | } | |
40 | } |