Author: jdcasey Date: Fri May 27 00:19:56 2011 New Revision: 1128127 URL: http://svn.apache.org/viewvc?rev=1128127&view=rev Log: moving mae-app classes into mae-booter, and switching the version to 1.0-alpha-1-SNAPSHOT, since I'm not sure it's appropriate to peg this to a maven version.
Added: maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/app/ maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/app/AbstractMAEApplication.java (with props) maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/app/MAEApplication.java (with props) Removed: maven/sandbox/trunk/mae/mae-app/src/main/java/org/ maven/sandbox/trunk/mae/mae-app/src/test/java/org/commonjava/emb/app/ Modified: maven/sandbox/trunk/mae/boms/mae-app-bom/pom.xml maven/sandbox/trunk/mae/boms/mae-library-bom/pom.xml maven/sandbox/trunk/mae/boms/pom.xml maven/sandbox/trunk/mae/mae-api/pom.xml maven/sandbox/trunk/mae/mae-app/pom.xml maven/sandbox/trunk/mae/mae-booter/pom.xml maven/sandbox/trunk/mae/mae-container/pom.xml maven/sandbox/trunk/mae/pom.xml Modified: maven/sandbox/trunk/mae/boms/mae-app-bom/pom.xml URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/boms/mae-app-bom/pom.xml?rev=1128127&r1=1128126&r2=1128127&view=diff ============================================================================== --- maven/sandbox/trunk/mae/boms/mae-app-bom/pom.xml (original) +++ maven/sandbox/trunk/mae/boms/mae-app-bom/pom.xml Fri May 27 00:19:56 2011 @@ -19,7 +19,7 @@ <parent> <artifactId>mae-boms</artifactId> <groupId>org.apache.maven.mae</groupId> - <version>3.0.3-SNAPSHOT</version> + <version>1.0-alpha-1-SNAPSHOT</version> </parent> <artifactId>mae-app-bom</artifactId> Modified: maven/sandbox/trunk/mae/boms/mae-library-bom/pom.xml URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/boms/mae-library-bom/pom.xml?rev=1128127&r1=1128126&r2=1128127&view=diff ============================================================================== --- maven/sandbox/trunk/mae/boms/mae-library-bom/pom.xml (original) +++ maven/sandbox/trunk/mae/boms/mae-library-bom/pom.xml Fri May 27 00:19:56 2011 @@ -19,7 +19,7 @@ <parent> <artifactId>mae-boms</artifactId> <groupId>org.apache.maven.mae</groupId> - <version>3.0.3-SNAPSHOT</version> + <version>1.0-alpha-1-SNAPSHOT</version> </parent> <artifactId>mae-library-bom</artifactId> Modified: maven/sandbox/trunk/mae/boms/pom.xml URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/boms/pom.xml?rev=1128127&r1=1128126&r2=1128127&view=diff ============================================================================== --- maven/sandbox/trunk/mae/boms/pom.xml (original) +++ maven/sandbox/trunk/mae/boms/pom.xml Fri May 27 00:19:56 2011 @@ -19,7 +19,7 @@ <parent> <artifactId>mae</artifactId> <groupId>org.apache.maven.mae</groupId> - <version>3.0.3-SNAPSHOT</version> + <version>1.0-alpha-1-SNAPSHOT</version> </parent> <artifactId>mae-boms</artifactId> Modified: maven/sandbox/trunk/mae/mae-api/pom.xml URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-api/pom.xml?rev=1128127&r1=1128126&r2=1128127&view=diff ============================================================================== --- maven/sandbox/trunk/mae/mae-api/pom.xml (original) +++ maven/sandbox/trunk/mae/mae-api/pom.xml Fri May 27 00:19:56 2011 @@ -22,7 +22,7 @@ <parent> <artifactId>mae</artifactId> <groupId>org.apache.maven.mae</groupId> - <version>3.0.3-SNAPSHOT</version> + <version>1.0-alpha-1-SNAPSHOT</version> </parent> <artifactId>mae-api</artifactId> Modified: maven/sandbox/trunk/mae/mae-app/pom.xml URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-app/pom.xml?rev=1128127&r1=1128126&r2=1128127&view=diff ============================================================================== --- maven/sandbox/trunk/mae/mae-app/pom.xml (original) +++ maven/sandbox/trunk/mae/mae-app/pom.xml Fri May 27 00:19:56 2011 @@ -22,7 +22,7 @@ <parent> <artifactId>mae</artifactId> <groupId>org.apache.maven.mae</groupId> - <version>3.0.3-SNAPSHOT</version> + <version>1.0-alpha-1-SNAPSHOT</version> </parent> <artifactId>mae-app</artifactId> Modified: maven/sandbox/trunk/mae/mae-booter/pom.xml URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-booter/pom.xml?rev=1128127&r1=1128126&r2=1128127&view=diff ============================================================================== --- maven/sandbox/trunk/mae/mae-booter/pom.xml (original) +++ maven/sandbox/trunk/mae/mae-booter/pom.xml Fri May 27 00:19:56 2011 @@ -22,7 +22,7 @@ <parent> <artifactId>mae</artifactId> <groupId>org.apache.maven.mae</groupId> - <version>3.0.3-SNAPSHOT</version> + <version>1.0-alpha-1-SNAPSHOT</version> </parent> <artifactId>mae-booter</artifactId> Added: 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=1128127&view=auto ============================================================================== --- maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/app/AbstractMAEApplication.java (added) +++ maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/app/AbstractMAEApplication.java Fri May 27 00:19:56 2011 @@ -0,0 +1,230 @@ +/* + * 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. + */ + +package org.apache.maven.mae.app; + +import org.apache.log4j.Logger; +import org.apache.maven.mae.MAEException; +import org.apache.maven.mae.boot.embed.MAEEmbedderBuilder; +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 AbstractMAEApplication + implements MAEApplication +{ + + private final List<MAELibrary> additionalLibraries = new ArrayList<MAELibrary>(); + + private final InstanceRegistry instanceRegistry = new InstanceRegistry(); + + private transient boolean loaded = false; + + @SuppressWarnings( { "rawtypes", "unchecked" } ) + protected AbstractMAEApplication() + { + withLibrary( this ); + withComponentInstance( new ComponentKey( getClass() ), this ); + } + + protected final AbstractMAEApplication withLibrary( final MAELibrary library ) + { + additionalLibraries.add( library ); + return this; + } + + @Override + public MAEApplication load() + throws MAEException + { + return doLoad(); + } + + private synchronized MAEApplication doLoad() + throws MAEException + { + if ( loaded ) + { + return this; + } + + final MAEEmbedderBuilder builder = new MAEEmbedderBuilder().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 MAEEmbedderBuilder 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-booter/src/main/java/org/apache/maven/mae/app/AbstractMAEApplication.java ------------------------------------------------------------------------------ svn:eol-style = native Added: 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=1128127&view=auto ============================================================================== --- maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/app/MAEApplication.java (added) +++ maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/app/MAEApplication.java Fri May 27 00:19:56 2011 @@ -0,0 +1,30 @@ +/* + * 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. + */ + +package org.apache.maven.mae.app; + +import org.apache.maven.mae.MAEException; +import org.apache.maven.mae.conf.MAELibrary; + +public interface MAEApplication + extends MAELibrary +{ + MAEApplication load() + throws MAEException; +} Propchange: maven/sandbox/trunk/mae/mae-booter/src/main/java/org/apache/maven/mae/app/MAEApplication.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: maven/sandbox/trunk/mae/mae-container/pom.xml URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-container/pom.xml?rev=1128127&r1=1128126&r2=1128127&view=diff ============================================================================== --- maven/sandbox/trunk/mae/mae-container/pom.xml (original) +++ maven/sandbox/trunk/mae/mae-container/pom.xml Fri May 27 00:19:56 2011 @@ -22,7 +22,7 @@ <parent> <artifactId>mae</artifactId> <groupId>org.apache.maven.mae</groupId> - <version>3.0.3-SNAPSHOT</version> + <version>1.0-alpha-1-SNAPSHOT</version> </parent> <artifactId>mae-container</artifactId> Modified: maven/sandbox/trunk/mae/pom.xml URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/pom.xml?rev=1128127&r1=1128126&r2=1128127&view=diff ============================================================================== --- maven/sandbox/trunk/mae/pom.xml (original) +++ maven/sandbox/trunk/mae/pom.xml Fri May 27 00:19:56 2011 @@ -28,7 +28,7 @@ <groupId>org.apache.maven.mae</groupId> <artifactId>mae</artifactId> - <version>3.0.3-SNAPSHOT</version> + <version>1.0-alpha-1-SNAPSHOT</version> <packaging>pom</packaging>