You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2011/05/17 18:57:54 UTC

svn commit: r1104405 [2/6] - in /maven/sandbox/trunk/mae: ./ boms/ boms/mae-app-bom/ boms/mae-library-bom/ mae-api/ mae-api/src/ mae-api/src/main/ mae-api/src/main/java/ mae-api/src/main/java/org/ mae-api/src/main/java/org/apache/ mae-api/src/main/java...

Added: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/MAEConfiguration.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/MAEConfiguration.java?rev=1104405&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/MAEConfiguration.java (added)
+++ maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/MAEConfiguration.java Tue May 17 16:57:50 2011
@@ -0,0 +1,316 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * 
+ * Licensed 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.
+ */
+
+package org.apache.maven.mae.conf;
+
+import org.apache.maven.mae.MAEExecutionRequest;
+import org.apache.maven.mae.conf.ext.ExtensionConfiguration;
+import org.apache.maven.mae.internal.container.ComponentKey;
+import org.apache.maven.mae.internal.container.ComponentSelector;
+import org.apache.maven.mae.internal.container.InstanceRegistry;
+import org.apache.maven.mae.internal.container.ServiceAuthorizer;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.PrintStream;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+public class MAEConfiguration
+{
+
+    public static final String STANDARD_LOG_HANDLE_CORE = "core";
+
+    public static final String STANDARD_LOG_HANDLE_LOADER = "emb-loader";
+
+    private static final File DEFAULT_CONFIGURATION_DIRECTORY =
+        new File( System.getProperty( "user.home" ), ".m2/conf" );
+
+    private ComponentSelector componentSelector;
+
+    private InstanceRegistry instanceRegistry;
+
+    private Set<MAELibrary> libraries;
+
+    private File configurationDirectory = DEFAULT_CONFIGURATION_DIRECTORY;
+
+    private MAEExecutionRequest executionRequest;
+
+    private InputStream stdin = System.in;
+
+    private PrintStream stdout = System.out;
+
+    private PrintStream stderr = System.err;
+
+    private boolean debug;
+
+    private boolean interactive = true;
+
+    public MAEConfiguration()
+    {
+    }
+
+    public MAEConfiguration withEMBExecutionRequest( final MAEExecutionRequest request )
+    {
+        executionRequest = request;
+        return this;
+    }
+
+    public MAEConfiguration withStandardIn( final InputStream stdin )
+    {
+        this.stdin = stdin;
+        return this;
+    }
+
+    public InputStream getStandardIn()
+    {
+        return stdin;
+    }
+
+    public MAEConfiguration withStandardOut( final PrintStream stdout )
+    {
+        this.stdout = stdout;
+        return this;
+    }
+
+    public PrintStream getStandardOut()
+    {
+        return stdout;
+    }
+
+    public MAEConfiguration withStandardErr( final PrintStream stderr )
+    {
+        this.stderr = stderr;
+        return this;
+    }
+
+    public PrintStream getStandardErr()
+    {
+        return stderr;
+    }
+
+    public MAEExecutionRequest getEMBExecutionRequest()
+    {
+        return executionRequest;
+    }
+
+    public boolean isInteractive()
+    {
+        return interactive;
+    }
+
+    public boolean isDebugEnabled()
+    {
+        return debug;
+    }
+
+    public MAEConfiguration withConfigurationDirectory( final File configurationDirectory )
+    {
+        this.configurationDirectory = configurationDirectory;
+        return this;
+    }
+
+    public File getConfigurationDirectory()
+    {
+        return configurationDirectory;
+    }
+
+    public MAEConfiguration withLibraries( final Collection<MAELibrary> libraries )
+    {
+        for ( final MAELibrary library : libraries )
+        {
+            withLibrary( library );
+        }
+        return this;
+    }
+
+    public MAEConfiguration withLibraries( final MAELibrary... libraries )
+    {
+        for ( final MAELibrary library : libraries )
+        {
+            withLibrary( library );
+        }
+        return this;
+    }
+
+    public MAELibrary getLibrary( final String id )
+    {
+        for ( final MAELibrary library : getLibraries() )
+        {
+            if ( library.getId().equalsIgnoreCase( id ) )
+            {
+                return library;
+            }
+        }
+
+        return null;
+    }
+
+    public Set<MAELibrary> getLibraries()
+    {
+        if ( libraries == null )
+        {
+            libraries = new HashSet<MAELibrary>();
+        }
+
+        return libraries;
+    }
+
+    public ComponentSelector getComponentSelector()
+    {
+        if ( componentSelector == null )
+        {
+            componentSelector = new ComponentSelector();
+        }
+
+        return componentSelector;
+    }
+
+    public synchronized MAEConfiguration withComponentSelection( final ComponentKey<?> key, final String newHint )
+    {
+        getComponentSelector().setSelection( key, newHint );
+        return this;
+    }
+
+    public synchronized MAEConfiguration withComponentSelections( final Map<ComponentKey<?>, String> selections )
+    {
+        if ( selections != null )
+        {
+            for ( final Map.Entry<ComponentKey<?>, String> entry : selections.entrySet() )
+            {
+                if ( entry == null || entry.getKey() == null || entry.getValue() == null )
+                {
+                    continue;
+                }
+
+                getComponentSelector().setSelection( entry.getKey(), entry.getValue() );
+            }
+        }
+
+        return this;
+    }
+
+    public synchronized MAEConfiguration withComponentSelections( final ComponentSelector newSelector )
+    {
+        if ( newSelector != null )
+        {
+            getComponentSelector().merge( newSelector );
+        }
+
+        return this;
+    }
+
+    public MAEConfiguration withComponentSelector( final ComponentSelector selector )
+    {
+        getComponentSelector().merge( selector );
+
+        return this;
+    }
+
+    public MAEConfiguration withoutDebug()
+    {
+        debug = false;
+        return this;
+    }
+
+    public MAEConfiguration withDebug()
+    {
+        debug = true;
+        return this;
+    }
+
+    public MAEConfiguration interactive()
+    {
+        interactive = true;
+        return this;
+    }
+
+    public MAEConfiguration nonInteractive()
+    {
+        interactive = false;
+        return this;
+    }
+
+    @SuppressWarnings( { "rawtypes", "unchecked" } )
+    public MAEConfiguration withLibrary( final MAELibrary library )
+    {
+        getLibraries().add( library );
+        withComponentSelector( library.getComponentSelector() );
+        withInstanceRegistry( library.getInstanceRegistry() );
+        withComponentInstance( new ComponentKey<MAELibrary>( MAELibrary.class, library.getId() ), library );
+
+        final ExtensionConfiguration configuration = library.getConfiguration();
+        if ( configuration != null )
+        {
+            withComponentInstance( new ComponentKey<ExtensionConfiguration>( ExtensionConfiguration.class,
+                                                                             library.getId() ), configuration );
+
+            withComponentInstance( new ComponentKey( configuration.getClass() ), configuration );
+        }
+
+        return this;
+    }
+
+    public synchronized <T> MAEConfiguration withComponentInstance( final ComponentKey<T> key, final T instance )
+    {
+        getInstanceRegistry().add( key, instance );
+
+        return this;
+    }
+
+    public synchronized MAEConfiguration withComponentInstance( final Object instance )
+    {
+        getInstanceRegistry().add( instance );
+        return this;
+    }
+
+    public synchronized MAEConfiguration withInstanceRegistry( final InstanceRegistry instanceRegistry )
+    {
+        if ( instanceRegistry != null )
+        {
+            getInstanceRegistry().overrideMerge( instanceRegistry );
+        }
+
+        return this;
+    }
+
+    public synchronized InstanceRegistry getInstanceRegistry()
+    {
+        if ( instanceRegistry == null )
+        {
+            instanceRegistry = new InstanceRegistry();
+        }
+
+        final Set<ComponentKey<?>> keys = new HashSet<ComponentKey<?>>();
+        for ( final MAELibrary lib : getLibraries() )
+        {
+            final Set<ComponentKey<?>> exports = lib.getExportedComponents();
+            if ( exports != null && !exports.isEmpty() )
+            {
+                keys.addAll( exports );
+            }
+        }
+
+        instanceRegistry.add( new ComponentKey<ServiceAuthorizer>( ServiceAuthorizer.class ),
+                              new ServiceAuthorizer( keys ) );
+        instanceRegistry.add( MAEConfiguration.class, this );
+
+        return instanceRegistry;
+    }
+
+}

