View Javadoc

1   /*
2    * $Id: MuleContextProcessor.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.registry.InjectProcessor;
15  
16  /**
17   * Injects the MuleContext object for objects stored in the {@link TransientRegistry} where the object registered
18   * implements {@link org.mule.api.context.MuleContextAware}.
19   */
20  public class MuleContextProcessor implements InjectProcessor
21  {
22      private MuleContext context;
23  
24      public MuleContextProcessor(MuleContext context)
25      {
26          this.context = context;
27      }
28  
29      public Object process(Object object)
30      {
31          if (object instanceof MuleContextAware)
32          {
33              ((MuleContextAware)object).setMuleContext(context);
34          }
35          return object;
36      }
37  }