View Javadoc

1   /*
2    * $Id: SimpleConfigurationBuilder.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  
11  package org.mule.config.builders;
12  
13  import org.mule.api.MuleContext;
14  import org.mule.api.config.ConfigurationBuilder;
15  import org.mule.api.registry.Registry;
16  
17  import java.util.Map;
18  
19  /**
20   * This simple ConfgurationBuilder implementation. This is useful for registering any
21   * Map of objects with the {@link Registry} via the {@link ConfigurationBuilder}
22   * interface. This is useful for example for the registration of "startup properties"
23   * which are provided at startup and then used to fill "property placeholders" in
24   * other configuration mechanisms such as XML.
25   */
26  public class SimpleConfigurationBuilder extends AbstractConfigurationBuilder
27  {
28  
29      protected Map objects;
30  
31      public SimpleConfigurationBuilder(Map objects)
32      {
33          this.objects = objects;
34      }
35  
36      protected void doConfigure(MuleContext muleContext) throws Exception
37      {
38          if (objects != null && objects.size() > 0)
39          {
40              muleContext.getRegistry().registerObjects(objects);
41          }
42      }
43  }