Propchange: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/MAEConfiguration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/MAELibraries.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/MAELibraries.java?rev=1104405&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/MAELibraries.java (added)
+++ maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/MAELibraries.java Tue May 17 16:57:50 2011
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * 
+ * Licensed 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.
+ */
+
+package org.apache.maven.mae.conf;
+
+import org.apache.log4j.Logger;
+import org.apache.maven.mae.conf.ext.ExtensionConfigurationException;
+import org.apache.maven.mae.conf.loader.MAELibraryLoader;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+public final class MAELibraries
+{
+
+    private static final Logger logger = Logger.getLogger( MAEConfiguration.STANDARD_LOG_HANDLE_LOADER );
+
+    private static Set<MAELibrary> libraries;
+
+    public static Collection<MAELibrary> loadLibraries( final MAEConfiguration embConfig,
+                                                        final List<MAELibraryLoader> loaders )
+        throws IOException
+    {
+        if ( libraries != null )
+        {
+            return libraries;
+        }
+
+        libraries = new LinkedHashSet<MAELibrary>();
+        for ( final MAELibraryLoader loader : loaders )
+        {
+            libraries.addAll( loader.loadLibraries( embConfig ) );
+        }
+
+        for ( final MAELibrary library : libraries )
+        {
+            try
+            {
+                library.loadConfiguration( embConfig );
+            }
+            catch ( final ExtensionConfigurationException e )
+            {
+                if ( logger.isDebugEnabled() )
+                {
+                    logger.debug( "Failed to load library configuration for: '" + library.getId() + "'. Reason: "
+                                                  + e.getMessage(), e );
+                }
+            }
+        }
+
+        libraries = Collections.unmodifiableSet( libraries );
+        return libraries;
+    }
+
+}

Propchange: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/MAELibraries.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/MAELibrary.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/MAELibrary.java?rev=1104405&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/MAELibrary.java (added)
+++ maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/MAELibrary.java Tue May 17 16:57:50 2011
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * 
+ * Licensed 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.
+ */
+
+package org.apache.maven.mae.conf;
+
+import org.apache.log4j.Logger;
+import org.apache.maven.mae.conf.ext.ExtensionConfiguration;
+import org.apache.maven.mae.conf.ext.ExtensionConfigurationException;
+import org.apache.maven.mae.internal.container.ComponentKey;
+import org.apache.maven.mae.internal.container.ComponentSelector;
+import org.apache.maven.mae.internal.container.InstanceRegistry;
+
+import java.util.Map;
+import java.util.Set;
+
+public interface MAELibrary
+{
+
+    Logger getLogger();
+
+    ExtensionConfiguration getConfiguration();
+
+    ComponentSelector getComponentSelector();
+
+    Set<ComponentKey<?>> getExportedComponents();
+
+    Set<ComponentKey<?>> getManagementComponents( Class<?> managementType );
+
+    Map<Class<?>, Set<ComponentKey<?>>> getManagementComponents();
+
+    String getLabel();
+
+    String getId();
+
+    String getLogHandle();
+
+    String getName();
+
+    String getVersion();
+
+    void loadConfiguration( final MAEConfiguration embConfig )
+        throws ExtensionConfigurationException;
+
+    InstanceRegistry getInstanceRegistry();
+
+}

Propchange: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/MAELibrary.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/MavenPomVersionProvider.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/MavenPomVersionProvider.java?rev=1104405&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/MavenPomVersionProvider.java (added)
+++ maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/MavenPomVersionProvider.java Tue May 17 16:57:50 2011
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * 
+ * Licensed 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.
+ */
+
+package org.apache.maven.mae.conf;
+
+import org.apache.log4j.Logger;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+public final class MavenPomVersionProvider
+    implements VersionProvider
+{
+
+    private static final Logger logger = Logger.getLogger( MAEConfiguration.STANDARD_LOG_HANDLE_LOADER );
+
+    private final String groupId;
+
+    private final String artifactId;
+
+    private String version;
+
+    public MavenPomVersionProvider( final String groupId, final String artifactId )
+    {
+        this.groupId = groupId;
+        this.artifactId = artifactId;
+    }
+
+    public final synchronized String getVersion()
+    {
+        if ( version == null )
+        {
+            final String path = "META-INF/maven/" + groupId + "/" + artifactId + "/pom.properties";
+            final InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream( path );
+
+            if ( stream != null )
+            {
+                final Properties p = new Properties();
+                try
+                {
+                    p.load( stream );
+                    version = p.getProperty( "version" );
+                }
+                catch ( final IOException e )
+                {
+                    if ( logger.isDebugEnabled() )
+                    {
+                        logger.debug( "Failed to load version for: " + groupId + ":" + artifactId );
+                    }
+                }
+            }
+
+            if ( version == null )
+            {
+                version = "-UNKNOWN-";
+            }
+        }
+
+        return version;
+    }
+
+}

Propchange: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/MavenPomVersionProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/StringVersionProvider.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/StringVersionProvider.java?rev=1104405&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/StringVersionProvider.java (added)
+++ maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/StringVersionProvider.java Tue May 17 16:57:50 2011
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * 
+ * Licensed 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.
+ */
+
+package org.apache.maven.mae.conf;
+
+public final class StringVersionProvider
+    implements VersionProvider
+{
+
+    private final String version;
+
+    public StringVersionProvider( final String version )
+    {
+        this.version = version;
+    }
+
+    public final String getVersion()
+    {
+        return version;
+    }
+
+}

