You are viewing a plain text version of this content. The canonical link for it is here.
Posted to npanday-commits@incubator.apache.org by lc...@apache.org on 2011/12/05 10:09:33 UTC
svn commit: r1210393 [2/3] - in
/incubator/npanday/branches/1.5.0-azuresupport:
archetypes/maven-archetype-netexecutable/src/main/resources/archetype-resources/src/main/java/
components/ components/dotnet-artifact/src/main/java/npanday/artifact/
compon...
Added: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/AbstractMultisourceRepository.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/AbstractMultisourceRepository.java?rev=1210393&view=auto
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/AbstractMultisourceRepository.java (added)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/AbstractMultisourceRepository.java Mon Dec 5 10:09:31 2011
@@ -0,0 +1,131 @@
+package npanday.registry.impl;
+
+import npanday.registry.NPandayRepositoryException;
+import npanday.registry.Repository;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+
+import javax.naming.OperationNotSupportedException;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+
+/**
+ * Provides base functionality for configuration repositories that read
+ * from both resources and files. It supports multiple sources, clear, reload
+ * and content versioning.
+ *
+ * @author <a href="mailto:lcorneliussen@apache.org">Lars Corneliussen</a>
+ * @param <T>
+ */
+public abstract class AbstractMultisourceRepository<T>
+ extends AbstractLogEnabled
+ implements Repository
+{
+
+ private Hashtable properties;
+
+ /**
+ * The list of sources loaded into the repository.
+ */
+ private List<URL> sources = new ArrayList<URL>();
+
+ private int contentVersion = 0;
+
+ public void load( URL sourceUrl )
+ throws NPandayRepositoryException
+ {
+ loadAndMerge( sourceUrl );
+ sources.add( sourceUrl );
+ }
+
+ public void clearAll()
+ throws OperationNotSupportedException
+ {
+ sources.clear();
+ clear();
+ }
+
+ private void loadAndMerge( URL sourceUrl )
+ throws NPandayRepositoryException
+ {
+ T model;
+ try
+ {
+ Reader reader = new InputStreamReader( sourceUrl.openStream() );
+ model = loadFromReader( reader, properties );
+ }
+ catch ( IOException e )
+ {
+ throw new NPandayRepositoryException(
+ "NPANDAY-111-000: An error occurred while reading " + sourceUrl + " into " + getClass().getSimpleName(),
+ e );
+ }
+ catch ( org.codehaus.plexus.util.xml.pull.XmlPullParserException e )
+ {
+ throw new NPandayRepositoryException(
+ "NPANDAY-111-001: Could not read " + sourceUrl + " into " + getClass().getSimpleName(), e );
+ }
+
+ mergeLoadedModel( model );
+ incrementContentVersion();
+ }
+
+ protected abstract T loadFromReader( Reader reader, Hashtable properties )
+ throws IOException, org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+ protected abstract void mergeLoadedModel( T model )
+ throws NPandayRepositoryException;
+
+ /**
+ * The properties configured in the registry.
+ */
+ public void setProperties( Hashtable props )
+ {
+ properties = props;
+ }
+
+ /**
+ * Reloads this repository based on all provided sources.
+ */
+ public void reloadAll()
+ throws IOException, NPandayRepositoryException
+ {
+ clear();
+ for ( URL source : sources )
+ {
+ // TODO: throw better exception
+ loadAndMerge( source );
+ }
+ }
+
+ /**
+ * Remove all stored values in preparation for a reload.
+ */
+ protected abstract void clear();
+
+ /**
+ * @return The current version of the content. Will be increased, every time new content is loaded
+ * into the same instance. This is useful, if you built a cache upon the values provided by this repository.
+ */
+ public int getContentVersion()
+ {
+ return this.contentVersion;
+ }
+
+ protected void incrementContentVersion()
+ {
+ this.contentVersion++;
+ }
+
+ /**
+ * @return The properties, the repository was initialized with.
+ */
+ public Hashtable getProperties()
+ {
+ return properties;
+ }
+}
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/DataAccessObjectRegistryImpl.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/DataAccessObjectRegistryImpl.java?rev=1210393&r1=1210392&r2=1210393&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/DataAccessObjectRegistryImpl.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/DataAccessObjectRegistryImpl.java Mon Dec 5 10:09:31 2011
@@ -18,19 +18,25 @@
*/
package npanday.registry.impl;
-import npanday.registry.*;
+import npanday.registry.ConnectionsRepository;
+import npanday.registry.DataAccessObject;
+import npanday.registry.DataAccessObjectRegistry;
+import npanday.registry.NPandayRepositoryException;
+import npanday.registry.Repository;
+import npanday.registry.RepositoryRegistry;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
-import java.util.Set;
-import java.util.HashSet;
import java.util.Collections;
-import java.util.logging.Level;
+import java.util.HashSet;
+import java.util.Set;
import java.util.logging.Logger;
-import java.io.IOException;
+@Component(role=DataAccessObjectRegistry.class)
public class DataAccessObjectRegistryImpl
implements DataAccessObjectRegistry
{
-
+ @Requirement
private RepositoryRegistry repositoryRegistry;
private static Logger logger = Logger.getAnonymousLogger();
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/RepositoryRegistryImpl.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/RepositoryRegistryImpl.java?rev=1210393&r1=1210392&r2=1210393&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/RepositoryRegistryImpl.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/RepositoryRegistryImpl.java Mon Dec 5 10:09:31 2011
@@ -18,33 +18,55 @@
*/
package npanday.registry.impl;
-import npanday.registry.*;
+import npanday.registry.NPandayRepositoryException;
+import npanday.registry.RegistryLoader;
+import npanday.registry.Repository;
+import npanday.registry.RepositoryLoader;
+import npanday.registry.RepositoryRegistry;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
import java.util.Hashtable;
-import java.util.Properties;
import java.util.Set;
-import java.util.Collections;
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.FileInputStream;
-
-import org.apache.maven.settings.SettingsUtils;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
/**
* @author Shane Isbell
*/
+@Component( role = RepositoryRegistry.class )
public class RepositoryRegistryImpl
+ extends AbstractLogEnabled
implements RepositoryRegistry, Initializable
{
+ private static int instanceCounter = 0;
+ private int instance;
private Hashtable repositories = new Hashtable();
+ @Requirement
private RepositoryLoader repositoryLoader;
+ @Requirement
private RegistryLoader registryLoader;
+ public RepositoryRegistryImpl(){
+ instance = instanceCounter++;
+
+ try{
+ throw new RuntimeException("Stacktrace");
+ }
+ catch(RuntimeException ex)
+ {
+ System.out.println("NPANDAY-082-010: Instantiating RepositoryRegistry #" + instance);
+ ex.printStackTrace();
+ }
+ }
/**
* @see org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable#initialize()
@@ -52,17 +74,27 @@ public class RepositoryRegistryImpl
public void initialize()
throws InitializationException
{
+
+ try{
+ throw new RuntimeException("Stacktrace");
+ }
+ catch(RuntimeException ex)
+ {
+ getLogger().debug( "NPANDAY-082-011: Initializing RepositoryRegistry #" + instance, ex );
+ }
+
try
{
loadFromResource( "/META-INF/npanday/registry-config.xml", this.getClass() );
}
catch ( IOException e )
{
- throw new InitializationException( "NPANDAY-082-000: Message = ", e );
+ throw new InitializationException(
+ "NPANDAY-082-000: Error loading registry-config.xml or one of the configured repositories", e );
}
catch ( NPandayRepositoryException e )
{
- throw new InitializationException( "NPANDAY-082-010: Message = ", e );
+ throw new InitializationException( "NPANDAY-082-010: Error loading registry-config.xml = ", e );
}
}
@@ -82,68 +114,9 @@ public class RepositoryRegistryImpl
}
public synchronized void loadFromInputStream( InputStream inputStream )
- throws IOException, NPandayRepositoryException {
+ throws IOException, NPandayRepositoryException
+ {
- if ( repositoryLoader == null || registryLoader == null )
- {
- InputStream stream =
- npanday.registry.RepositoryRegistry.class.getResourceAsStream( "/registry.properties" );
- if ( stream == null )
- {
- throw new IOException( "NPANDAY-082-001: Could not find /registry.properties file with the jar" );
- }
-
- Properties prop = new Properties();
- prop.load( stream );
-
- if ( repositoryLoader == null )
- {
- String loaderClassName = prop.getProperty( "repositoryLoader" );
- if ( loaderClassName == null )
- {
- throw new IOException( "NPANDAY-082-002: Missing the repositoryLoader from the /registry.properties" );
- }
-
- String message = "Repository Loader = " + loaderClassName;
- try
- {
- Class c = Class.forName( loaderClassName );
- repositoryLoader = (RepositoryLoader) c.newInstance();
- }
- catch ( Exception e )
- {
- throw new NPandayRepositoryException( "NPANDAY-082-003: Unable to load repository: " + message, e );
- }
- catch ( Error e )
- {
- throw new NPandayRepositoryException( "NPANDAY-082-004: Unable to load repository: " + message, e );
- }
- }
-
- if ( registryLoader == null )
- {
- String loaderClassName = prop.getProperty( "registryLoader" );
- if ( loaderClassName == null )
- {
- throw new IOException( "NPANDAY-082-005: Missing the registryLoader from the /registry.properties" );
- }
-
- String message = "Registry Loader = " + loaderClassName;
- try
- {
- Class c = Class.forName( loaderClassName );
- registryLoader = (RegistryLoader) c.newInstance();
- }
- catch ( Exception e )
- {
- throw new NPandayRepositoryException( "NPANDAY-082-006: Unable to load registry: " + message, e );
- }
- catch ( Error e )
- {
- throw new NPandayRepositoryException( "NPANDAY-082-007: Unable to load registry: " + message, e );
- }
- }
- }
repositoryLoader.setRepositoryRegistry( this );
registryLoader.setRepositoryLoader( repositoryLoader );
registryLoader.loadRegistry( inputStream );
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/StandardRegistryLoader.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/StandardRegistryLoader.java?rev=1210393&r1=1210392&r2=1210393&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/StandardRegistryLoader.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/StandardRegistryLoader.java Mon Dec 5 10:09:31 2011
@@ -22,24 +22,24 @@ import npanday.registry.NPandayRepositor
import npanday.registry.RegistryLoader;
import npanday.registry.Repository;
import npanday.registry.RepositoryLoader;
+import org.codehaus.plexus.component.annotations.Component;
+import org.kxml2.io.KXmlParser;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
-import java.util.List;
+import java.io.IOException;
+import java.io.InputStream;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.Hashtable;
-import java.io.InputStream;
-import java.io.IOException;
-
-import org.kxml2.io.KXmlParser;
-import org.xmlpull.v1.XmlPullParserException;
-import org.xmlpull.v1.XmlPullParser;
+import java.util.Iterator;
+import java.util.List;
/**
* The default loader for the registry-config.xml file.
*
* @author Shane Isbell
*/
-
+@Component(role = RegistryLoader.class)
public class StandardRegistryLoader
implements RegistryLoader
{
@@ -52,11 +52,6 @@ public class StandardRegistryLoader
private RepositoryLoader repositoryLoader;
- public void setRepositoryLoader( RepositoryLoader repositoryLoader )
- {
- this.repositoryLoader = repositoryLoader;
- }
-
/**
* Loads the registry-config file
*
@@ -248,6 +243,11 @@ public class StandardRegistryLoader
return repositoryObject;
}
+ public void setRepositoryLoader( RepositoryLoader repositoryLoader )
+ {
+ this.repositoryLoader = repositoryLoader;
+ }
+
/**
* Value Object for Repository Information
*/
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/StandardRepositoryLoader.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/StandardRepositoryLoader.java?rev=1210393&r1=1210392&r2=1210393&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/StandardRepositoryLoader.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/StandardRepositoryLoader.java Mon Dec 5 10:09:31 2011
@@ -22,101 +22,186 @@ import npanday.registry.NPandayRepositor
import npanday.registry.Repository;
import npanday.registry.RepositoryLoader;
import npanday.registry.RepositoryRegistry;
+import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.context.Context;
+import org.codehaus.plexus.context.ContextException;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
-import java.util.Hashtable;
+import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.FileInputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Hashtable;
+import java.util.List;
/**
* The default repository loader. This class can be extended
*
* @author Shane Isbell
+ * @author <a href="mailto:lcorneliussen@apache.org">Lars Corneliussen</a>
*/
+@Component(role = RepositoryLoader.class)
public class StandardRepositoryLoader
- implements RepositoryLoader
+ extends AbstractLogEnabled
+ implements RepositoryLoader, Contextualizable
{
+ /**
+ * Can't be provided as a component, because that would result in a circular reference.
+ */
private RepositoryRegistry repositoryRegistry;
/**
+ * The plexus context, which we can use to dynamically add components.
+ */
+ private PlexusContainer container;
+
+ /**
* Takes information from the registry-config file and dynamically builds a <code>Repository</code>
*
- * @param fileUri name of the repository's configuration file. It may be located on the file system
- * or within a jar.
+ * @param location name of the repository's configuration file. It may be located on the file system
+ * or on the current threads classpath. If multiple files are found on the classpath,
+ * their contents will be merged by the corresponding repository implementation.
* @param repositoryClass name of the repository class
* @param initParams <code>Hashtable</code> containing the repository's configuration parameters.
* @return instance of repository
* @throws java.io.IOException
*/
-
- public Repository loadRepository( String fileUri, String repositoryClass, Hashtable initParams )
- throws IOException, NPandayRepositoryException
+ public Repository loadRepository( String location, String repositoryClass, Hashtable initParams )
+ throws IOException, NPandayRepositoryException
{
if ( repositoryRegistry == null )
{
throw new IOException( "NPANDAY-084-000: The repository registry has not been set." );
}
+ if ( container == null )
+ {
+ throw new IOException(
+ "NPANDAY-084-012: The context has not been set; make sure this instance is loaded as a component." );
+ }
+
Hashtable props = ( initParams != null ) ? initParams : new Hashtable();
- if ( fileUri == null || fileUri.trim().equals( "" ) )
+ if ( location == null || location.trim().equals( "" ) )
{
throw new IOException( "NPANDAY-084-001: File uri must be provided." );
}
if ( repositoryClass == null || repositoryClass.trim().equals( "" ) )
{
- throw new IOException( "NPANDAY-084-002: Repository class name must be provided: File Name = " + fileUri +
- ", Properties = " + props.toString() );
+ throw new IOException(
+ "NPANDAY-084-002: Repository class name must be provided: File Name = " + location + ", Properties = "
+ + props.toString() );
}
- InputStream stream;
- Repository repository;
- try
- {
- stream = new FileInputStream( fileUri );
- }
- catch ( IOException e )
+ final List<URL> sources = findSources( location, initParams );
+
+ Repository repository = initializeRepository( repositoryClass, props );
+ loadFoundSources( location, repositoryClass, props, sources, repository );
+
+ return repository;
+ }
+
+ private List<URL> findSources( String location, Hashtable initParams )
+ throws IOException
+ {
+ final List<URL> sources = new ArrayList<URL>();
+
+ final File locationAsFile = new File( location );
+ if ( locationAsFile.exists() )
{
- stream = this.getClass().getResourceAsStream( fileUri );
+ final URL fileUrl = locationAsFile.toURI().toURL();
+ getLogger().debug(
+ String.format( "NPANDAY-084-007: Searched file with '%s', found: [%s]", location, fileUrl ) );
+ sources.add( fileUrl );
}
- String message =
- "File Name = " + fileUri + ", Repository Class = " + repositoryClass + ", Properties = " + props.toString();
- boolean optional = ( initParams.containsKey( "optional" ) &&
- ( (String) initParams.get( "optional" ) ).equalsIgnoreCase( "true" ) );
- if ( stream == null && !optional )
+ else
{
- throw new IOException( "NPANDAY-084-003: Unable to loadRegistry config file: " + message );
+ ClassLoader cloader = Thread.currentThread().getContextClassLoader();
+ final ArrayList<URL> threadClassPath = Collections.list( cloader.getResources( location ) );
+ sources.addAll( threadClassPath );
+
+ getLogger().debug(
+ String.format( "NPANDAY-084-008: Searched thread classpath with '%s', found: [%s]", location,
+ sources ) );
+
+ cloader = getClass().getClassLoader();
+ final ArrayList<URL> currentClassPath = Collections.list( cloader.getResources( location ) );
+ sources.addAll( currentClassPath );
+
+ getLogger().debug(
+ String.format( "NPANDAY-084-012: Searched dotnet-core classpath with '%s', found: [%s]", location,
+ sources ) );
}
- else if ( stream == null && optional )
+
+ boolean optional = "true".equalsIgnoreCase( (String) initParams.get( "optional" ) );
+
+ if ( sources.size() == 0 && !optional )
{
- return null;
+ throw new IOException(
+ String.format( "NPANDAY-084-003: Unable to find any repository source files or resources named: %s",
+ location ) );
}
+ return sources;
+ }
+ private Repository initializeRepository( String repositoryClass, Hashtable props )
+ throws NPandayRepositoryException
+ {
+ Repository repository;
try
{
- Class c = Class.forName( repositoryClass );
- repository = (Repository) c.newInstance();
- repository.setRepositoryRegistry( repositoryRegistry );
- repository.load( stream, props );
- repository.setSourceUri( fileUri );
- }
- catch ( NPandayRepositoryException e )
- {
- throw new NPandayRepositoryException( "NPANDAY-084-004: " + e.toString() + " : " + message, e );
+ /*Class c = Class.forName( repositoryClass );
+ repository = (Repository) c.newInstance(); */
+
+ repository = (Repository)container.lookup( repositoryClass );
+
+ repository.setProperties( props );
}
catch ( Exception e )
{
- throw new NPandayRepositoryException( "NPANDAY-084-005: " + e.toString() + " : " + message, e );
+ throw new NPandayRepositoryException(
+ String.format( "NPANDAY-084-005: Error on initializing %s ", repositoryClass ), e );
}
catch ( Error e )
{
- throw new NPandayRepositoryException( "NPANDAY-084-006: " + e.toString() + " : " + message, e );
+ throw new NPandayRepositoryException(
+ String.format( "NPANDAY-084-011: Error on initializing %s ", repositoryClass ), e );
}
return repository;
}
+ private void loadFoundSources( String location, String repositoryClass, Hashtable props, List<URL> sources,
+ Repository repository )
+ throws NPandayRepositoryException
+ {
+ for ( URL source : sources )
+ {
+ getLogger().debug(
+ String.format( "NPANDAY-084-009: loading '%s' into the repository %s", location, repositoryClass ) );
+
+ try
+ {
+ getLogger().debug( String.format( "NPANDAY-084-009: loading '%s' into the repository %s", location,
+ repositoryClass ) );
+
+ repository.load( source );
+ }
+ catch ( NPandayRepositoryException e )
+ {
+ throw new NPandayRepositoryException(
+ String.format( "NPANDAY-084-010: Error on loading '%s' into the repository %s", location,
+ repositoryClass ) );
+
+ }
+ }
+ }
+
public String getLoaderName()
{
return this.getClass().getName();
@@ -126,4 +211,11 @@ public class StandardRepositoryLoader
{
this.repositoryRegistry = repositoryRegistry;
}
+
+ public void contextualize( Context context )
+ throws ContextException
+ {
+ this.container = (PlexusContainer)context.get ( PlexusConstants.PLEXUS_KEY);
+ }
}
+
Added: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/resources/META-INF/plexus/components.xml?rev=1210393&view=auto
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/resources/META-INF/plexus/components.xml (added)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/resources/META-INF/plexus/components.xml Mon Dec 5 10:09:31 2011
@@ -0,0 +1,23 @@
+<!--
+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.
+-->
+<component-set>
+ <components>
+ <!-- use annotations instead -->
+ </components>
+</component-set>
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/SettingsUtil.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/SettingsUtil.java?rev=1210393&r1=1210392&r2=1210393&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/SettingsUtil.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/SettingsUtil.java Mon Dec 5 10:09:31 2011
@@ -22,13 +22,12 @@ package npanday.vendor;
import npanday.PathUtil;
import npanday.registry.NPandayRepositoryException;
import npanday.registry.RepositoryRegistry;
-import npanday.registry.impl.StandardRepositoryLoader;
import npanday.vendor.impl.SettingsRepository;
import org.codehaus.plexus.util.StringUtils;
+import javax.naming.OperationNotSupportedException;
import java.io.File;
import java.io.IOException;
-import java.util.Hashtable;
/**
* Central handling of creation and retrieval of the SettingsRepository.
@@ -65,8 +64,8 @@ public class SettingsUtil
throws SettingsException
{
SettingsRepository settingsRepository = (SettingsRepository) repositoryRegistry.find( "npanday-settings" );
- if (settingsRepository == null){
- return populateSettingsRepository( repositoryRegistry, settingsPathOrFile);
+ if (settingsRepository.isEmpty()){
+ populateSettingsRepository( repositoryRegistry, settingsPathOrFile);
}
return settingsRepository;
}
@@ -78,7 +77,7 @@ public class SettingsUtil
* @return The new Settings Repository.
* @throws SettingsException If anything goes wrong reading or registering the settings
*/
- public static SettingsRepository populateSettingsRepository( RepositoryRegistry repositoryRegistry, String settingsPathOrFile )
+ public static void populateSettingsRepository( RepositoryRegistry repositoryRegistry, String settingsPathOrFile )
throws SettingsException
{
SettingsRepository settingsRepository;
@@ -91,36 +90,25 @@ public class SettingsUtil
throw new SettingsException( "NPANDAY-108-001: Error finding npanday-settings in registry", ex );
}
- if ( settingsRepository != null )
- {
- try
- {
- repositoryRegistry.removeRepository( "npanday-settings" );
- }
- catch ( Exception ex )
- {
- throw new SettingsException( "NPANDAY-108-002: Error removing npanday-settings from registry", ex );
- }
- }
-
File settingsFile = PathUtil.buildSettingsFilePath( settingsPathOrFile );
if (!settingsFile.exists())
{
- return null;
+ throw new SettingsException( "NPANDAY-108-005: Settings file does not exist: " + settingsFile );
}
try
{
- StandardRepositoryLoader repoLoader = new StandardRepositoryLoader();
- repoLoader.setRepositoryRegistry( repositoryRegistry );
- settingsRepository = (SettingsRepository) repoLoader.loadRepository( settingsFile.getAbsolutePath(),
- SettingsRepository.class.getName(),
- new Hashtable() );
- repositoryRegistry.addRepository( "npanday-settings", settingsRepository );
- assert settingsRepository != null;
+ settingsRepository.clearAll();
+ }
+ catch ( OperationNotSupportedException e )
+ {
+ throw new SettingsException( "NPANDAY-108-006: Error clearing settings repository.", e );
+ }
- return settingsRepository;
+ try
+ {
+ settingsRepository.load( settingsFile.toURI().toURL() );
}
catch ( IOException e )
{
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/SettingsRepository.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/SettingsRepository.java?rev=1210393&r1=1210392&r2=1210393&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/SettingsRepository.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/SettingsRepository.java Mon Dec 5 10:09:31 2011
@@ -18,40 +18,41 @@
*/
package npanday.vendor.impl;
+import npanday.PlatformUnsupportedException;
+import npanday.model.settings.DefaultSetup;
+import npanday.model.settings.Framework;
+import npanday.model.settings.NPandaySettings;
+import npanday.model.settings.Vendor;
+import npanday.model.settings.io.xpp3.NPandaySettingsXpp3Reader;
import npanday.registry.NPandayRepositoryException;
import npanday.registry.Repository;
-import npanday.registry.RepositoryRegistry;
+import npanday.registry.impl.AbstractMultisourceRepository;
+import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-import java.io.*;
+import java.io.File;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.Hashtable;
import java.util.List;
-import java.util.ArrayList;
-
-import npanday.model.settings.NPandaySettings;
-import npanday.model.settings.Vendor;
-import npanday.model.settings.DefaultSetup;
-import npanday.model.settings.Framework;
-import npanday.model.settings.io.xpp3.NPandaySettingsXpp3Reader;
-import npanday.PlatformUnsupportedException;
-import npanday.vendor.VendorFactory;
-import npanday.vendor.VendorInfo;
-import npanday.vendor.VendorUnsupportedException;
/**
- * Provides methods for loading and reading the npanday-settings config file.
+ * Provides methods for loading and reading the npanday-settings config file.
*
* @author Shane Isbell
+ * @author <a href="mailto:lcorneliussen@apache.org">Lars Corneliussen</a>
*/
+@Component( role = SettingsRepository.class )
public final class SettingsRepository
+ extends AbstractMultisourceRepository<NPandaySettings>
implements Repository
{
-
/**
- * List of all vendors from the npanday-settings file. The <code>Vendor</code> is the raw model type.
+ * List of all vendors from the various sources. The <code>Vendor</code> is the raw model type.
*/
- private List<Vendor> vendors;
+ private List<Vendor> vendors = new ArrayList<Vendor>();
/**
* The default setup: framework version, vendor, vendor version. If no information is provided by the user, then
@@ -59,12 +60,6 @@ public final class SettingsRepository
*/
private DefaultSetup defaultSetup;
- private String fileUri;
-
- private Hashtable props;
-
- private boolean reloaded = false;
-
/**
* Constructor. This method is intended to be invoked by the <code>RepositoryRegistry<code>, not by the
* application developer.
@@ -73,122 +68,57 @@ public final class SettingsRepository
{
}
- /**
- * @see Repository#load(java.io.InputStream, java.util.Hashtable)
- */
- public void load( InputStream inputStream, Hashtable properties )
- throws NPandayRepositoryException
+ @Override
+ protected NPandaySettings loadFromReader( Reader reader, Hashtable properties )
+ throws IOException, XmlPullParserException
{
NPandaySettingsXpp3Reader xpp3Reader = new NPandaySettingsXpp3Reader();
- Reader reader = new InputStreamReader( inputStream );
- NPandaySettings settings;
- try
- {
- settings = xpp3Reader.read( reader );
- }
- catch( IOException e )
- {
- throw new NPandayRepositoryException( "NPANDAY-104-000: An error occurred while reading npanday-settings.xml", e );
- }
- catch ( XmlPullParserException e )
- {
- throw new NPandayRepositoryException( "NPANDAY-104-001: Could not read npanday-settings.xml", e );
- }
- vendors = settings.getVendors();
- defaultSetup = settings.getDefaultSetup();
- props = properties;
- }
-
- /**
- * Gets the raw configured model.
- *
- * @return Unmodifiable list.
- */
- public List<Vendor> getVendors() {
- return Collections.unmodifiableList(vendors);
- }
-
- /**
- * @see Repository#setRepositoryRegistry(npanday.registry.RepositoryRegistry)
- */
- public void setRepositoryRegistry( RepositoryRegistry repositoryRegistry )
- {
+ return xpp3Reader.read( reader );
}
- public void setSourceUri( String fileUri )
+ @Override
+ protected void mergeLoadedModel( NPandaySettings settings )
+ throws NPandayRepositoryException
{
- this.fileUri = fileUri;
- }
+ vendors.addAll( settings.getVendors() );
- public void reload()
- throws IOException, NPandayRepositoryException {
+ final DefaultSetup currentDefaultSetup = settings.getDefaultSetup();
- if ( fileUri == null || fileUri.trim().equals( "" ) )
+ if ( currentDefaultSetup != null && defaultSetup != null )
{
- throw new IOException( "NPANDAY-084-001: File uri must be provided." );
+ getLogger().warn(
+ "NPANDAY-104-006: The default setup was already defined, got overridden by a subsequent source, was: "
+ + defaultSetup + ", is now " + currentDefaultSetup );
}
- InputStream stream;
-
- try
- {
- stream = new FileInputStream( fileUri );
- }
- catch ( IOException e )
- {
- stream = this.getClass().getResourceAsStream( fileUri );
- }
- String message =
- "File Name = " + fileUri + ", Repository Class = " + this.getClass().getName() + ", Properties = " + props.toString();
- boolean optional = ( props.containsKey( "optional" ) &&
- ( (String) props.get( "optional" ) ).equalsIgnoreCase( "true" ) );
- if ( stream == null )
- {
- if ( !optional )
- {
- throw new IOException( "NPANDAY-084-003: Unable to loadRegistry config file: " + message );
- }
- }
- else
- {
- try
- {
- load( stream, props );
- }
- catch ( NPandayRepositoryException e )
- {
- throw new NPandayRepositoryException( "NPANDAY-084-004: " + e.toString() + " : " + message, e );
- }
- catch ( Exception e )
- {
- throw new NPandayRepositoryException( "NPANDAY-084-005: " + e.toString() + " : " + message, e );
- }
- catch ( Error e )
- {
- throw new NPandayRepositoryException( "NPANDAY-084-006: " + e.toString() + " : " + message, e );
- }
- }
-
- reloaded = true;
+ defaultSetup = currentDefaultSetup;
}
- public void setReloaded( boolean status )
+ @Override
+ protected void clear()
{
- this.reloaded = status;
+ vendors.clear();
+ defaultSetup = null;
}
- public boolean isReloaded()
+ /**
+ * Gets the raw configured model.
+ *
+ * @return Unmodifiable list.
+ */
+ public List<Vendor> getVendors()
{
- return this.reloaded;
- }
+ return Collections.unmodifiableList( vendors );
+ }
File getSdkInstallRootFor( String vendor, String vendorVersion, String frameworkVersion )
throws PlatformUnsupportedException
{
if ( vendor == null || vendorVersion == null || frameworkVersion == null )
{
- throw new PlatformUnsupportedException( "NPANDAY-104-004: One of more of the parameters is null: Vendor = " +
- vendor + ", Vendor Version = " + vendorVersion + ", Framework Version = " + frameworkVersion );
+ throw new PlatformUnsupportedException(
+ "NPANDAY-104-004: One of more of the parameters is null: Vendor = " + vendor + ", Vendor Version = "
+ + vendorVersion + ", Framework Version = " + frameworkVersion );
}
for ( Vendor v : vendors )
{
@@ -199,8 +129,11 @@ public final class SettingsRepository
{
if ( frameworkVersion.equals( framework.getFrameworkVersion().trim() ) )
{
- String sdkRoot = framework.getSdkInstallRoot();
- if(sdkRoot != null) return new File(sdkRoot );
+ String sdkRoot = framework.getSdkInstallRoot();
+ if ( sdkRoot != null )
+ {
+ return new File( sdkRoot );
+ }
}
}
}
@@ -209,40 +142,43 @@ public final class SettingsRepository
}
/**
- * Returns the install root for the .NET framework for the specified parameters. None of the parameter values
- * should be null.
+ * Returns the install root for the .NET framework for the specified parameters. None of the parameter values
+ * should be null.
*
- * @param vendor the vendor name
- * @param vendorVersion the vendor version
- * @param frameworkVersion the .NET framework version
+ * @param vendor the vendor name
+ * @param vendorVersion the vendor version
+ * @param frameworkVersion the .NET framework version
* @return the install root for the .NET framework
- * @throws npanday.PlatformUnsupportedException if there is no install root found for the specified parameters
+ * @throws npanday.PlatformUnsupportedException
+ * if there is no install root found for the specified parameters
*/
public File getInstallRootFor( String vendor, String vendorVersion, String frameworkVersion )
throws PlatformUnsupportedException
{
if ( vendor == null || vendorVersion == null || frameworkVersion == null )
{
- throw new PlatformUnsupportedException( "NPANDAY-104-001: One of more of the parameters is null: Vendor = " +
- vendor + ", Vendor Version = " + vendorVersion + ", Framework Version = " + frameworkVersion );
+ throw new PlatformUnsupportedException(
+ "NPANDAY-104-001: One of more of the parameters is null: Vendor = " + vendor + ", Vendor Version = "
+ + vendorVersion + ", Framework Version = " + frameworkVersion );
}
for ( Vendor v : vendors )
{
- if ( vendor.equals( v.getVendorName().trim() ) && vendorVersion.equals( v.getVendorVersion().trim() ) )
+ if ( vendor.equals( v.getVendorName().trim() ) && vendorVersion.equals( v.getVendorVersion().trim() ) )
{
List<Framework> frameworks = v.getFrameworks();
-
- for ( Framework framework : frameworks )
+
+ for ( Framework framework : frameworks )
{
- if ( frameworkVersion.equals( framework.getFrameworkVersion().trim() ))
- {
- return new File( framework.getInstallRoot() );
+ if ( frameworkVersion.equals( framework.getFrameworkVersion().trim() ) )
+ {
+ return new File( framework.getInstallRoot() );
}
}
}
}
- throw new PlatformUnsupportedException( "NPANDAY-104-002: Unable to find install root: Vendor = " + vendor +
- ", Vendor Version = " + vendorVersion + ", Framework Version = " + frameworkVersion );
+ throw new PlatformUnsupportedException(
+ "NPANDAY-104-002: Unable to find install root: Vendor = " + vendor + ", Vendor Version = " + vendorVersion
+ + ", Framework Version = " + frameworkVersion );
}
List<File> getExecutablePathsFor( String vendor, String vendorVersion, String frameworkVersion )
@@ -251,8 +187,9 @@ public final class SettingsRepository
List<File> executablePaths = new ArrayList<File>();
if ( vendor == null || vendorVersion == null || frameworkVersion == null )
{
- throw new PlatformUnsupportedException( "NPANDAY-104-006: One of more of the parameters is null: Vendor = " +
- vendor + ", Vendor Version = " + vendorVersion + ", Framework Version = " + frameworkVersion );
+ throw new PlatformUnsupportedException(
+ "NPANDAY-104-006: One of more of the parameters is null: Vendor = " + vendor + ", Vendor Version = "
+ + vendorVersion + ", Framework Version = " + frameworkVersion );
}
for ( Vendor v : vendors )
{
@@ -264,9 +201,9 @@ public final class SettingsRepository
if ( frameworkVersion.equals( framework.getFrameworkVersion().trim() ) )
{
List paths = framework.getExecutablePaths();
- for(Object path : paths)
+ for ( Object path : paths )
{
- executablePaths.add(new File((String)path));
+ executablePaths.add( new File( (String) path ) );
}
}
}
@@ -285,4 +222,10 @@ public final class SettingsRepository
{
return defaultSetup;
}
+
+ public boolean isEmpty()
+ {
+ return getVendors().size() == 0 && defaultSetup == null;
+ }
}
+
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoRepositoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoRepositoryImpl.java?rev=1210393&r1=1210392&r2=1210393&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoRepositoryImpl.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoRepositoryImpl.java Mon Dec 5 10:09:31 2011
@@ -20,20 +20,25 @@ package npanday.vendor.impl;
import npanday.ArtifactType;
import npanday.ArtifactTypeHelper;
+import npanday.PlatformUnsupportedException;
import npanday.model.settings.Framework;
-import npanday.vendor.*;
import npanday.registry.RepositoryRegistry;
-import npanday.PlatformUnsupportedException;
+import npanday.vendor.InvalidVersionFormatException;
+import npanday.vendor.Vendor;
+import npanday.vendor.VendorFactory;
+import npanday.vendor.VendorInfo;
+import npanday.vendor.VendorInfoMatchPolicy;
+import npanday.vendor.VendorInfoRepository;
+import npanday.vendor.VendorUnsupportedException;
+import org.codehaus.plexus.logging.LogEnabled;
+import org.codehaus.plexus.logging.Logger;
-import java.util.List;
-import java.util.Collections;
+import java.io.File;
import java.util.ArrayList;
-import java.util.Set;
+import java.util.Collections;
import java.util.HashSet;
-import java.io.File;
-
-import org.codehaus.plexus.logging.LogEnabled;
-import org.codehaus.plexus.logging.Logger;
+import java.util.List;
+import java.util.Set;
/**
* Provides an implementation of <code>VendorInfoRepository</code>.
@@ -61,6 +66,11 @@ public class VendorInfoRepositoryImpl
private List<VendorInfo> cachedVendorInfos;
/**
+ * The version the repository was at, when the cache was built up.
+ */
+ private int cachedVendorInfosContentVersion;
+
+ /**
* Constructor. This method is intended to be invoked by the plexus-container, not by the application developer.
*/
public VendorInfoRepositoryImpl()
@@ -114,11 +124,11 @@ public class VendorInfoRepositoryImpl
{
List<VendorInfo> infos = getVendorInfosFor(vendorInfoExample, false);
if (infos.size() == 0) {
- throw new PlatformUnsupportedException( "NPANDAY-200-001: Could not find configuration for " + vendorInfoExample );
+ throw new PlatformUnsupportedException( "NPANDAY-113-001: Could not find configuration for " + vendorInfoExample );
}
if (infos.size() > 2) {
- // reload default
+ // reloadAll default
infos = getVendorInfosFor(vendorInfoExample, true);
}
@@ -129,28 +139,30 @@ public class VendorInfoRepositoryImpl
private List<VendorInfo> getVendorInfos()
{
+ ensureCache();
+
+ return Collections.unmodifiableList( cachedVendorInfos );
+ }
+
+ private void ensureCache()
+ {
SettingsRepository settingsRepository = (SettingsRepository) repositoryRegistry.find( "npanday-settings" );
- if ( settingsRepository.isReloaded() )
- {
- clearCache();
- settingsRepository.setReloaded(false);
+ if (settingsRepository.isEmpty()) {
+ logger.warn( "NPANDAY-113-000: The settings repository does not contain any vendor information" );
}
- try
- {
- settingsRepository.reload();
- }
- catch(Exception e)
+ if ( settingsRepository.getContentVersion() > cachedVendorInfosContentVersion )
{
- //e.printStackTrace();
+ clearCache();
}
-
- if ( cachedVendorInfos != null && cachedVendorInfos.size() > 0 && !settingsRepository.isReloaded() )
+
+ if ( cachedVendorInfos != null && cachedVendorInfos.size() > 0 )
{
- return Collections.unmodifiableList( cachedVendorInfos );
+ return;
}
+ cachedVendorInfosContentVersion = settingsRepository.getContentVersion();
cachedVendorInfos = new ArrayList<VendorInfo>();
for ( npanday.model.settings.Vendor v : settingsRepository.getVendors() )
@@ -181,7 +193,7 @@ public class VendorInfoRepositoryImpl
vendorInfo.setFrameworkVersion( framework.getFrameworkVersion() );
try
{
- vendorInfo.setVendor( VendorFactory.createVendorFromName(v.getVendorName()) );
+ vendorInfo.setVendor( VendorFactory.createVendorFromName( v.getVendorName() ) );
}
catch ( VendorUnsupportedException e )
{
@@ -189,11 +201,10 @@ public class VendorInfoRepositoryImpl
}
vendorInfo.setDefault(
v.getIsDefault() != null && v.getIsDefault().toLowerCase().trim().equals( "true" ) );
+
cachedVendorInfos.add( vendorInfo );
}
}
- settingsRepository.setReloaded( false );
- return Collections.unmodifiableList( cachedVendorInfos );
}
/**
@@ -309,7 +320,7 @@ public class VendorInfoRepositoryImpl
}
catch ( InvalidVersionFormatException e )
{
- throw new PlatformUnsupportedException( "NPANDAY-xxx-000: Invalid version format", e );
+ throw new PlatformUnsupportedException( "NPANDAY-113-004: Invalid version format", e );
}
for ( VendorInfo vendorInfo : vendorInfos )
@@ -321,7 +332,7 @@ public class VendorInfoRepositoryImpl
if ( !gacRoot.exists() )
{
throw new PlatformUnsupportedException(
- "NPANDAY-xxx-000: The Mono GAC path does not exist: Path = " +
+ "NPANDAY-113-005: The Mono GAC path does not exist: Path = " +
gacRoot.getAbsolutePath() );
}
return gacRoot;
@@ -359,6 +370,6 @@ public class VendorInfoRepositoryImpl
{
return new File( System.getenv("SystemRoot"), "\\Microsoft.NET\\assembly\\GAC_MSIL\\" );
}
- throw new PlatformUnsupportedException("NPANDAY-200-002: Could not locate a valid GAC");
+ throw new PlatformUnsupportedException("NPANDAY-113-006: Could not locate a valid GAC");
}
}
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoTransitionRuleFactory.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoTransitionRuleFactory.java?rev=1210393&r1=1210392&r2=1210393&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoTransitionRuleFactory.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoTransitionRuleFactory.java Mon Dec 5 10:09:31 2011
@@ -18,18 +18,26 @@
*/
package npanday.vendor.impl;
-import npanday.vendor.*;
import npanday.InitializationException;
import npanday.PlatformUnsupportedException;
import npanday.registry.RepositoryRegistry;
+import npanday.vendor.InvalidVersionFormatException;
+import npanday.vendor.SettingsException;
+import npanday.vendor.SettingsUtil;
+import npanday.vendor.Vendor;
+import npanday.vendor.VendorFactory;
+import npanday.vendor.VendorInfo;
+import npanday.vendor.VendorInfoRepository;
+import npanday.vendor.VendorInfoState;
+import npanday.vendor.VendorInfoTransitionRule;
+import npanday.vendor.VendorUnsupportedException;
+import org.codehaus.plexus.logging.Logger;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.HashSet;
-import java.util.ArrayList;
-import java.io.File;
-
-import org.codehaus.plexus.logging.Logger;
/**
* Provides factory methods for creating vendor info transition rules. These rules usually can determine the
@@ -96,6 +104,7 @@ final class VendorInfoTransitionRuleFact
}
logger.debug( "NPANDAY-103-036.0: Respository registry: " + repositoryRegistry);
+ // TODO: I think we should make sure settingsrepo is filled prio to this
SettingsRepository settingsRepository = null;
try
{
@@ -138,7 +147,7 @@ final class VendorInfoTransitionRuleFact
List<File> configuredExecutablePaths = vendorInfoRepository.getConfiguredVendorInfoByExample(vendorInfo).getExecutablePaths();
for(File path : configuredExecutablePaths){
if (!path.exists()) {
- logger.debug( "NPANDAY-103-61: Configured path does not exist and is therefore omitted: " + path );
+ logger.debug( "NPANDAY-103-061: Configured path does not exist and is therefore omitted: " + path );
}
else {
existingPaths.add(path);
@@ -148,7 +157,7 @@ final class VendorInfoTransitionRuleFact
}
catch ( PlatformUnsupportedException e )
{
- logger.debug( "NPANDAY-103-36: Failed to resolve configured executable paths." );
+ logger.warn( "NPANDAY-103-036: Failed to resolve configured executable paths.", e );
}
}
return VendorInfoState.EXIT;
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/test/java/npanday/vendor/impl/VendorInfoTransitionRuleFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/test/java/npanday/vendor/impl/VendorInfoTransitionRuleFactoryTest.java?rev=1210393&r1=1210392&r2=1210393&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/test/java/npanday/vendor/impl/VendorInfoTransitionRuleFactoryTest.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/test/java/npanday/vendor/impl/VendorInfoTransitionRuleFactoryTest.java Mon Dec 5 10:09:31 2011
@@ -37,6 +37,7 @@ public class VendorInfoTransitionRuleFac
extends TestCase
{
public void testNTF()
+ throws NoSuchFieldException, IllegalAccessException
{
List<VendorInfo> vendorInfoList = new ArrayList<VendorInfo>();
vendorInfoList.add( VendorTestFactory.getVendorInfo( Vendor.MONO, "1.1.18", "1.1.4322" ) );
@@ -55,6 +56,7 @@ public class VendorInfoTransitionRuleFac
}
public void testNFF()
+ throws NoSuchFieldException, IllegalAccessException
{
List<VendorInfo> vendorInfoList = new ArrayList<VendorInfo>();
vendorInfoList.add( VendorTestFactory.getVendorInfo( Vendor.MONO, "1.1.18", "1.1.4322" ) );
@@ -73,6 +75,7 @@ public class VendorInfoTransitionRuleFac
}
public void testNFF_MatchDefaultVendor()
+ throws NoSuchFieldException, IllegalAccessException
{
List<VendorInfo> vendorInfoList = new ArrayList<VendorInfo>();
vendorInfoList.add( VendorTestFactory.getVendorInfo( Vendor.MONO, "1.1.18", "2.0.50727" ) );
@@ -91,6 +94,7 @@ public class VendorInfoTransitionRuleFac
}
public void testNFT()
+ throws NoSuchFieldException, IllegalAccessException
{
List<VendorInfo> vendorInfoList = new ArrayList<VendorInfo>();
vendorInfoList.add( VendorTestFactory.getVendorInfo( Vendor.MONO, "1.1.13", "2.0.50727" ) );
@@ -109,6 +113,7 @@ public class VendorInfoTransitionRuleFac
}
public void testNFT_WithMatchingDefault()
+ throws NoSuchFieldException, IllegalAccessException
{
List<VendorInfo> vendorInfoList = new ArrayList<VendorInfo>();
vendorInfoList.add( VendorTestFactory.getVendorInfo( Vendor.MONO, "1.1.18", "2.0.50727" ) );
@@ -126,6 +131,7 @@ public class VendorInfoTransitionRuleFac
}
public void testNFT_CantFindMatchingVendorInfo()
+ throws NoSuchFieldException, IllegalAccessException
{
VendorInfoTransitionRuleFactory factory = Factory.getVendorInfoTransitionRuleFactory(
VendorTestFactory.getDefaultSetup( "MICROSOFT", "2.0.50727", "2.0.50727" ), new ArrayList<VendorInfo>() );
@@ -140,22 +146,15 @@ public class VendorInfoTransitionRuleFac
{
static VendorInfoTransitionRuleFactory getVendorInfoTransitionRuleFactory( DefaultSetup defaultSetup,
List<VendorInfo> vendorInfos )
+ throws NoSuchFieldException, IllegalAccessException
{
SettingsRepository settingsRepository = new SettingsRepository();
- try
- {
- Field field = settingsRepository.getClass().getDeclaredField( "defaultSetup" );
- field.setAccessible( true );
- field.set( settingsRepository, defaultSetup );
- }
- catch ( NoSuchFieldException e )
- {
- e.printStackTrace();
- }
- catch ( IllegalAccessException e )
- {
- e.printStackTrace();
- }
+ settingsRepository.enableLogging( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ) );
+
+ Field field = settingsRepository.getClass().getDeclaredField( "defaultSetup" );
+ field.setAccessible( true );
+ field.set( settingsRepository, defaultSetup );
+
RepositoryRegistryTestStub repositoryRegistry = new RepositoryRegistryTestStub();
repositoryRegistry.setSettingRepository( settingsRepository );
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/pom.xml
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/pom.xml?rev=1210393&r1=1210392&r2=1210393&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/pom.xml (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/pom.xml Mon Dec 5 10:09:31 2011
@@ -18,36 +18,73 @@ KIND, either express or implied. See th
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/maven-v4_0_0.xsd">
- <parent>
+<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/maven-v4_0_0.xsd">
+ <parent>
<groupId>org.apache.npanday</groupId>
- <version>1.5.0-azuresupport-SNAPSHOT</version>
- <artifactId>npanday-project</artifactId>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>dotnet-components</artifactId>
- <packaging>pom</packaging>
- <name>NPanday :: Java Components</name>
- <modules>
- <module>dotnet-artifact</module>
- <module>dotnet-assembler</module>
- <module>dotnet-core</module>
- <module>dotnet-dao-project</module>
+ <version>1.5.0-azuresupport-SNAPSHOT</version>
+ <artifactId>npanday-project</artifactId>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>dotnet-components</artifactId>
+ <packaging>pom</packaging>
+ <name>NPanday :: Java Components</name>
+ <modules>
+ <module>dotnet-artifact</module>
+ <module>dotnet-assembler</module>
+ <module>dotnet-core</module>
+ <module>dotnet-dao-project</module>
<module>dotnet-executable</module>
- <module>dotnet-model</module>
- <module>dotnet-plugin</module>
- <module>dotnet-registry</module>
- <module>dotnet-repository</module>
- <module>dotnet-vendor</module>
+ <module>dotnet-model</module>
+ <module>dotnet-plugin</module>
+ <module>dotnet-registry</module>
+ <module>dotnet-repository</module>
+ <module>dotnet-vendor</module>
</modules>
-<reporting>
+ <dependencies>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <!-- version is defined in parent pom -->
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-annotations</artifactId>
+ <version>1.5.5</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-metadata</artifactId>
+ <version>1.5.5</version>
+ <executions>
+ <execution>
+ <id>process-classes</id>
+ <goals>
+ <goal>generate-metadata</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>process-test-classes</id>
+ <goals>
+ <goal>generate-test-metadata</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <reporting>
<excludeDefaults>true</excludeDefaults>
- <plugins>
- <plugin>
+ <plugins>
+ <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>emma-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
</plugin>
</plugins>
-</reporting>
+ </reporting>
</project>
Modified: incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-aspx-plugin/src/main/java/npanday/plugin/aspx/AspxCompilerMojo.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-aspx-plugin/src/main/java/npanday/plugin/aspx/AspxCompilerMojo.java?rev=1210393&r1=1210392&r2=1210393&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-aspx-plugin/src/main/java/npanday/plugin/aspx/AspxCompilerMojo.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-aspx-plugin/src/main/java/npanday/plugin/aspx/AspxCompilerMojo.java Mon Dec 5 10:09:31 2011
@@ -19,11 +19,6 @@ package npanday.plugin.aspx;
* under the License.
*/
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
import npanday.ArtifactType;
import npanday.PlatformUnsupportedException;
import npanday.executable.ExecutionException;
@@ -39,6 +34,11 @@ import org.apache.maven.plugin.MojoExecu
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.FileUtils;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* Maven Mojo for precompiling ASPx files
*
@@ -141,11 +141,6 @@ public class AspxCompilerMojo
* @component
*/
private npanday.executable.NetExecutableFactory netExecutableFactory;
-
- /**
- * @component
- */
- private npanday.NPandayRepositoryRegistry npandayRegistry;
private File webSourceDirectory;
Modified: incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java?rev=1210393&r1=1210392&r2=1210393&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java Mon Dec 5 10:09:31 2011
@@ -22,30 +22,35 @@ package npanday.plugin.compile;
import npanday.ArtifactType;
import npanday.ArtifactTypeHelper;
import npanday.PathUtil;
-import npanday.vendor.SettingsException;
-import npanday.vendor.SettingsUtil;
-import org.apache.maven.artifact.Artifact;
import npanday.PlatformUnsupportedException;
import npanday.assembler.AssemblerContext;
-import npanday.assembler.AssemblyInfoMarshaller;
-import npanday.assembler.AssemblyInfoException;
import npanday.assembler.AssemblyInfo;
import npanday.assembler.AssemblyInfo.TargetFramework;
+import npanday.assembler.AssemblyInfoException;
+import npanday.assembler.AssemblyInfoMarshaller;
import npanday.executable.ExecutionException;
import npanday.executable.compiler.CompilerConfig;
import npanday.executable.compiler.CompilerExecutable;
import npanday.executable.compiler.CompilerRequirement;
import npanday.registry.RepositoryRegistry;
+import npanday.vendor.SettingsException;
+import npanday.vendor.SettingsUtil;
+import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectHelper;
import org.codehaus.plexus.util.FileUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
import java.io.BufferedReader;
import java.io.BufferedWriter;
-import java.io.File;
import java.io.ByteArrayOutputStream;
+import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
@@ -53,18 +58,11 @@ import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
-import java.util.Set;
import java.util.Arrays;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
import java.util.List;
-
-import java.util.regex.Pattern;
+import java.util.Set;
import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* Abstract Class for compile mojos for both test-compile and compile.
@@ -1111,6 +1109,7 @@ public abstract class AbstractCompilerMo
}
+
try
{
SettingsUtil.populateSettingsRepository( repositoryRegistry, settingsPath );
Modified: incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AssemblyInfoGeneratorMojo.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AssemblyInfoGeneratorMojo.java?rev=1210393&r1=1210392&r2=1210393&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AssemblyInfoGeneratorMojo.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AssemblyInfoGeneratorMojo.java Mon Dec 5 10:09:31 2011
@@ -19,26 +19,25 @@
package npanday.plugin.compile;
import npanday.ArtifactTypeHelper;
+import npanday.assembler.AssemblerContext;
+import npanday.assembler.AssemblyInfo;
+import npanday.assembler.AssemblyInfoException;
+import npanday.assembler.AssemblyInfoMarshaller;
+import npanday.vendor.Vendor;
+import npanday.vendor.VendorFactory;
+import npanday.vendor.VendorInfo;
+import npanday.vendor.VendorUnsupportedException;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.FileUtils;
-import java.io.IOException;
import java.io.File;
-import java.io.FileOutputStream;
+import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import npanday.InitializationException;
-import npanday.PlatformUnsupportedException;
-import npanday.vendor.*;
-import npanday.assembler.AssemblerContext;
-import npanday.assembler.AssemblyInfoMarshaller;
-import npanday.assembler.AssemblyInfoException;
-import npanday.assembler.AssemblyInfo;
-
/**
* Generates an AssemblyInfo.* class based on information within the pom file.
*
@@ -141,6 +140,8 @@ public class AssemblyInfoGeneratorMojo
return;
}
+
+
File srcFile = new File( sourceDirectory );
if ( srcFile.exists() )
{
Modified: incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-install-plugin/src/main/java/npanday/plugin/install/FileInstallerMojo.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-install-plugin/src/main/java/npanday/plugin/install/FileInstallerMojo.java?rev=1210393&r1=1210392&r2=1210393&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-install-plugin/src/main/java/npanday/plugin/install/FileInstallerMojo.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-install-plugin/src/main/java/npanday/plugin/install/FileInstallerMojo.java Mon Dec 5 10:09:31 2011
@@ -18,19 +18,18 @@
*/
package npanday.plugin.install;
+import npanday.artifact.ArtifactContext;
+import npanday.dao.ProjectDao;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.installer.ArtifactInstallationException;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
import java.io.File;
-import npanday.artifact.ArtifactContext;
-import npanday.dao.ProjectDao;
-import org.apache.maven.artifact.installer.ArtifactInstallationException;
-import org.apache.maven.artifact.resolver.ArtifactResolver;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.factory.ArtifactFactory;
-
/**
* Installs assembly file into the local repository
*
@@ -99,11 +98,6 @@ public class FileInstallerMojo
private ArtifactContext artifactContext;
/**
- * @component
- */
- private npanday.NPandayRepositoryRegistry npandayRegistry;
-
- /**
* The artifact factory component, which is used for creating artifacts.
*
* @component
Modified: incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-resgen-plugin/src/main/java/npanday/plugin/resgen/ResourceGeneratorMojo.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-resgen-plugin/src/main/java/npanday/plugin/resgen/ResourceGeneratorMojo.java?rev=1210393&r1=1210392&r2=1210393&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-resgen-plugin/src/main/java/npanday/plugin/resgen/ResourceGeneratorMojo.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-resgen-plugin/src/main/java/npanday/plugin/resgen/ResourceGeneratorMojo.java Mon Dec 5 10:09:31 2011
@@ -18,20 +18,14 @@
*/
package npanday.plugin.resgen;
+import npanday.artifact.ArtifactContext;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.util.FileUtils;
-import npanday.executable.ExecutionException;
-import npanday.PlatformUnsupportedException;
-import npanday.vendor.VendorInfo;
-import npanday.vendor.VendorFactory;
-import npanday.artifact.ArtifactContext;
+import java.io.File;
import java.util.ArrayList;
import java.util.List;
-import java.io.File;
-import java.io.IOException;
/**
* Generates resources
@@ -92,11 +86,6 @@ public class ResourceGeneratorMojo
*/
private npanday.executable.NetExecutableFactory netExecutableFactory;
- /**
- * @component
- */
- private npanday.NPandayRepositoryRegistry npandayRegistry;
-
public void execute()
throws MojoExecutionException
{
Modified: incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-resolver-plugin/src/main/java/npanday/plugin/resolver/NetDependencyResolverMojo.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-resolver-plugin/src/main/java/npanday/plugin/resolver/NetDependencyResolverMojo.java?rev=1210393&r1=1210392&r2=1210393&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-resolver-plugin/src/main/java/npanday/plugin/resolver/NetDependencyResolverMojo.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-resolver-plugin/src/main/java/npanday/plugin/resolver/NetDependencyResolverMojo.java Mon Dec 5 10:09:31 2011
@@ -18,27 +18,25 @@
*/
package npanday.plugin.resolver;
+import npanday.PlatformUnsupportedException;
+import npanday.artifact.ArtifactContext;
import npanday.artifact.NPandayArtifactResolutionException;
-import npanday.registry.NPandayRepositoryException;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.model.Dependency;
-import org.apache.maven.artifact.Artifact;
+import npanday.artifact.NetDependenciesRepository;
+import npanday.artifact.NetDependencyMatchPolicy;
+import npanday.executable.ExecutionException;
+import npanday.executable.NetExecutable;
+import npanday.model.netdependency.NetDependency;
import npanday.registry.RepositoryRegistry;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Dependency;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
import java.io.File;
import java.io.IOException;
-import java.util.List;
import java.util.ArrayList;
-
-import npanday.artifact.NetDependenciesRepository;
-import npanday.artifact.NetDependencyMatchPolicy;
-import npanday.artifact.ArtifactContext;
-import npanday.model.netdependency.NetDependency;
-import npanday.executable.NetExecutable;
-import npanday.executable.ExecutionException;
-import npanday.PlatformUnsupportedException;
+import java.util.List;
/**
* @author Shane Isbell
@@ -96,7 +94,7 @@ public class NetDependencyResolverMojo
/**
* @component
*/
- private npanday.NPandayRepositoryRegistry npandayRegistry;
+ private RepositoryRegistry repositoryRegistry;
/**
* @component
@@ -128,22 +126,6 @@ public class NetDependencyResolverMojo
String profile = System.getProperty( "dependencyProfile" );
- RepositoryRegistry repositoryRegistry;
- try
- {
- repositoryRegistry = npandayRegistry.createRepositoryRegistry();
- }
- catch ( IOException e )
- {
- throw new MojoExecutionException(
- "NPANDAY-1600-000: Failed to create the repository registry for this plugin", e );
- }
- catch( NPandayRepositoryException e )
- {
- throw new MojoExecutionException(
- "NPANDAY-1600-007: Failed to create the repository registry for this plugin", e );
- }
-
if ( netDependencies == null )
{
netDependencies = new NetDependency[0];