View Javadoc

1   /*
2    * $Id: AbstractConfigurationBuilder.java 10521 2008-01-24 16:45:01Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.config.ConfigurationException;
16  import org.mule.config.i18n.CoreMessages;
17  
18  import org.apache.commons.logging.Log;
19  import org.apache.commons.logging.LogFactory;
20  
21  /**
22   * A support class for {@link org.mule.api.config.ConfigurationBuilder} implementations
23   * that handles the logic of creating config arrays and {@link java.util.Properties}
24   * arguments
25   * 
26   * @see org.mule.api.config.ConfigurationBuilder
27   */
28  public abstract class AbstractConfigurationBuilder implements ConfigurationBuilder
29  {
30      protected static final Log logger = LogFactory.getLog(AbstractConfigurationBuilder.class);
31  
32      private boolean configured = false;
33  
34      public void configure(MuleContext muleContext) throws ConfigurationException
35      {
36          try
37          {
38              doConfigure(muleContext);
39              configured = true;
40          }
41          catch (Exception e)
42          {
43              logger.error(CoreMessages.configurationBuilderError(this), e);
44              throw new ConfigurationException(e);
45          }
46      }
47  
48      protected abstract void doConfigure(MuleContext muleContext) throws Exception;
49  
50      public boolean isConfigured()
51      {
52          return configured;
53      }
54  }