Propchange: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/StringVersionProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/VersionProvider.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/VersionProvider.java?rev=1104405&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/VersionProvider.java (added)
+++ maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/VersionProvider.java Tue May 17 16:57:50 2011
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * 
+ * Licensed 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.
+ */
+
+package org.apache.maven.mae.conf;
+
+public interface VersionProvider
+{
+    String getVersion();
+}

Propchange: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/VersionProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/ext/ExtensionConfiguration.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/ext/ExtensionConfiguration.java?rev=1104405&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/ext/ExtensionConfiguration.java (added)
+++ maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/ext/ExtensionConfiguration.java Tue May 17 16:57:50 2011
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * 
+ * Licensed 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.
+ */
+
+package org.apache.maven.mae.conf.ext;
+
+public interface ExtensionConfiguration
+{
+
+}

Propchange: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/ext/ExtensionConfiguration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/ext/ExtensionConfigurationException.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/ext/ExtensionConfigurationException.java?rev=1104405&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/ext/ExtensionConfigurationException.java (added)
+++ maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/ext/ExtensionConfigurationException.java Tue May 17 16:57:50 2011
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * 
+ * Licensed 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.
+ */
+
+package org.apache.maven.mae.conf.ext;
+
+import java.text.MessageFormat;
+
+public class ExtensionConfigurationException
+    extends Exception
+{
+
+    private static final long serialVersionUID = 1L;
+
+    private final Object[] params;
+
+    private String formattedMessage;
+
+    public ExtensionConfigurationException( final String message, final Throwable cause )
+    {
+        super( message, cause );
+        params = null;
+    }
+
+    public ExtensionConfigurationException( final String message )
+    {
+        super( message );
+        params = null;
+    }
+
+    public ExtensionConfigurationException( final String message, final Throwable cause, final Object... params )
+    {
+        super( message, cause );
+        this.params = params;
+    }
+
+    public ExtensionConfigurationException( final String message, final Object... params )
+    {
+        super( message );
+        this.params = params;
+    }
+
+    @Override
+    public synchronized String getMessage()
+    {
+        if ( formattedMessage == null )
+        {
+            final String format = super.getMessage();
+            if ( params == null || params.length < 1 )
+            {
+                formattedMessage = format;
+            }
+            else
+            {
+                try
+                {
+                    formattedMessage = MessageFormat.format( format, params );
+                }
+                catch ( final Error e )
+                {
+                    formattedMessage = format;
+                    throw e;
+                }
+                catch ( final RuntimeException e )
+                {
+                    formattedMessage = format;
+                    throw e;
+                }
+                catch ( final Exception e )
+                {
+                    formattedMessage = format;
+                }
+            }
+        }
+
+        return formattedMessage;
+    }
+
+}

Propchange: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/ext/ExtensionConfigurationException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/ext/ExtensionConfigurationLoader.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/ext/ExtensionConfigurationLoader.java?rev=1104405&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/ext/ExtensionConfigurationLoader.java (added)
+++ maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/ext/ExtensionConfigurationLoader.java Tue May 17 16:57:50 2011
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * 
+ * Licensed 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.
+ */
+
+package org.apache.maven.mae.conf.ext;
+
+import org.apache.maven.mae.conf.MAEConfiguration;
+
+public interface ExtensionConfigurationLoader
+{
+
+    ExtensionConfiguration loadConfiguration( MAEConfiguration embConfig )
+        throws ExtensionConfigurationException;
+
+}

