01: /*
02: * $Id: AbstractConfigurationBuilder.java 10521 2008-01-24 16:45:01Z dfeist $
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:
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
29: ConfigurationBuilder {
30: protected static final Log logger = LogFactory
31: .getLog(AbstractConfigurationBuilder.class);
32:
33: private boolean configured = false;
34:
35: public void configure(MuleContext muleContext)
36: throws ConfigurationException {
37: try {
38: doConfigure(muleContext);
39: configured = true;
40: } catch (Exception e) {
41: logger.error(CoreMessages.configurationBuilderError(this ),
42: e);
43: throw new ConfigurationException(e);
44: }
45: }
46:
47: protected abstract void doConfigure(MuleContext muleContext)
48: throws Exception;
49:
50: public boolean isConfigured() {
51: return configured;
52: }
53: }
|