aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration')
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/BasedirBeanConfigurationPathTranslator.java71
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/BeanConfigurationException.java41
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/BeanConfigurationPathTranslator.java41
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/BeanConfigurationRequest.java130
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/BeanConfigurationValuePreprocessor.java45
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/BeanConfigurator.java44
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/DefaultBeanConfigurationRequest.java195
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/internal/DefaultBeanConfigurator.java160
8 files changed, 0 insertions, 727 deletions
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/BasedirBeanConfigurationPathTranslator.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/BasedirBeanConfigurationPathTranslator.java
deleted file mode 100644
index 9859f586..00000000
--- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/BasedirBeanConfigurationPathTranslator.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package org.apache.maven.configuration;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-
-/**
- * A path translator that resolves relative paths against a specific base directory.
- *
- * @author Benjamin Bentmann
- */
-public class BasedirBeanConfigurationPathTranslator
- implements BeanConfigurationPathTranslator
-{
-
- private final File basedir;
-
- /**
- * Creates a new path translator using the specified base directory.
- *
- * @param basedir The base directory to resolve relative paths against, may be {@code null} to disable path
- * translation.
- */
- public BasedirBeanConfigurationPathTranslator( File basedir )
- {
- this.basedir = basedir;
- }
-
- public File translatePath( File path )
- {
- File result = path;
-
- if ( path != null && basedir != null )
- {
- if ( path.isAbsolute() )
- {
- // path is already absolute, we're done
- }
- else if ( path.getPath().startsWith( File.separator ) )
- {
- // drive-relative Windows path, don't align with base dir but with drive root
- result = path.getAbsoluteFile();
- }
- else
- {
- // an ordinary relative path, align with base dir
- result = new File( new File( basedir, path.getPath() ).toURI().normalize() ).getAbsoluteFile();
- }
- }
-
- return result;
- }
-
-}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/BeanConfigurationException.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/BeanConfigurationException.java
deleted file mode 100644
index 3d10ed4a..00000000
--- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/BeanConfigurationException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package org.apache.maven.configuration;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Thrown when a bean couldn't be configured.
- *
- * @author Benjamin Bentmann
- */
-public class BeanConfigurationException
- extends Exception
-{
-
- public BeanConfigurationException( String message )
- {
- super( message );
- }
-
- public BeanConfigurationException( String message, Throwable cause )
- {
- super( message, cause );
- }
-
-}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/BeanConfigurationPathTranslator.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/BeanConfigurationPathTranslator.java
deleted file mode 100644
index 39663391..00000000
--- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/BeanConfigurationPathTranslator.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package org.apache.maven.configuration;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-
-/**
- * Postprocesses filesystem paths. For instance, a path translator might want to resolve relative paths given in the
- * bean configuration against some base directory.
- *
- * @author Benjamin Bentmann
- */
-public interface BeanConfigurationPathTranslator
-{
-
- /**
- * Translates the specified path.
- *
- * @param path The path to translate, may be {@code null}.
- * @return The translated path or {@code null} if none.
- */
- File translatePath( File path );
-
-}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/BeanConfigurationRequest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/BeanConfigurationRequest.java
deleted file mode 100644
index d19aa204..00000000
--- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/BeanConfigurationRequest.java
+++ /dev/null
@@ -1,130 +0,0 @@
-package org.apache.maven.configuration;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * A request to configure a bean from some configuration in the POM or similar.
- *
- * @author Benjamin Bentmann
- */
-public interface BeanConfigurationRequest
-{
-
- /**
- * Gets the bean to configure. Eventually, a valid request must have a bean set.
- *
- * @return The bean to configure, or {@code null} if none.
- */
- Object getBean();
-
- /**
- * Sets the bean to configure. Eventually, a valid request must have a bean set.
- *
- * @param bean The bean to configure, may be {@code null}.
- * @return This request for chaining, never {@code null}.
- */
- BeanConfigurationRequest setBean( Object bean );
-
- /**
- * Gets the configuration to unmarshal into the bean.
- *
- * @return The configuration to unmarshal into the bean or {@code null} if none.
- */
- Object getConfiguration();
-
- /**
- * Sets the configuration to unmarshal into the bean. The configuration should be taken from
- * {@link org.apache.maven.model.ConfigurationContainer#getConfiguration()} or a similar source.
- * Fully equivalent to {@code setConfiguration(configuration, null)}.
- *
- * @param configuration The configuration to unmarshal, may be {@code null}.
- * @return This request for chaining, never {@code null}.
- */
- BeanConfigurationRequest setConfiguration( Object configuration );
-
- /**
- * Sets the configuration to unmarshal into the bean. The configuration should be taken from
- * {@link org.apache.maven.model.ConfigurationContainer#getConfiguration()} or a similar source.
- * If {@code element} is not {@code null}, child configuration element with the specified name will
- * be unmarshaled.
- *
- * @param configuration The configuration to unmarshal, may be {@code null}.
- * @param element Configuration element name to unmarshal or {@code null} to unmarshal entire configuration.
- * @return This request for chaining, never {@code null}.
- */
- BeanConfigurationRequest setConfiguration( Object configuration, String element );
-
- /**
- * Returns configuration element name or {@code null}.
- *
- * @see #setConfiguration(Object, String)
- *
- * @return Configuration element name or {@code null}
- */
- String getConfigurationElement();
-
- /**
- * Gets the class loader from which to load any types referenced by the configuration. If unset, the class loader of
- * the bean class will be used.
- *
- * @return The class loader to load referenced types from or {@code null} if unset.
- */
- ClassLoader getClassLoader();
-
- /**
- * Sets the class loader from which to load any types referenced by the configuration. If unset, the class loader of
- * the bean class will be used.
- *
- * @param classLoader The class loader to load referenced types from, may be {@code null}.
- * @return This request for chaining, never {@code null}.
- */
- BeanConfigurationRequest setClassLoader( ClassLoader classLoader );
-
- /**
- * Gets the optional preprocessor for configuration values.
- *
- * @return The preprocessor for configuration values or {@code null} if none.
- */
- BeanConfigurationValuePreprocessor getValuePreprocessor();
-
- /**
- * Sets the optional preprocessor for configuration values.
- *
- * @param valuePreprocessor The preprocessor for configuration values, may be {@code null} if unneeded.
- * @return This request for chaining, never {@code null}.
- */
- BeanConfigurationRequest setValuePreprocessor( BeanConfigurationValuePreprocessor valuePreprocessor );
-
- /**
- * Gets the optional path translator for configuration values unmarshalled to files.
- *
- * @return The path translator for files or {@code null} if none.
- */
- BeanConfigurationPathTranslator getPathTranslator();
-
- /**
- * Sets the optional path translator for configuration values unmarshalled to files.
- *
- * @param pathTranslator The path translator for files, may be {@code null} if unneeded.
- * @return This request for chaining, never {@code null}.
- */
- BeanConfigurationRequest setPathTranslator( BeanConfigurationPathTranslator pathTranslator );
-
-}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/BeanConfigurationValuePreprocessor.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/BeanConfigurationValuePreprocessor.java
deleted file mode 100644
index 63f85173..00000000
--- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/BeanConfigurationValuePreprocessor.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package org.apache.maven.configuration;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Preprocesses a value from a bean configuration before the bean configurator unmarshals it into a bean property. A
- * common use case for such preprocessing is the evaluation of variables within the configuration value.
- *
- * @author Benjamin Bentmann
- */
-public interface BeanConfigurationValuePreprocessor
-{
-
- /**
- * Preprocesses the specified bean configuration value. The optional type provided to this method is a hint (not a
- * requirement) for the preprocessor to resolve the value to a compatible value or a (string) value than can be
- * unmarshalled into that type. The preprocessor is not required to perform any type conversion but should rather
- * filter out incompatible values from its result.
- *
- * @param value The configuration value to preprocess, must not be {@code null}.
- * @param type The target type of the value, may be {@code null}.
- * @return The processed configuration value or {@code null} if none.
- * @throws BeanConfigurationException If an error occurred while preprocessing the value.
- */
- Object preprocessValue( String value, Class<?> type )
- throws BeanConfigurationException;
-
-}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/BeanConfigurator.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/BeanConfigurator.java
deleted file mode 100644
index 36d23eca..00000000
--- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/BeanConfigurator.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.apache.maven.configuration;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Unmarshals some textual configuration from the POM or similar into the properties of a bean. This component works
- * similar to the way Maven configures plugins from the POM, i.e. some configuration like {@code <param>value</param>}
- * is mapped to an equally named property of the bean and converted. The properties of the bean are supposed to either
- * have a public setter or be backed by an equally named field (of any visibility).
- *
- * @since 3.0
- * @author Benjamin Bentmann
- */
-public interface BeanConfigurator
-{
-
- /**
- * Performs the specified bean configuration.
- *
- * @param request The configuration request that specifies the bean and the configuration to process, must not be
- * {@code null}.
- * @throws BeanConfigurationException If the bean configuration could not be successfully processed.
- */
- void configureBean( BeanConfigurationRequest request )
- throws BeanConfigurationException;
-
-}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/DefaultBeanConfigurationRequest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/DefaultBeanConfigurationRequest.java
deleted file mode 100644
index 32def48f..00000000
--- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/DefaultBeanConfigurationRequest.java
+++ /dev/null
@@ -1,195 +0,0 @@
-package org.apache.maven.configuration;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.model.Build;
-import org.apache.maven.model.Model;
-import org.apache.maven.model.Plugin;
-import org.apache.maven.model.PluginExecution;
-import org.apache.maven.model.PluginManagement;
-import org.codehaus.plexus.util.StringUtils;
-
-/**
- * A basic bean configuration request.
- *
- * @author Benjamin Bentmann
- */
-public class DefaultBeanConfigurationRequest
- implements BeanConfigurationRequest
-{
-
- private Object bean;
-
- private Object configuration;
-
- private String configurationElement;
-
- private ClassLoader classLoader;
-
- private BeanConfigurationValuePreprocessor valuePreprocessor;
-
- private BeanConfigurationPathTranslator pathTranslator;
-
- public Object getBean()
- {
- return bean;
- }
-
- public DefaultBeanConfigurationRequest setBean( Object bean )
- {
- this.bean = bean;
- return this;
- }
-
- public Object getConfiguration()
- {
- return configuration;
- }
-
- public String getConfigurationElement()
- {
- return configurationElement;
- }
-
- public DefaultBeanConfigurationRequest setConfiguration( Object configuration )
- {
- return setConfiguration( configuration, null );
- }
-
- public DefaultBeanConfigurationRequest setConfiguration( Object configuration, String element )
- {
- this.configuration = configuration;
- this.configurationElement = element;
- return this;
- }
-
- /**
- * Sets the configuration to the configuration taken from the specified build plugin in the POM. First, the build
- * plugins will be searched for the specified plugin, if that fails, the plugin management section will be searched.
- *
- * @param model The POM to extract the plugin configuration from, may be {@code null}.
- * @param pluginGroupId The group id of the plugin whose configuration should be used, must not be {@code null} or
- * empty.
- * @param pluginArtifactId The artifact id of the plugin whose configuration should be used, must not be
- * {@code null} or empty.
- * @param pluginExecutionId The id of a plugin execution whose configuration should be used, may be {@code null} or
- * empty to use the general plugin configuration.
- * @return This request for chaining, never {@code null}.
- */
- public DefaultBeanConfigurationRequest setConfiguration( Model model, String pluginGroupId,
- String pluginArtifactId, String pluginExecutionId )
- {
- Plugin plugin = findPlugin( model, pluginGroupId, pluginArtifactId );
- if ( plugin != null )
- {
- if ( StringUtils.isNotEmpty( pluginExecutionId ) )
- {
- for ( PluginExecution execution : plugin.getExecutions() )
- {
- if ( pluginExecutionId.equals( execution.getId() ) )
- {
- setConfiguration( execution.getConfiguration() );
- break;
- }
- }
- }
- else
- {
- setConfiguration( plugin.getConfiguration() );
- }
- }
- return this;
- }
-
- private Plugin findPlugin( Model model, String groupId, String artifactId )
- {
- if ( StringUtils.isEmpty( groupId ) )
- {
- throw new IllegalArgumentException( "group id for plugin has not been specified" );
- }
- if ( StringUtils.isEmpty( artifactId ) )
- {
- throw new IllegalArgumentException( "artifact id for plugin has not been specified" );
- }
-
- if ( model != null )
- {
- Build build = model.getBuild();
- if ( build != null )
- {
- for ( Plugin plugin : build.getPlugins() )
- {
- if ( groupId.equals( plugin.getGroupId() ) && artifactId.equals( plugin.getArtifactId() ) )
- {
- return plugin;
- }
- }
-
- PluginManagement mngt = build.getPluginManagement();
- if ( mngt != null )
- {
- for ( Plugin plugin : mngt.getPlugins() )
- {
- if ( groupId.equals( plugin.getGroupId() ) && artifactId.equals( plugin.getArtifactId() ) )
- {
- return plugin;
- }
- }
- }
- }
- }
-
- return null;
- }
-
- public ClassLoader getClassLoader()
- {
- return classLoader;
- }
-
- public DefaultBeanConfigurationRequest setClassLoader( ClassLoader classLoader )
- {
- this.classLoader = classLoader;
- return this;
- }
-
- public BeanConfigurationValuePreprocessor getValuePreprocessor()
- {
- return valuePreprocessor;
- }
-
- public DefaultBeanConfigurationRequest setValuePreprocessor( BeanConfigurationValuePreprocessor valuePreprocessor )
- {
- this.valuePreprocessor = valuePreprocessor;
- return this;
- }
-
- public BeanConfigurationPathTranslator getPathTranslator()
- {
- return pathTranslator;
- }
-
- public DefaultBeanConfigurationRequest setPathTranslator( BeanConfigurationPathTranslator pathTranslator )
- {
- this.pathTranslator = pathTranslator;
- return this;
- }
-
-}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/internal/DefaultBeanConfigurator.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/internal/DefaultBeanConfigurator.java
deleted file mode 100644
index 3d3def62..00000000
--- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/configuration/internal/DefaultBeanConfigurator.java
+++ /dev/null
@@ -1,160 +0,0 @@
-package org.apache.maven.configuration.internal;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-
-import org.apache.maven.configuration.BeanConfigurationException;
-import org.apache.maven.configuration.BeanConfigurationPathTranslator;
-import org.apache.maven.configuration.BeanConfigurationRequest;
-import org.apache.maven.configuration.BeanConfigurationValuePreprocessor;
-import org.apache.maven.configuration.BeanConfigurator;
-import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
-import org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter;
-import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup;
-import org.codehaus.plexus.component.configurator.converters.lookup.DefaultConverterLookup;
-import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
-import org.codehaus.plexus.component.configurator.expression.TypeAwareExpressionEvaluator;
-import org.codehaus.plexus.configuration.PlexusConfiguration;
-import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
-import org.codehaus.plexus.util.xml.Xpp3Dom;
-
-/**
- * <strong>Warning:</strong> This is an internal class that is only public for technical reasons, it is not part of the
- * public API. In particular, this class can be changed or deleted without prior notice.
- *
- * @author Benjamin Bentmann
- */
-@Component( role = BeanConfigurator.class )
-public class DefaultBeanConfigurator
- implements BeanConfigurator
-{
-
- private final ConverterLookup converterLookup = new DefaultConverterLookup();
-
- public void configureBean( BeanConfigurationRequest request )
- throws BeanConfigurationException
- {
- if ( request == null )
- {
- throw new IllegalArgumentException( "bean configuration request not specified" );
- }
-
- if ( request.getBean() == null )
- {
- throw new IllegalArgumentException( "bean to be configured not specified" );
- }
-
- Object configuration = request.getConfiguration();
- if ( configuration == null )
- {
- return;
- }
-
- PlexusConfiguration plexusConfig;
- if ( configuration instanceof PlexusConfiguration )
- {
- plexusConfig = (PlexusConfiguration) configuration;
- }
- else if ( configuration instanceof Xpp3Dom )
- {
- plexusConfig = new XmlPlexusConfiguration( (Xpp3Dom) configuration );
- }
- else
- {
- throw new BeanConfigurationException( "unsupported bean configuration source ("
- + configuration.getClass().getName() + ")" );
- }
-
- if ( request.getConfigurationElement() != null )
- {
- plexusConfig = plexusConfig.getChild( request.getConfigurationElement() );
- }
-
- ClassLoader classLoader = request.getClassLoader();
- if ( classLoader == null )
- {
- classLoader = request.getBean().getClass().getClassLoader();
- }
-
- BeanExpressionEvaluator evaluator = new BeanExpressionEvaluator( request );
-
- ObjectWithFieldsConverter converter = new ObjectWithFieldsConverter();
-
- try
- {
- converter.processConfiguration( converterLookup, request.getBean(), classLoader, plexusConfig, evaluator );
- }
- catch ( ComponentConfigurationException e )
- {
- throw new BeanConfigurationException( e.getMessage(), e );
- }
- }
-
- static class BeanExpressionEvaluator
- implements TypeAwareExpressionEvaluator
- {
-
- private final BeanConfigurationValuePreprocessor preprocessor;
-
- private final BeanConfigurationPathTranslator translator;
-
- public BeanExpressionEvaluator( BeanConfigurationRequest request )
- {
- preprocessor = request.getValuePreprocessor();
- translator = request.getPathTranslator();
- }
-
- public Object evaluate( String expression, Class<?> type )
- throws ExpressionEvaluationException
- {
- if ( preprocessor != null )
- {
- try
- {
- return preprocessor.preprocessValue( expression, type );
- }
- catch ( BeanConfigurationException e )
- {
- throw new ExpressionEvaluationException( e.getMessage(), e );
- }
- }
- return expression;
- }
-
- public Object evaluate( String expression )
- throws ExpressionEvaluationException
- {
- return evaluate( expression, null );
- }
-
- public File alignToBaseDirectory( File file )
- {
- if ( translator != null )
- {
- return translator.translatePath( file );
- }
- return file;
- }
-
- }
-
-}