Propchange: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/ext/ExtensionConfigurationLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/loader/InstanceLibraryLoader.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/loader/InstanceLibraryLoader.java?rev=1104405&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/loader/InstanceLibraryLoader.java (added)
+++ maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/loader/InstanceLibraryLoader.java Tue May 17 16:57:50 2011
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * 
+ * Licensed 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.
+ */
+
+package org.apache.maven.mae.conf.loader;
+
+import org.apache.maven.mae.conf.MAEConfiguration;
+import org.apache.maven.mae.conf.MAELibrary;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+public class InstanceLibraryLoader
+    implements MAELibraryLoader
+{
+
+    private final List<MAELibrary> libraries;
+
+    public InstanceLibraryLoader( final MAELibrary... libraries )
+    {
+        this.libraries =
+            libraries == null ? new ArrayList<MAELibrary>() : new ArrayList<MAELibrary>( Arrays.asList( libraries ) );
+    }
+
+    public InstanceLibraryLoader( final List<MAELibrary> libraries )
+    {
+        this.libraries = libraries;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.apache.maven.mae.conf.loader.MAELibraryLoader#loadLibraries(org.apache.maven.mae.conf.MAEConfiguration)
+     */
+    @Override
+    public Collection<MAELibrary> loadLibraries( final MAEConfiguration embConfig )
+        throws IOException
+    {
+        return libraries;
+    }
+
+}

Propchange: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/loader/InstanceLibraryLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/loader/MAELibraryLoader.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/loader/MAELibraryLoader.java?rev=1104405&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/loader/MAELibraryLoader.java (added)
+++ maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/loader/MAELibraryLoader.java Tue May 17 16:57:50 2011
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * 
+ * Licensed 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.
+ */
+
+package org.apache.maven.mae.conf.loader;
+
+import org.apache.maven.mae.conf.MAEConfiguration;
+import org.apache.maven.mae.conf.MAELibrary;
+
+import java.io.IOException;
+import java.util.Collection;
+
+public interface MAELibraryLoader
+{
+    Collection<? extends MAELibrary> loadLibraries( MAEConfiguration embConfig )
+        throws IOException;
+}

Propchange: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/loader/MAELibraryLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/loader/ServiceLibraryLoader.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/loader/ServiceLibraryLoader.java?rev=1104405&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/loader/ServiceLibraryLoader.java (added)
+++ maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/loader/ServiceLibraryLoader.java Tue May 17 16:57:50 2011
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * 
+ * Licensed 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.
+ */
+
+package org.apache.maven.mae.conf.loader;
+
+import org.apache.log4j.Logger;
+import org.apache.maven.mae.conf.MAEConfiguration;
+import org.apache.maven.mae.conf.MAELibrary;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.ServiceLoader;
+
+public class ServiceLibraryLoader
+    implements MAELibraryLoader
+{
+
+    @SuppressWarnings( "unused" )
+    private static final Logger logger = Logger.getLogger( MAEConfiguration.STANDARD_LOG_HANDLE_LOADER );
+
+    public Collection<MAELibrary> loadLibraries( final MAEConfiguration embConfig )
+        throws IOException
+    {
+        final LinkedHashSet<MAELibrary> libraries = new LinkedHashSet<MAELibrary>();
+
+        final ServiceLoader<MAELibrary> loader = ServiceLoader.load( MAELibrary.class );
+        for ( final MAELibrary library : loader )
+        {
+            libraries.add( library );
+        }
+
+        return libraries;
+    }
+
+}

Propchange: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/loader/ServiceLibraryLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/mgmt/LoadOnFinish.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/mgmt/LoadOnFinish.java?rev=1104405&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/mgmt/LoadOnFinish.java (added)
+++ maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/mgmt/LoadOnFinish.java Tue May 17 16:57:50 2011
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * 
+ * Licensed 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.
+ */
+
+package org.apache.maven.mae.conf.mgmt;
+
+
+public interface LoadOnFinish
+{
+
+    void executionFinished( MAEManagementView managementView );
+
+}

Propchange: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/mgmt/LoadOnFinish.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/mgmt/LoadOnStart.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/mgmt/LoadOnStart.java?rev=1104405&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/mgmt/LoadOnStart.java (added)
+++ maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/mgmt/LoadOnStart.java Tue May 17 16:57:50 2011
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * 
+ * Licensed 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.
+ */
+
+package org.apache.maven.mae.conf.mgmt;
+
+
+public interface LoadOnStart
+{
+
+    void executionStarting( MAEManagementView managementView );
+
+}

Propchange: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/mgmt/LoadOnStart.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/mgmt/MAEManagementException.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/mgmt/MAEManagementException.java?rev=1104405&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/mgmt/MAEManagementException.java (added)
+++ maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/mgmt/MAEManagementException.java Tue May 17 16:57:50 2011
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * 
+ * Licensed 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.
+ */
+
+package org.apache.maven.mae.conf.mgmt;
+
+import org.apache.maven.mae.MAEException;
+
+public class MAEManagementException
+    extends MAEException
+{
+
+    private static final long serialVersionUID = 1L;
+
+    public MAEManagementException( final String message, final Object... params )
+    {
+        super( message, params );
+    }
+
+    public MAEManagementException( final String message, final Throwable cause, final Object... params )
+    {
+        super( message, cause, params );
+    }
+
+    public MAEManagementException( final String message, final Throwable cause )
+    {
+        super( message, cause );
+    }
+
+    public MAEManagementException( final String message )
+    {
+        super( message );
+    }
+
+}

Propchange: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/mgmt/MAEManagementException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/mgmt/MAEManagementView.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/mgmt/MAEManagementView.java?rev=1104405&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/mgmt/MAEManagementView.java (added)
+++ maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/mgmt/MAEManagementView.java Tue May 17 16:57:50 2011
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * 
+ * Licensed 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.
+ */
+
+package org.apache.maven.mae.conf.mgmt;
+
+import org.apache.maven.mae.conf.MAEConfiguration;
+
+import java.util.List;
+import java.util.Map;
+
+public interface MAEManagementView
+{
+
+    <T> T lookup( Class<T> role, String hint )
+        throws MAEManagementException;
+
+    <T> T lookup( Class<T> role )
+        throws MAEManagementException;
+
+    <T> Map<String, T> lookupMap( Class<T> role )
+        throws MAEManagementException;
+
+    <T> List<T> lookupList( Class<T> role )
+        throws MAEManagementException;
+
+    MAEConfiguration getConfiguration();
+
+}

Propchange: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/mgmt/MAEManagementView.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/internal/container/ComponentKey.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/internal/container/ComponentKey.java?rev=1104405&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/internal/container/ComponentKey.java (added)
+++ maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/internal/container/ComponentKey.java Tue May 17 16:57:50 2011
@@ -0,0 +1,125 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * 
+ * Licensed 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.
+ */
+
+package org.apache.maven.mae.internal.container;
+
+import static org.codehaus.plexus.util.StringUtils.isBlank;
+
+public class ComponentKey<T>
+{
+
+    public static final String DEFAULT_HINT = "default".intern();
+
+    public static final String LITERAL_SUFFIX = "_";
+
+    private final Class<T> roleClass;
+
+    private final String hint;
+
+    public ComponentKey( final Class<T> role, final String hint )
+    {
+        roleClass = role;
+        this.hint = isBlank( hint ) || DEFAULT_HINT.equals( hint ) ? DEFAULT_HINT : hint.intern();
+    }
+
+    public ComponentKey( final Class<T> role )
+    {
+        roleClass = role;
+        hint = DEFAULT_HINT;
+    }
+
+    public String getRole()
+    {
+        return roleClass.getName();
+    }
+
+    public String getHint()
+    {
+        return hint;
+    }
+
+    public String key()
+    {
+        return roleClass + ( DEFAULT_HINT.equals( hint ) ? "" : "#" + hint );
+    }
+
+    @Override
+    public String toString()
+    {
+        return key();
+    }
+
+    @Override
+    public int hashCode()
+    {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + hint.hashCode();
+        result = prime * result + roleClass.getName().hashCode();
+        return result;
+    }
+
+    @Override
+    public boolean equals( final Object obj )
+    {
+        if ( this == obj )
+        {
+            return true;
+        }
+        if ( obj == null )
+        {
+            return false;
+        }
+        if ( getClass() != obj.getClass() )
+        {
+            return false;
+        }
+
+        final ComponentKey<?> other = ComponentKey.class.cast( obj );
+        if ( !hint.equals( other.hint ) )
+        {
+            return false;
+        }
+
+        if ( !roleClass.getName().equals( other.roleClass.getName() ) )
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    public Class<T> getRoleClass()
+    {
+        return roleClass;
+    }
+
+    public T castValue( final Object instance )
+    {
+        return instance == null ? null : roleClass.cast( instance );
+    }
+
+    public static boolean isLiteral( final String value )
+    {
+        return value != null && value.length() > 1 && value.endsWith( LITERAL_SUFFIX );
+    }
+
+    public static String getLiteralHint( final String value )
+    {
+        return isLiteral( value ) ? value.substring( 0, value.length() - 1 ) : value;
+    }
+
+}

Propchange: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/internal/container/ComponentKey.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/internal/container/ComponentSelector.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/internal/container/ComponentSelector.java?rev=1104405&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/internal/container/ComponentSelector.java (added)
+++ maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/internal/container/ComponentSelector.java Tue May 17 16:57:50 2011
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * 
+ * Licensed 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.
+ */
+
+package org.apache.maven.mae.internal.container;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+public class ComponentSelector
+{
+
+    private Map<ComponentKey<?>, ComponentKey<?>> remappedComponentHints =
+        new HashMap<ComponentKey<?>, ComponentKey<?>>();
+
+    public ComponentSelector()
+    {
+    }
+
+    public ComponentSelector merge( final ComponentSelector selectorToCopy )
+    {
+        if ( selectorToCopy != null && !selectorToCopy.isEmpty() )
+        {
+            final Map<ComponentKey<?>, ComponentKey<?>> result = new HashMap<ComponentKey<?>, ComponentKey<?>>();
+            result.putAll( selectorToCopy.remappedComponentHints );
+
+            if ( !remappedComponentHints.isEmpty() )
+            {
+                result.putAll( remappedComponentHints );
+            }
+
+            remappedComponentHints = result;
+        }
+
+        return this;
+    }
+
+    public boolean isEmpty()
+    {
+        return remappedComponentHints.isEmpty();
+    }
+
+    public <T> boolean hasOverride( final Class<T> role, final String hint )
+    {
+        final ComponentKey<T> check = new ComponentKey<T>( role, hint );
+        return remappedComponentHints.containsKey( check );
+    }
+
+    public <T> boolean hasOverride( final Class<T> role )
+    {
+        final ComponentKey<T> check = new ComponentKey<T>( role );
+        return remappedComponentHints.containsKey( check );
+    }
+
+    public Set<ComponentKey<?>> getKeysOverriddenBy( final Class<?> role, final String hint )
+    {
+        @SuppressWarnings( { "rawtypes", "unchecked" } )
+        final ComponentKey check = new ComponentKey( role, hint );
+
+        final Set<ComponentKey<?>> result = new HashSet<ComponentKey<?>>();
+        for ( final Map.Entry<ComponentKey<?>, ComponentKey<?>> mapping : remappedComponentHints.entrySet() )
+        {
+            if ( mapping.getValue().equals( check ) )
+            {
+                result.add( mapping.getKey() );
+            }
+        }
+
+        return result;
+    }
+
+    public <T> ComponentSelector setSelection( final ComponentKey<T> originalKey, final String newHint )
+    {
+        remappedComponentHints.put( originalKey, new ComponentKey<T>( originalKey.getRoleClass(), newHint ) );
+        return this;
+    }
+
+    public <T> ComponentSelector setSelection( final Class<T> role, final String oldHint, final String newHint )
+    {
+        final ComponentKey<T> originalKey = new ComponentKey<T>( role, oldHint );
+        remappedComponentHints.put( originalKey, new ComponentKey<T>( role, newHint ) );
+        return this;
+    }
+
+    public <T> ComponentSelector setSelection( final Class<T> role, final String newHint )
+    {
+        final ComponentKey<T> originalKey = new ComponentKey<T>( role );
+        remappedComponentHints.put( originalKey, new ComponentKey<T>( role, newHint ) );
+        return this;
+    }
+
+}

Propchange: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/internal/container/ComponentSelector.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/internal/container/InstanceRegistry.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/internal/container/InstanceRegistry.java?rev=1104405&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/internal/container/InstanceRegistry.java (added)
+++ maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/internal/container/InstanceRegistry.java Tue May 17 16:57:50 2011
@@ -0,0 +1,197 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * 
+ * Licensed 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.
+ */
+
+package org.apache.maven.mae.internal.container;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class InstanceRegistry
+{
+
+    private final Map<ComponentKey<?>, Object> instances = new HashMap<ComponentKey<?>, Object>();
+
+    public InstanceRegistry()
+    {
+    }
+
+    public InstanceRegistry( final InstanceRegistry... delegates )
+    {
+        if ( delegates != null && delegates.length > 0 )
+        {
+            for ( final InstanceRegistry delegate : delegates )
+            {
+                overrideMerge( delegate );
+            }
+        }
+    }
+
+    public boolean has( final ComponentKey<?> key )
+    {
+        if ( key == null )
+        {
+            return false;
+        }
+
+        return instances.containsKey( key );
+    }
+
+    public <T> boolean has( final Class<T> role, final String hint )
+    {
+        return has( new ComponentKey<T>( role, hint ) );
+    }
+
+    public <T> T get( final ComponentKey<T> key )
+    {
+        return key.castValue( instances.get( key ) );
+    }
+
+    public <T> T get( final Class<T> role, final String hint )
+    {
+        return get( new ComponentKey<T>( role, hint ) );
+    }
+
+    public <C, T extends C> InstanceRegistry add( final ComponentKey<C> key, final T instance )
+    {
+        if ( instance != null )
+        {
+            instances.put( key, instance );
+        }
+        return this;
+    }
+
+    public <C, T extends C> InstanceRegistry add( final Class<C> role, final String hint, final T instance )
+    {
+        if ( role == null )
+        {
+            throw new NullPointerException( "Role class is null." );
+        }
+
+        if ( instance == null )
+        {
+            throw new NullPointerException( "Instance is null." );
+        }
+
+        if ( !role.isAssignableFrom( instance.getClass() ) )
+        {
+            throw new IllegalArgumentException( "Instance class: " + instance.getClass().getName()
+                            + " is not assignable to role: " + role.getClass() );
+        }
+
+        return add( new ComponentKey<C>( role, hint ), instance );
+    }
+
+    public <C, T extends C> InstanceRegistry add( final Class<C> role, final T instance )
+    {
+        if ( role == null )
+        {
+            throw new NullPointerException( "Role class is null." );
+        }
+
+        if ( instance == null )
+        {
+            throw new NullPointerException( "Instance is null." );
+        }
+
+        if ( !role.isAssignableFrom( instance.getClass() ) )
+        {
+            throw new IllegalArgumentException( "Instance class: " + instance.getClass().getName()
+                            + " is not assignable to role: " + role.getClass() );
+        }
+
+        return add( new ComponentKey<C>( role ), instance );
+    }
+
+    @SuppressWarnings( { "unchecked", "rawtypes" } )
+    public <C, T extends C> InstanceRegistry setVirtualInstance( final ComponentKey<C> key, final T instance )
+    {
+        final Object virt = instances.get( key );
+        if ( virt != null && ( virt instanceof VirtualInstance ) )
+        {
+            final VirtualInstance vi = (VirtualInstance) virt;
+            if ( vi.getVirtualClass().equals( key.getRoleClass() ) && vi.getRawInstance() == null )
+            {
+                vi.setInstance( instance );
+            }
+        }
+
+        return this;
+    }
+
+    public <C, T extends C> InstanceRegistry setVirtualInstance( final Class<C> role, final String hint,
+                                                                 final T instance )
+    {
+        return setVirtualInstance( new ComponentKey<C>( role, hint ), instance );
+    }
+
+    public <C, T extends C> InstanceRegistry setVirtualInstance( final Class<C> role, final T instance )
+    {
+        return setVirtualInstance( new ComponentKey<C>( role ), instance );
+    }
+
+    public <T> InstanceRegistry addVirtual( final ComponentKey<T> key, final VirtualInstance<T> virt )
+    {
+        instances.put( key, virt );
+        return this;
+    }
+
+    public <T> InstanceRegistry addVirtual( final String hint, final VirtualInstance<T> instance )
+    {
+        if ( instance == null )
+        {
+            throw new NullPointerException( "Instance is null." );
+        }
+
+        return addVirtual( new ComponentKey<T>( instance.getVirtualClass(), hint ), instance );
+    }
+
+    public <T> InstanceRegistry addVirtual( final VirtualInstance<T> instance )
+    {
+        if ( instance == null )
+        {
+            throw new NullPointerException( "Instance is null." );
+        }
+
+        return addVirtual( new ComponentKey<T>( instance.getVirtualClass() ), instance );
+    }
+
+    public InstanceRegistry overrideMerge( final InstanceRegistry instanceRegistry )
+    {
+        if ( !instanceRegistry.instances.isEmpty() )
+        {
+            instances.putAll( instanceRegistry.instances );
+        }
+
+        return this;
+    }
+
+    public Map<ComponentKey<?>, Object> getInstances()
+    {
+        return instances;
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public <T> InstanceRegistry add( final T instance )
+    {
+        if ( instance == null )
+        {
+            throw new NullPointerException( "Instance is null." );
+        }
+
+        return add( new ComponentKey<T>( (Class<T>) instance.getClass() ), instance );
+    }
+
+}

Propchange: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/internal/container/InstanceRegistry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/internal/container/ServiceAuthorizer.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/internal/container/ServiceAuthorizer.java?rev=1104405&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/internal/container/ServiceAuthorizer.java (added)
+++ maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/internal/container/ServiceAuthorizer.java Tue May 17 16:57:50 2011
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * 
+ * Licensed 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.
+ */
+
+package org.apache.maven.mae.internal.container;
+
+import java.util.Set;
+
+public class ServiceAuthorizer
+{
+
+    private final Set<ComponentKey<?>> authorizedKeys;
+
+    public ServiceAuthorizer( final Set<ComponentKey<?>> authorizedKeys )
+    {
+        this.authorizedKeys = authorizedKeys;
+    }
+
+    public <T> boolean isAvailable( final Class<T> serviceType )
+    {
+        return authorizedKeys.contains( new ComponentKey<T>( serviceType ) );
+    }
+
+    public <T> boolean isAvailable( final Class<T> serviceType, final String hint )
+    {
+        return authorizedKeys.contains( new ComponentKey<T>( serviceType, hint ) );
+    }
+
+}

Propchange: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/internal/container/ServiceAuthorizer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/internal/container/VirtualInstance.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/internal/container/VirtualInstance.java?rev=1104405&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/internal/container/VirtualInstance.java (added)
+++ maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/internal/container/VirtualInstance.java Tue May 17 16:57:50 2011
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * 
+ * Licensed 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.
+ */
+
+package org.apache.maven.mae.internal.container;
+
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import com.google.inject.Provider;
+
+public class VirtualInstance<T>
+    implements Provider<T>
+{
+
+    @Inject
+    private Injector injector;
+
+    private T instance;
+
+    private final Class<T> virtualClass;
+
+    public VirtualInstance( final Class<T> virtualClass )
+    {
+        this.virtualClass = virtualClass;
+    }
+
+    public void setInstance( final T instance )
+    {
+        this.instance = instance;
+    }
+
+    public Class<T> getVirtualClass()
+    {
+        return virtualClass;
+    }
+
+    public T getRawInstance()
+    {
+        return instance;
+    }
+
+    @Override
+    public T get()
+    {
+        if ( injector != null && instance != null )
+        {
+            injector.injectMembers( instance );
+        }
+
+        return instance;
+    }
+
+}

Propchange: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/internal/container/VirtualInstance.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/io/MAEPrompter.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/io/MAEPrompter.java?rev=1104405&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/io/MAEPrompter.java (added)
+++ maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/io/MAEPrompter.java Tue May 17 16:57:50 2011
@@ -0,0 +1,239 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * 
+ * Licensed 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.
+ */
+
+package org.apache.maven.mae.io;
+
+import org.apache.maven.mae.conf.MAEConfiguration;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.codehaus.plexus.components.interactivity.Prompter;
+import org.codehaus.plexus.components.interactivity.PrompterException;
+import org.codehaus.plexus.util.StringUtils;
+
+import javax.inject.Inject;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.util.Iterator;
+import java.util.List;
+
+import jline.ConsoleReader;
+
+@Component( role = Prompter.class, hint = "emb" )
+public class MAEPrompter
+    implements Prompter
+{
+    @Requirement
+    private final MAEConfiguration embConfig;
+
+    @Inject
+    public MAEPrompter( final MAEConfiguration embConfig )
+    {
+        this.embConfig = embConfig;
+    }
+
+    public String prompt( final String message )
+        throws PrompterException
+    {
+        try
+        {
+            writePrompt( message );
+        }
+        catch ( final IOException e )
+        {
+            throw new PrompterException( "Failed to present prompt", e );
+        }
+
+        try
+        {
+            return readLine();
+        }
+        catch ( final IOException e )
+        {
+            throw new PrompterException( "Failed to read user response", e );
+        }
+    }
+
+    private String readLine()
+        throws IOException
+    {
+        return new BufferedReader( new InputStreamReader( embConfig.getStandardIn() ) ).readLine();
+    }
+
+    public String prompt( final String message, final String defaultReply )
+        throws PrompterException
+    {
+        try
+        {
+            writePrompt( formatMessage( message, null, defaultReply ) );
+        }
+        catch ( final IOException e )
+        {
+            throw new PrompterException( "Failed to present prompt", e );
+        }
+
+        try
+        {
+            String line = readLine();
+
+            if ( StringUtils.isEmpty( line ) )
+            {
+                line = defaultReply;
+            }
+
+            return line;
+        }
+        catch ( final IOException e )
+        {
+            throw new PrompterException( "Failed to read user response", e );
+        }
+    }
+
+    @SuppressWarnings( "rawtypes" )
+    public String prompt( final String message, final List possibleValues, final String defaultReply )
+        throws PrompterException
+    {
+        final String formattedMessage = formatMessage( message, possibleValues, defaultReply );
+
+        String line;
+
+        do
+        {
+            try
+            {
+                writePrompt( formattedMessage );
+            }
+            catch ( final IOException e )
+            {
+                throw new PrompterException( "Failed to present prompt", e );
+            }
+
+            try
+            {
+                line = readLine();
+            }
+            catch ( final IOException e )
+            {
+                throw new PrompterException( "Failed to read user response", e );
+            }
+
+            if ( StringUtils.isEmpty( line ) )
+            {
+                line = defaultReply;
+            }
+
+            if ( line != null && !possibleValues.contains( line ) )
+            {
+                writeLine( "Invalid selection." );
+            }
+        }
+        while ( line == null || !possibleValues.contains( line ) );
+
+        return line;
+    }
+
+    private void writeLine( final String message )
+    {
+        embConfig.getStandardOut().println( message );
+    }
+
+    @SuppressWarnings( "rawtypes" )
+    public String prompt( final String message, final List possibleValues )
+        throws PrompterException
+    {
+        return prompt( message, possibleValues, null );
+    }
+
+    public String promptForPassword( final String message )
+        throws PrompterException
+    {
+        try
+        {
+            writePrompt( message );
+        }
+        catch ( final IOException e )
+        {
+            throw new PrompterException( "Failed to present prompt", e );
+        }
+
+        try
+        {
+            return new ConsoleReader( embConfig.getStandardIn(), new OutputStreamWriter( embConfig.getStandardOut() ) ).readLine( new Character(
+                                                                                                                                                 '*' ) );
+        }
+        catch ( final IOException e )
+        {
+            throw new PrompterException( "Failed to read user response", e );
+        }
+    }
+
+    @SuppressWarnings( "rawtypes" )
+    private String formatMessage( final String message, final List possibleValues, final String defaultReply )
+    {
+        final StringBuffer formatted = new StringBuffer( message.length() * 2 );
+
+        formatted.append( message );
+
+        if ( possibleValues != null && !possibleValues.isEmpty() )
+        {
+            formatted.append( " (" );
+
+            for ( final Iterator it = possibleValues.iterator(); it.hasNext(); )
+            {
+                final String possibleValue = (String) it.next();
+
+                formatted.append( possibleValue );
+
+                if ( it.hasNext() )
+                {
+                    formatted.append( '/' );
+                }
+            }
+
+            formatted.append( ')' );
+        }
+
+        if ( defaultReply != null )
+        {
+            formatted.append( ' ' ).append( defaultReply ).append( ": " );
+        }
+
+        return formatted.toString();
+    }
+
+    private void writePrompt( final String message )
+        throws IOException
+    {
+        embConfig.getStandardOut().print( message + ": " );
+    }
+
+    public void showMessage( final String message )
+        throws PrompterException
+    {
+        try
+        {
+            writePrompt( message );
+        }
+        catch ( final IOException e )
+        {
+            throw new PrompterException( "Failed to present prompt", e );
+        }
+
+    }
+
+}

Propchange: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/io/MAEPrompter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-api/src/test/java/org/apache/maven/mae/ComponentSelectorTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-api/src/test/java/org/apache/maven/mae/ComponentSelectorTest.java?rev=1104405&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-api/src/test/java/org/apache/maven/mae/ComponentSelectorTest.java (added)
+++ maven/sandbox/trunk/mae/mae-api/src/test/java/org/apache/maven/mae/ComponentSelectorTest.java Tue May 17 16:57:50 2011
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * 
+ * Licensed 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.
+ */
+
+package org.apache.maven.mae;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+import org.apache.log4j.SimpleLayout;
+import org.apache.log4j.spi.Configurator;
+import org.apache.log4j.spi.LoggerRepository;
+import org.apache.maven.mae.internal.container.ComponentKey;
+import org.apache.maven.mae.internal.container.ComponentSelector;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Properties;
+import java.util.Set;
+
+/*
+ * 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.
+ */
+
+public class ComponentSelectorTest
+{
+
+    @BeforeClass
+    public static void setupLogging()
+    {
+        final Configurator log4jConfigurator = new Configurator()
+        {
+            @SuppressWarnings( "unchecked" )
+            public void doConfigure( final URL notUsed, final LoggerRepository repo )
+            {
+                repo.getRootLogger().addAppender( new ConsoleAppender( new SimpleLayout() ) );
+
+                final Enumeration<Logger> loggers = repo.getCurrentLoggers();
+                while ( loggers.hasMoreElements() )
+                {
+                    final Logger logger = loggers.nextElement();
+                    logger.setLevel( Level.DEBUG );
+                }
+            }
+        };
+
+        log4jConfigurator.doConfigure( null, LogManager.getLoggerRepository() );
+    }
+
+    @SuppressWarnings( "rawtypes" )
+    @Test
+    public void componentSubstitutionWhenTargetHasRoleHint()
+    {
+        final Properties selectors = new Properties();
+        selectors.setProperty( "role#hint", "other-hint" );
+
+        final ComponentSelector selector = new ComponentSelector().setSelection( String.class, "hint", "other-hint" );
+
+        final Set<ComponentKey<?>> overridden = selector.getKeysOverriddenBy( String.class, "other-hint" );
+        assertEquals( 1, overridden.size() );
+
+        final ComponentKey ok = overridden.iterator().next();
+        assertEquals( "hint", ok.getHint() );
+        assertEquals( String.class, ok.getRoleClass() );
+        assertFalse( selector.hasOverride( String.class, "other-hint" ) );
+        assertTrue( selector.hasOverride( String.class, "hint" ) );
+    }
+
+    @SuppressWarnings( "rawtypes" )
+    @Test
+    public void componentSubstitutionWhenTargetRoleHintIsMissing()
+    {
+        final Properties selectors = new Properties();
+        selectors.setProperty( "role", "other-hint" );
+
+        final ComponentSelector selector = new ComponentSelector().setSelection( String.class, "other-hint" );
+
+        final Set<ComponentKey<?>> overridden = selector.getKeysOverriddenBy( String.class, "other-hint" );
+        assertEquals( 1, overridden.size() );
+
+        final ComponentKey ok = overridden.iterator().next();
+
+        assertEquals( ComponentKey.DEFAULT_HINT, ok.getHint() );
+
+        assertEquals( String.class, ok.getRoleClass() );
+        assertFalse( selector.hasOverride( String.class, "other-hint" ) );
+        assertTrue( selector.hasOverride( String.class ) );
+    }
+
+}

Propchange: maven/sandbox/trunk/mae/mae-api/src/test/java/org/apache/maven/mae/ComponentSelectorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-app/pom.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-app/pom.xml?rev=1104405&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-app/pom.xml (added)
+++ maven/sandbox/trunk/mae/mae-app/pom.xml Tue May 17 16:57:50 2011
@@ -0,0 +1,68 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 2010 Red Hat, Inc.
+  
+  Licensed 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <artifactId>mae</artifactId>
+    <groupId>org.apache.maven.mae</groupId>
+    <version>0.6-SNAPSHOT</version>
+  </parent>
+  
+  <artifactId>mae-app</artifactId>
+  <name>Maven App Engine: MAE Application Hooks</name>
+  
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+  
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.apache.maven.mae</groupId>
+        <artifactId>mae-app-bom</artifactId>
+        <version>${project.version}</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <build>
+  	<plugins>
+  		<plugin>
+  			<groupId>org.codehaus.plexus</groupId>
+  			<artifactId>plexus-component-metadata</artifactId>
+  		</plugin>
+  	</plugins>
+  </build>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.mae</groupId>
+      <artifactId>mae-api</artifactId>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.mae</groupId>
+      <artifactId>mae-booter</artifactId>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+    </dependency>
+  </dependencies>
+</project>

Propchange: maven/sandbox/trunk/mae/mae-app/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-app/src/main/java/org/commonjava/emb/app/AbstractEMBApplication.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-app/src/main/java/org/commonjava/emb/app/AbstractEMBApplication.java?rev=1104405&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-app/src/main/java/org/commonjava/emb/app/AbstractEMBApplication.java (added)
+++ maven/sandbox/trunk/mae/mae-app/src/main/java/org/commonjava/emb/app/AbstractEMBApplication.java Tue May 17 16:57:50 2011
@@ -0,0 +1,227 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * 
+ * Licensed 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.
+ */
+
+package org.commonjava.emb.app;
+
+import org.apache.log4j.Logger;
+import org.apache.maven.mae.MAEException;
+import org.apache.maven.mae.boot.embed.EMBEmbedderBuilder;
+import org.apache.maven.mae.conf.MAEConfiguration;
+import org.apache.maven.mae.conf.MAELibrary;
+import org.apache.maven.mae.conf.VersionProvider;
+import org.apache.maven.mae.conf.ext.ExtensionConfiguration;
+import org.apache.maven.mae.conf.ext.ExtensionConfigurationException;
+import org.apache.maven.mae.conf.loader.InstanceLibraryLoader;
+import org.apache.maven.mae.internal.container.ComponentKey;
+import org.apache.maven.mae.internal.container.ComponentSelector;
+import org.apache.maven.mae.internal.container.InstanceRegistry;
+import org.apache.maven.mae.internal.container.VirtualInstance;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public abstract class AbstractEMBApplication
+    implements EMBApplication
+{
+
+    private final List<MAELibrary> additionalLibraries = new ArrayList<MAELibrary>();
+
+    private final InstanceRegistry instanceRegistry = new InstanceRegistry();
+
+    private transient boolean loaded = false;
+
+    @SuppressWarnings( { "rawtypes", "unchecked" } )
+    protected AbstractEMBApplication()
+    {
+        withLibrary( this );
+        withComponentInstance( new ComponentKey( getClass() ), this );
+    }
+
+    protected final AbstractEMBApplication withLibrary( final MAELibrary library )
+    {
+        additionalLibraries.add( library );
+        return this;
+    }
+
+    @Override
+    public EMBApplication load()
+        throws MAEException
+    {
+        return doLoad();
+    }
+
+    private synchronized EMBApplication doLoad()
+        throws MAEException
+    {
+        if ( loaded )
+        {
+            return this;
+        }
+
+        final EMBEmbedderBuilder builder = new EMBEmbedderBuilder().withLibraryLoader( new InstanceLibraryLoader( additionalLibraries ) );
+
+        beforeLoading();
+        configureBuilder( builder );
+
+        builder.build();
+        for ( final ComponentKey<?> key : getInstanceRegistry().getInstances().keySet() )
+        {
+            try
+            {
+                builder.container().lookup( key.getRoleClass(), key.getHint() );
+            }
+            catch ( final ComponentLookupException e )
+            {
+                throw new MAEException( "Forced member-injection for registered instance: %s failed. Reason: %s", e,
+                                        key, e.getMessage() );
+            }
+        }
+
+        afterLoading();
+
+        loaded = true;
+
+        return this;
+    }
+
+    @SuppressWarnings( { "unchecked", "rawtypes" } )
+    protected final void withComponentInstance( final Object instance )
+    {
+        getInstanceRegistry().add( new ComponentKey( instance.getClass() ), instance );
+    }
+
+    protected final <C> void withVirtualComponent( final Class<C> virtualClass )
+    {
+        getInstanceRegistry().addVirtual( new VirtualInstance<C>( virtualClass ) );
+    }
+
+    protected final <C, T extends C> void setVirtualInstance( final Class<C> virtualKey, final T instance )
+    {
+        getInstanceRegistry().setVirtualInstance( virtualKey, instance );
+    }
+
+    protected final <C> void withComponentInstance( final ComponentKey<C> componentKey, final C instance )
+    {
+        getInstanceRegistry().add( componentKey, instance );
+    }
+
+    protected final <C> void withVirtualComponent( final ComponentKey<C> virtualKey )
+    {
+        getInstanceRegistry().addVirtual( virtualKey, new VirtualInstance<C>( virtualKey.getRoleClass() ) );
+    }
+
+    protected final <C, T extends C> void setVirtualInstance( final ComponentKey<C> virtualKey, final T instance )
+    {
+        getInstanceRegistry().setVirtualInstance( virtualKey, instance );
+    }
+
+    protected void configureBuilder( final EMBEmbedderBuilder builder )
+        throws MAEException
+    {
+    }
+
+    protected void beforeLoading()
+        throws MAEException
+    {
+    }
+
+    protected void afterLoading()
+        throws MAEException
+    {
+    }
+
+    @Override
+    public Logger getLogger()
+    {
+        return Logger.getLogger( getLogHandle() );
+    }
+
+    @Override
+    public ExtensionConfiguration getConfiguration()
+    {
+        return null;
+    }
+
+    @Override
+    public ComponentSelector getComponentSelector()
+    {
+        return null;
+    }
+
+    @Override
+    public Set<ComponentKey<?>> getExportedComponents()
+    {
+        return null;
+    }
+
+    @Override
+    public Set<ComponentKey<?>> getManagementComponents( final Class<?> managementType )
+    {
+        return null;
+    }
+
+    @Override
+    public Map<Class<?>, Set<ComponentKey<?>>> getManagementComponents()
+    {
+        return null;
+    }
+
+    @Override
+    public String getLabel()
+    {
+        return getName();
+    }
+
+    @Override
+    public String getLogHandle()
+    {
+        return getId();
+    }
+
+    @Override
+    public void loadConfiguration( final MAEConfiguration embConfig )
+        throws ExtensionConfigurationException
+    {
+    }
+
+    @Override
+    public final InstanceRegistry getInstanceRegistry()
+    {
+        return instanceRegistry;
+    }
+
+    @Override
+    public String getVersion()
+    {
+        final VersionProvider provider = getVersionProvider();
+        if ( provider == null )
+        {
+            throw new IllegalStateException( "Your application booter: " + getClass().getName()
+                            + " must implement either getVersion() or getVersionProvider()." );
+        }
+
+        return provider.getVersion();
+    }
+
+    protected VersionProvider getVersionProvider()
+    {
+        return null;
+    }
+
+}

Propchange: maven/sandbox/trunk/mae/mae-app/src/main/java/org/commonjava/emb/app/AbstractEMBApplication.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-app/src/main/java/org/commonjava/emb/app/EMBApplication.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-app/src/main/java/org/commonjava/emb/app/EMBApplication.java?rev=1104405&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-app/src/main/java/org/commonjava/emb/app/EMBApplication.java (added)
+++ maven/sandbox/trunk/mae/mae-app/src/main/java/org/commonjava/emb/app/EMBApplication.java Tue May 17 16:57:50 2011
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * 
+ * Licensed 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.
+ */
+
+package org.commonjava.emb.app;
+
+import org.apache.maven.mae.MAEException;
+import org.apache.maven.mae.conf.MAELibrary;
+
+public interface EMBApplication
+    extends MAELibrary
+{
+    EMBApplication load()
+        throws MAEException;
+}

Propchange: maven/sandbox/trunk/mae/mae-app/src/main/java/org/commonjava/emb/app/EMBApplication.java
------------------------------------------------------------------------------
    svn:eol-style = native