Author: jdcasey Date: Fri May 27 02:50:04 2011 New Revision: 1128144 URL: http://svn.apache.org/viewvc?rev=1128144&view=rev Log: Adding documentation and removing vestigial code from early days.
Modified: maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/MAEConfiguration.java maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/app/AbstractMAEApplication.java maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/app/MAEApplication.java maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/Maven3BooterLibrary.java maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/embed/MAEEmbedder.java maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/embed/MAEEmbedderBuilder.java maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/main/MAEMain.java maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/services/DefaultMAEServiceManager.java maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/services/MAEServiceManager.java maven/sandbox/trunk/mae/mae-container/src/main/java/org/apache/maven/mae/internal/container/ExtrudablePlexusContainer.java maven/sandbox/trunk/mae/mae-container/src/main/java/org/apache/maven/mae/internal/container/MAEContainer.java maven/sandbox/trunk/mae/mae-container/src/main/java/org/apache/maven/mae/internal/container/guice/InstanceBindingModule.java maven/sandbox/trunk/mae/mae-container/src/main/java/org/apache/maven/mae/internal/container/guice/SelectingTypeBinder.java Modified: 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=1128144&r1=1128143&r2=1128144&view=diff ============================================================================== --- maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/MAEConfiguration.java (original) +++ maven/sandbox/trunk/mae/mae-api/src/main/java/org/apache/maven/mae/conf/MAEConfiguration.java Fri May 27 02:50:04 2011 @@ -68,7 +68,7 @@ public class MAEConfiguration { } - public MAEConfiguration withEMBExecutionRequest( final MAEExecutionRequest request ) + public MAEConfiguration withExecutionRequest( final MAEExecutionRequest request ) { executionRequest = request; return this; Modified: maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/app/AbstractMAEApplication.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/app/AbstractMAEApplication.java?rev=1128144&r1=1128143&r2=1128144&view=diff ============================================================================== --- maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/app/AbstractMAEApplication.java (original) +++ maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/app/AbstractMAEApplication.java Fri May 27 02:50:04 2011 @@ -21,6 +21,7 @@ package org.apache.maven.mae.app; import org.apache.log4j.Logger; import org.apache.maven.mae.MAEException; +import org.apache.maven.mae.boot.embed.MAEEmbedder; import org.apache.maven.mae.boot.embed.MAEEmbedderBuilder; import org.apache.maven.mae.conf.MAEConfiguration; import org.apache.maven.mae.conf.MAELibrary; @@ -39,6 +40,14 @@ import java.util.List; import java.util.Map; import java.util.Set; +/** + * {@link MAEApplication} implementation that provides support for loading a full Maven component + * environment, complete with {@link MAELibrary}'s, {@link ComponentSelector} and {@link InstanceRegistry}. + * This class supervises the assembly of the environment, giving the application developer an easy + * way to inject the behavior he needs. + * + * @author John Casey + */ public abstract class AbstractMAEApplication implements MAEApplication { @@ -56,12 +65,21 @@ public abstract class AbstractMAEApplica withComponentInstance( new ComponentKey( getClass() ), this ); } + /** + * Programmatically add a new {@link MAELibrary} instance, beyond those that are automatically + * detected via the /META-INF/services/org.apache.maven.mae.conf.MAELibrary files on the + * classpath. + */ protected final AbstractMAEApplication withLibrary( final MAELibrary library ) { additionalLibraries.add( library ); return this; } + /** + * {@inheritDoc} + * @see org.apache.maven.mae.app.MAEApplication#load() + */ @Override public MAEApplication load() throws MAEException @@ -69,7 +87,25 @@ public abstract class AbstractMAEApplica return doLoad(); } - private synchronized MAEApplication doLoad() + /** + * Carry out the application loading process. This means: + * <br/> + * <ul> + * <li>Create a new {@link MAEEmbedderBuilder}</li> + * <li>Add to that an {@link InstanceLibraryLoader} to handle libraries that were + * programmatically added here</li> + * <li>Call {@link AbstractMAEApplication#beforeLoading()}</li> + * <li>Call {@link AbstractMAEApplication#configureBuilder(MAEEmbedderBuilder)} to allow + * fine-tuning of the {@link MAEEmbedderBuilder} instance</li> + * <li>Call {@link MAEEmbedderBuilder#build} to create an instance of {@link MAEEmbedder}</li> + * <li>For each instance in the {@link InstanceRegistry}, lookup via {@link MAEEmbedder#container()} + * to ensure injectable component dependencies are filled</li> + * <li>Call {@link AbstractMAEApplication#afterLoading()}</li> + * <li>Set the loaded flag, which will prevent this process from repeating for an application + * that has already been loaded</li> + * </ul> + */ + private synchronized final MAEApplication doLoad() throws MAEException { if ( loaded ) @@ -79,10 +115,9 @@ public abstract class AbstractMAEApplica final MAEEmbedderBuilder builder = new MAEEmbedderBuilder().withLibraryLoader( new InstanceLibraryLoader( additionalLibraries ) ); - beforeLoading(); configureBuilder( builder ); - builder.build(); + MAEEmbedder embedder = builder.build(); for ( final ComponentKey<?> key : getInstanceRegistry().getInstances().keySet() ) { try @@ -96,55 +131,82 @@ public abstract class AbstractMAEApplica } } - afterLoading(); + afterLoading( embedder ); loaded = true; return this; } + /** + * Register a new, external component instance for injection into other components, or to + * have components injected into it. + */ @SuppressWarnings( { "unchecked", "rawtypes" } ) protected final void withComponentInstance( final Object instance ) { getInstanceRegistry().add( new ComponentKey( instance.getClass() ), instance ); } + /** + * Register a new {@link VirtualInstance}, which allows the component environment to bind its + * requirements without actually having access to the component instance. The instance itself + * will be injected into the {@link VirtualInstance} later. + */ protected final <C> void withVirtualComponent( final Class<C> virtualClass ) { getInstanceRegistry().addVirtual( new VirtualInstance<C>( virtualClass ) ); } + /** + * Set the actual instance on a {@link VirtualInstance} that was registered previously. + */ protected final <C, T extends C> void setVirtualInstance( final Class<C> virtualKey, final T instance ) { getInstanceRegistry().setVirtualInstance( virtualKey, instance ); } + /** + * Register a new, external component instance to make it available for injection, or to allow + * other components to be injected into it. + */ protected final <C> void withComponentInstance( final ComponentKey<C> componentKey, final C instance ) { getInstanceRegistry().add( componentKey, instance ); } + /** + * Register a new {@link VirtualInstance}, which allows the component environment to bind its + * requirements without actually having access to the component instance. The instance itself + * will be injected into the {@link VirtualInstance} later. + */ protected final <C> void withVirtualComponent( final ComponentKey<C> virtualKey ) { getInstanceRegistry().addVirtual( virtualKey, new VirtualInstance<C>( virtualKey.getRoleClass() ) ); } + /** + * Set the actual instance on a {@link VirtualInstance} that was registered previously. + */ protected final <C, T extends C> void setVirtualInstance( final ComponentKey<C> virtualKey, final T instance ) { getInstanceRegistry().setVirtualInstance( virtualKey, instance ); } + /** + * Fine-tune the {@link MAEEmbedderBuilder} instance before it is used to create the + * {@link MAEEmbedder} that will be used to load the application components. + */ protected void configureBuilder( final MAEEmbedderBuilder builder ) throws MAEException { } - protected void beforeLoading() - throws MAEException - { - } - - protected void afterLoading() + /** + * Hook allowing application developers access to the {@link MAEEmbedder} just after the registered + * external component instances have been injected, but before loading is considered complete. + */ + protected void afterLoading(MAEEmbedder embedder) throws MAEException { } Modified: maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/app/MAEApplication.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/app/MAEApplication.java?rev=1128144&r1=1128143&r2=1128144&view=diff ============================================================================== --- maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/app/MAEApplication.java (original) +++ maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/app/MAEApplication.java Fri May 27 02:50:04 2011 @@ -22,9 +22,16 @@ package org.apache.maven.mae.app; import org.apache.maven.mae.MAEException; import org.apache.maven.mae.conf.MAELibrary; +/** + * Interface providing basic support for loading a Maven component environment. + */ public interface MAEApplication extends MAELibrary { + /** + * Assemble the component environment, based on the information given in implementors of this + * abstract class and auto-detected libraries. + */ MAEApplication load() throws MAEException; } Modified: maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/Maven3BooterLibrary.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/Maven3BooterLibrary.java?rev=1128144&r1=1128143&r2=1128144&view=diff ============================================================================== --- maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/Maven3BooterLibrary.java (original) +++ maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/Maven3BooterLibrary.java Fri May 27 02:50:04 2011 @@ -30,6 +30,6 @@ public class Maven3BooterLibrary { public Maven3BooterLibrary() { - super( "boot", "EMB-Booter", new MavenPomVersionProvider( "org.commonjava.emb", "emb-booter" ), "core" ); + super( "boot", "MAE-Booter", new MavenPomVersionProvider( "org.apache.maven.mae", "mae-booter" ), "core" ); } } Modified: maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/embed/MAEEmbedder.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/embed/MAEEmbedder.java?rev=1128144&r1=1128143&r2=1128144&view=diff ============================================================================== --- maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/embed/MAEEmbedder.java (original) +++ maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/embed/MAEEmbedder.java Fri May 27 02:50:04 2011 @@ -32,16 +32,17 @@ import org.apache.maven.execution.MavenE import org.apache.maven.execution.MavenExecutionResult; import org.apache.maven.lifecycle.LifecycleExecutionException; import org.apache.maven.mae.MAEExecutionRequest; +import org.apache.maven.mae.app.AbstractMAEApplication; import org.apache.maven.mae.boot.log.EventLogger; import org.apache.maven.mae.boot.main.MAEMain; import org.apache.maven.mae.boot.services.MAEServiceManager; import org.apache.maven.mae.conf.MAEConfiguration; import org.apache.maven.mae.conf.MAELibrary; import org.apache.maven.mae.conf.loader.MAELibraryLoader; -import org.apache.maven.mae.conf.mgmt.MAEManagementException; -import org.apache.maven.mae.conf.mgmt.MAEManagementView; import org.apache.maven.mae.conf.mgmt.LoadOnFinish; import org.apache.maven.mae.conf.mgmt.LoadOnStart; +import org.apache.maven.mae.conf.mgmt.MAEManagementException; +import org.apache.maven.mae.conf.mgmt.MAEManagementView; import org.apache.maven.mae.internal.container.ComponentKey; import org.apache.maven.mae.internal.container.ExtrudablePlexusContainer; import org.apache.maven.project.MavenProject; @@ -66,8 +67,6 @@ import org.sonatype.plexus.components.se import org.sonatype.plexus.components.sec.dispatcher.SecUtil; import org.sonatype.plexus.components.sec.dispatcher.model.SettingsSecurity; -import com.google.inject.Injector; - import java.io.IOException; import java.io.PrintStream; import java.util.Collection; @@ -77,11 +76,18 @@ import java.util.Map; import java.util.Properties; import java.util.Set; +/** + * The core of the embeddable Maven environment. This class is used as the main interface to the embedded + * Maven environment for the application developer. The only other interface is component-instance + * injection, available through the configuration of {@link AbstractMAEApplication} subclasses. + * + * @author John Casey + */ @Component( role = MAEEmbedder.class ) public class MAEEmbedder { - private static boolean embInfoShown; + private static boolean infoShown; private final Logger logger; @@ -109,6 +115,8 @@ public class MAEEmbedder private boolean infoPrinted = false; + private boolean stopped = false; + MAEEmbedder( final Maven maven, final MAEConfiguration embConfiguration, final ExtrudablePlexusContainer container, final SettingsBuilder settingsBuilder, final MavenExecutionRequestPopulator executionRequestPopulator, final DefaultSecDispatcher securityDispatcher, final MAEServiceManager serviceManager, @@ -130,30 +138,54 @@ public class MAEEmbedder this.showVersion = showVersion; } - public synchronized Injector injector() +// public synchronized Injector injector() +// throws MAEEmbeddingException +// { +// printInfo( null ); +// return container.getInjector(); +// } + + /** + * Wire a series of externally managed objects with components from the Maven environment, + * according to component annotations in those instances. + */ + public synchronized Map<Object, Throwable> wire( final Object... instances ) throws MAEEmbeddingException { + checkStopped(); + printInfo( null ); - return container.getInjector(); + return container.extrudeDependencies( instances ); } - public synchronized Map<Object, Throwable> wire( final Object... instances ) - throws MAEEmbeddingException + protected void checkStopped() { - printInfo( null ); - return container.extrudeDependencies( instances ); + if ( stopped ) + { + throw new IllegalStateException( "This MAEEmbedder instance has been shutdown! It is no longer available for use." ); + } } + /** + * Retrieve the {@link MAEServiceManager} that was initialized to work with this embedded Maven + * environment. + */ public synchronized MAEServiceManager serviceManager() - throws MAEEmbeddingException { + checkStopped(); + printInfo( null ); return serviceManager; } + /** + * Execute a Maven build, using the normal request/response paradigm. + */ public MavenExecutionResult execute( final MAEExecutionRequest request ) throws MAEEmbeddingException { + checkStopped(); + final PrintStream oldOut = System.out; try { @@ -170,14 +202,20 @@ public class MAEEmbedder } finally { - doExecutionFinished(); + shutdown(); System.setOut( oldOut ); } } - + + /** + * Encrypt the master password that's used to decrypt settings information such as server + * passwords. + */ public String encryptMasterPassword( final MAEExecutionRequest request ) throws MAEEmbeddingException { + checkStopped(); + printInfo( null ); String passwd = request.getPasswordToEncyrpt(); @@ -201,9 +239,14 @@ public class MAEEmbedder } } + /** + * Encrypt a password that will be put in the settings.xml file, as for server authentication. + */ public String encryptPassword( final MAEExecutionRequest request ) throws MAEEmbeddingException { + checkStopped(); + printInfo( null ); final String passwd = request.getPasswordToEncyrpt(); @@ -254,6 +297,8 @@ public class MAEEmbedder protected void doExecutionStarting() throws MAEEmbeddingException { + checkStopped(); + for ( final MAELibrary library : embConfiguration.getLibraries() ) { final Set<ComponentKey<?>> components = library.getManagementComponents( LoadOnStart.class ); @@ -278,8 +323,19 @@ public class MAEEmbedder } } - protected void doExecutionFinished() + /** + * Perform any shutdown functions associated with this embedder and its component environment. + * <br/> + * <b>NOTE:</b> After this method is called, this embedder can no longer be used. + */ + public synchronized void shutdown() { + if ( stopped ) + { + return; + } + + stopped = true; for ( final MAELibrary library : embConfiguration.getLibraries() ) { final Set<ComponentKey<?>> components = library.getManagementComponents( LoadOnFinish.class ); @@ -306,9 +362,11 @@ public class MAEEmbedder protected synchronized void injectEnvironment( final MAEExecutionRequest request ) throws MAEEmbeddingException { + checkStopped(); + injectLogSettings( request ); - initializeEMB( request ); + initialize( request ); injectProperties( request ); @@ -317,9 +375,9 @@ public class MAEEmbedder injectFromProperties( request ); } - private void initializeEMB( final MAEExecutionRequest request ) + private void initialize( final MAEExecutionRequest request ) { - embConfiguration.withEMBExecutionRequest( request ); + embConfiguration.withExecutionRequest( request ); if ( request.isInteractiveMode() ) { embConfiguration.interactive(); @@ -341,6 +399,8 @@ public class MAEEmbedder protected void injectFromProperties( final MAEExecutionRequest request ) { + checkStopped(); + String localRepoProperty = request.getUserProperties().getProperty( MAEMain.LOCAL_REPO_PROPERTY ); if ( localRepoProperty == null ) @@ -356,6 +416,8 @@ public class MAEEmbedder protected void injectLogSettings( final MAEExecutionRequest request ) { + checkStopped(); + final int logLevel = request.getLoggingLevel(); if ( Logger.LEVEL_DEBUG == logLevel ) @@ -463,20 +525,24 @@ public class MAEEmbedder } } - public static void showEMBInfo( final MAEConfiguration embConfig, final List<MAELibraryLoader> loaders, + /** + * Print information about the {@link MAELibrary} instances loaded into this environment to + * the {@link PrintStream} parameter. + */ + public static void showInfo( final MAEConfiguration config, final List<MAELibraryLoader> loaders, final PrintStream standardOut ) throws IOException { - if ( embInfoShown ) + if ( infoShown ) { return; } standardOut.println(); - standardOut.println( "-- EMB Libraries Loaded --" ); + standardOut.println( "-- MAE Libraries Loaded --" ); standardOut.println(); - final Collection<MAELibrary> libraries = loadLibraries( embConfig, loaders ); + final Collection<MAELibrary> libraries = loadLibraries( config, loaders ); for ( final MAELibrary ext : libraries ) { standardOut.println( "+" + ext.getLabel() + " (Log handle: '" + ext.getLogHandle() + "')" ); @@ -486,14 +552,18 @@ public class MAEEmbedder standardOut.println( "--------------------------" ); standardOut.println(); - embInfoShown = true; + infoShown = true; } - public static void showVersion( final MAEConfiguration embConfig, final List<MAELibraryLoader> loaders, + /** + * Print the information about {@link MAELibrary} instances loaded, along with version information + * about this Maven environment in general, to the provided {@link PrintStream} parameter. + */ + public static void showVersion( final MAEConfiguration config, final List<MAELibraryLoader> loaders, final PrintStream standardOut ) throws IOException { - showEMBInfo( embConfig, loaders, standardOut ); + showInfo( config, loaders, standardOut ); CLIReportingUtils.showVersion( standardOut ); } @@ -535,6 +605,10 @@ public class MAEEmbedder } } + /** + * Print error output from a Maven execution request, in the familiar format, to the {@link Logger} + * instance used by this embedder. + */ public int formatErrorOutput( final MAEExecutionRequest request, final MavenExecutionResult result ) { if ( result.hasExceptions() ) Modified: maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/embed/MAEEmbedderBuilder.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/embed/MAEEmbedderBuilder.java?rev=1128144&r1=1128143&r2=1128144&view=diff ============================================================================== --- maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/embed/MAEEmbedderBuilder.java (original) +++ maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/embed/MAEEmbedderBuilder.java Fri May 27 02:50:04 2011 @@ -494,22 +494,22 @@ public class MAEEmbedderBuilder public synchronized ComponentSelector selector() { - return embConfiguration().getComponentSelector(); + return configuration().getComponentSelector(); } public synchronized InstanceRegistry instanceRegistry() { - return embConfiguration().getInstanceRegistry(); + return configuration().getInstanceRegistry(); } - public MAEEmbedderBuilder withEMBConfiguration( final MAEConfiguration config ) + public MAEEmbedderBuilder withConfiguration( final MAEConfiguration config ) { embConfiguration = config; embConfigurationProvided = true; return this; } - public synchronized MAEConfiguration embConfiguration() + public synchronized MAEConfiguration configuration() { final String[] debugLogHandles = debugLogHandles(); if ( !logHandlesConfigured && debugLogHandles != null ) @@ -545,7 +545,7 @@ public class MAEEmbedderBuilder if ( debugLogHandles != null && Arrays.binarySearch( debugLogHandles, MAEConfiguration.STANDARD_LOG_HANDLE_CORE ) > -1 ) { - MAEEmbedder.showEMBInfo( embConfiguration, loaders, standardOut() ); + MAEEmbedder.showInfo( embConfiguration, loaders, standardOut() ); } } catch ( final IOException e ) @@ -804,7 +804,7 @@ public class MAEEmbedderBuilder throws MAEEmbeddingException { final MAEEmbedder embedder = - new MAEEmbedder( maven(), embConfiguration(), container(), settingsBuilder(), executionRequestPopulator(), + new MAEEmbedder( maven(), configuration(), container(), settingsBuilder(), executionRequestPopulator(), securityDispatcher(), serviceManager(), libraryLoaders(), standardOut(), logger(), shouldShowErrors(), showVersion() ); @@ -819,7 +819,7 @@ public class MAEEmbedderBuilder if ( embedder == null ) { logger(); - embConfiguration(); + configuration(); mavenHome(); wireLogging(); Modified: maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/main/MAEMain.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/main/MAEMain.java?rev=1128144&r1=1128143&r2=1128144&view=diff ============================================================================== --- maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/main/MAEMain.java (original) +++ maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/main/MAEMain.java Fri May 27 02:50:04 2011 @@ -201,7 +201,7 @@ public class MAEMain { try { - MAEEmbedder.showVersion( cliRequest.builder.embConfiguration(), cliRequest.builder.libraryLoaders(), + MAEEmbedder.showVersion( cliRequest.builder.configuration(), cliRequest.builder.libraryLoaders(), cliRequest.builder.standardOut() ); } catch ( final IOException e ) @@ -326,7 +326,7 @@ public class MAEMain if ( commandLine.hasOption( CLIManager.BATCH_MODE ) ) { request.setInteractiveMode( false ); - cliRequest.builder.embConfiguration().nonInteractive(); + cliRequest.builder.configuration().nonInteractive(); } boolean noSnapshotUpdates = false; Modified: maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/services/DefaultMAEServiceManager.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/services/DefaultMAEServiceManager.java?rev=1128144&r1=1128143&r2=1128144&view=diff ============================================================================== --- maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/services/DefaultMAEServiceManager.java (original) +++ maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/services/DefaultMAEServiceManager.java Fri May 27 02:50:04 2011 @@ -42,11 +42,9 @@ import org.sonatype.aether.util.DefaultR @Component( role = MAEServiceManager.class ) public class DefaultMAEServiceManager - implements MAEServiceManager/* , Contextualizable */ + implements MAEServiceManager { - // private final Logger logger = Logger.getLogger( EMBConfiguration.STANDARD_LOG_HANDLE_CORE ); - @Requirement private ProjectBuilder projectBuilder; @@ -87,11 +85,19 @@ public class DefaultMAEServiceManager // this.container = container; // } + /** + * {@inheritDoc} + */ + @Override public ProjectBuilder projectBuilder() { return projectBuilder; } + /** + * {@inheritDoc} + */ + @Override public DefaultProjectBuildingRequest createProjectBuildingRequest() throws MAEEmbeddingException { @@ -106,17 +112,28 @@ public class DefaultMAEServiceManager return req; } + /** + * {@inheritDoc} + */ + @Override public RepositorySystem mavenRepositorySystem() { return repositorySystem; } + /** + * {@inheritDoc} + */ @Override public org.sonatype.aether.RepositorySystem aetherRepositorySystem() { return aetherRepositorySystem; } + /** + * {@inheritDoc} + */ + @Override public RepositorySystemSession createAetherRepositorySystemSession() throws MAEEmbeddingException { @@ -135,6 +152,10 @@ public class DefaultMAEServiceManager } } + /** + * {@inheritDoc} + */ + @Override public RepositorySystemSession createAetherRepositorySystemSession( MavenExecutionRequest request ) throws MAEEmbeddingException { @@ -163,6 +184,10 @@ public class DefaultMAEServiceManager } } + /** + * {@inheritDoc} + */ + @Override public synchronized ArtifactRepository defaultLocalRepository() throws MAEEmbeddingException { @@ -182,6 +207,9 @@ public class DefaultMAEServiceManager return defaultLocalRepo; } + /** + * {@inheritDoc} + */ @Override public <T> T service( final Class<T> type ) throws MAEEmbeddingException @@ -207,6 +235,9 @@ public class DefaultMAEServiceManager } } + /** + * {@inheritDoc} + */ @Override public <T> T service( final Class<T> type, final String hint ) throws MAEEmbeddingException @@ -232,11 +263,4 @@ public class DefaultMAEServiceManager } } - // @Override - // public void contextualize( final Context ctx ) - // throws ContextException - // { - // container = (PlexusContainer) ctx.get( PlexusConstants.PLEXUS_KEY ); - // } - } Modified: maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/services/MAEServiceManager.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/services/MAEServiceManager.java?rev=1128144&r1=1128143&r2=1128144&view=diff ============================================================================== --- maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/services/MAEServiceManager.java (original) +++ maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/boot/services/MAEServiceManager.java Fri May 27 02:50:04 2011 @@ -22,38 +22,85 @@ package org.apache.maven.mae.boot.servic import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.mae.boot.embed.MAEEmbeddingException; +import org.apache.maven.mae.conf.MAELibrary; import org.apache.maven.project.DefaultProjectBuildingRequest; import org.apache.maven.project.ProjectBuilder; +import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.repository.RepositorySystem; import org.sonatype.aether.RepositorySystemSession; +/** + * Service manager used as an aid in constructing complex objects correctly for use in Maven, such + * as {@link RepositorySystemSession} instances, which are used to resolve artifacts, or + * {@link ProjectBuildingRequest} instances, used to build maven projects from their corresponding + * POM files or artifact coordinates. + * + * @author John Casey + */ public interface MAEServiceManager { + /** + * Retrieve the Maven {@link ProjectBuilder} component. + */ ProjectBuilder projectBuilder() throws MAEEmbeddingException; + /** + * Create a new {@link ProjectBuildingRequest} to be used in building project instances from + * POM files or artifact coordinates. + */ DefaultProjectBuildingRequest createProjectBuildingRequest() throws MAEEmbeddingException; + /** + * Retrieve the Maven {@link RepositorySystem} component. + */ RepositorySystem mavenRepositorySystem() throws MAEEmbeddingException; + /** + * Retrieve the aether {@link org.sonatype.aether.RepositorySystem} component. + */ org.sonatype.aether.RepositorySystem aetherRepositorySystem() throws MAEEmbeddingException; + /** + * Create a new {@link RepositorySystemSession} for resolving artifacts, using default configurations. + */ RepositorySystemSession createAetherRepositorySystemSession() throws MAEEmbeddingException; + /** + * Create a new {@link RepositorySystemSession} for resolving artifacts, based on the configuration + * of a {@link MavenExecutionRequest}. + */ RepositorySystemSession createAetherRepositorySystemSession( MavenExecutionRequest request ) throws MAEEmbeddingException; + /** + * Retrieve a component from the Maven component environment, based on its class. + * <br/> + * <b>NOTE:</b> This method requires that some {@link MAELibrary} present in the current environment + * has granted permission to lookup the component in question. + */ <T> T service( Class<T> type ) throws MAEEmbeddingException; + /** + * Retrieve a component from the Maven component environment, based on its class and an implementation + * hint. + * <br/> + * <b>NOTE:</b> This method requires that some {@link MAELibrary} present in the current environment + * has granted permission to lookup the component in question. + */ <T> T service( Class<T> type, String hint ) throws MAEEmbeddingException; + /** + * Retrieve an {@link ArtifactRepository} instance configured for the default location of the + * Maven local repository. + */ ArtifactRepository defaultLocalRepository() throws MAEEmbeddingException; Modified: maven/sandbox/trunk/mae/mae-container/src/main/java/org/apache/maven/mae/internal/container/ExtrudablePlexusContainer.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-container/src/main/java/org/apache/maven/mae/internal/container/ExtrudablePlexusContainer.java?rev=1128144&r1=1128143&r2=1128144&view=diff ============================================================================== --- maven/sandbox/trunk/mae/mae-container/src/main/java/org/apache/maven/mae/internal/container/ExtrudablePlexusContainer.java (original) +++ maven/sandbox/trunk/mae/mae-container/src/main/java/org/apache/maven/mae/internal/container/ExtrudablePlexusContainer.java Fri May 27 02:50:04 2011 @@ -25,6 +25,13 @@ import com.google.inject.Injector; import java.util.Map; +/** + * Extension to the {@link MutablePlexusContainer} interface, which allows injection of components + * into existing objects. Also, retrieving the Guice {@link Injector} instance used in the container, + * for binding into an outer Guice context... + * + * @author John Casey + */ public interface ExtrudablePlexusContainer extends MutablePlexusContainer { Modified: maven/sandbox/trunk/mae/mae-container/src/main/java/org/apache/maven/mae/internal/container/MAEContainer.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-container/src/main/java/org/apache/maven/mae/internal/container/MAEContainer.java?rev=1128144&r1=1128143&r2=1128144&view=diff ============================================================================== --- maven/sandbox/trunk/mae/mae-container/src/main/java/org/apache/maven/mae/internal/container/MAEContainer.java (original) +++ maven/sandbox/trunk/mae/mae-container/src/main/java/org/apache/maven/mae/internal/container/MAEContainer.java Fri May 27 02:50:04 2011 @@ -93,6 +93,11 @@ import java.util.concurrent.atomic.Atomi /** * {@link PlexusContainer} shim that delegates to a Plexus-aware Guice {@link Injector}. + * <br/> + * This variant provides supports for {@link ComponentSelector} and {@link InstanceRegistry}, giving + * the application developer more control over the component environment. + * + * @author John Casey */ @SuppressWarnings( { "unchecked", "rawtypes" } ) public final class MAEContainer Modified: maven/sandbox/trunk/mae/mae-container/src/main/java/org/apache/maven/mae/internal/container/guice/InstanceBindingModule.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-container/src/main/java/org/apache/maven/mae/internal/container/guice/InstanceBindingModule.java?rev=1128144&r1=1128143&r2=1128144&view=diff ============================================================================== --- maven/sandbox/trunk/mae/mae-container/src/main/java/org/apache/maven/mae/internal/container/guice/InstanceBindingModule.java (original) +++ maven/sandbox/trunk/mae/mae-container/src/main/java/org/apache/maven/mae/internal/container/guice/InstanceBindingModule.java Fri May 27 02:50:04 2011 @@ -32,10 +32,15 @@ import org.sonatype.guice.plexus.config. import com.google.inject.Binder; import com.google.inject.Inject; import com.google.inject.Injector; +import com.google.inject.Module; import com.google.inject.Provider; import java.util.Map; +/** + * {@link PlexusBeanModule} (variant of Guice {@link Module}), which allows injection of externally + * managed object instances into plexus-managed components. + */ public class InstanceBindingModule implements PlexusBeanModule { Modified: maven/sandbox/trunk/mae/mae-container/src/main/java/org/apache/maven/mae/internal/container/guice/SelectingTypeBinder.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-container/src/main/java/org/apache/maven/mae/internal/container/guice/SelectingTypeBinder.java?rev=1128144&r1=1128143&r2=1128144&view=diff ============================================================================== --- maven/sandbox/trunk/mae/mae-container/src/main/java/org/apache/maven/mae/internal/container/guice/SelectingTypeBinder.java (original) +++ maven/sandbox/trunk/mae/mae-container/src/main/java/org/apache/maven/mae/internal/container/guice/SelectingTypeBinder.java Fri May 27 02:50:04 2011 @@ -53,6 +53,11 @@ import java.util.Set; * * - PluginManager.class/"default_" => DefaultPluginManager.class */ +/** + * {@link PlexusTypeListener} implementation that uses a {@link ComponentSelector} to selectively + * redirect one component requirement to another component, which was configured by the developer + * who's embedding the container/Maven apis. + */ public final class SelectingTypeBinder implements PlexusTypeListener {