View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *  http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.geronimo.genesis.plugins.script;
21  
22  import org.apache.commons.logging.Log;
23  import org.apache.commons.logging.LogFactory;
24  import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
25  import org.codehaus.plexus.component.configurator.ConfigurationListener;
26  import org.codehaus.plexus.component.configurator.converters.AbstractConfigurationConverter;
27  import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup;
28  import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
29  import org.codehaus.plexus.configuration.PlexusConfiguration;
30  
31  /**
32   * Plexus converter for {@link DelayedConfiguration} objects.
33   *
34   * @version $Rev: 462757 $ $Date: 2006-10-11 03:24:37 -0700 (Wed, 11 Oct 2006) $
35   */
36  public class DelayedConfigurationConverter
37      extends AbstractConfigurationConverter
38  {
39      private static final Log log = LogFactory.getLog(DelayedConfigurationConverter.class);
40  
41      public boolean canConvert(final Class type) {
42          return DelayedConfiguration.class.isAssignableFrom(type);
43      }
44  
45      public Object fromConfiguration(final ConverterLookup converterLookup,
46                                      final PlexusConfiguration configuration,
47                                      final Class type,
48                                      final Class baseType,
49                                      final ClassLoader classLoader,
50                                      final ExpressionEvaluator expressionEvaluator,
51                                      final ConfigurationListener listener)
52              throws ComponentConfigurationException
53      {
54          if (log.isDebugEnabled()) {
55              log.debug("Capturing delayed config: " + configuration);
56          }
57  
58          return new DelayedConfiguration(converterLookup,
59                                          configuration,
60                                          type,
61                                          baseType,
62                                          classLoader,
63                                          expressionEvaluator,
64                                          listener);
65      }
66  }