Skip to content

Commit

Permalink
replace handwritten components.xml with annotations (#285)
Browse files Browse the repository at this point in the history
* replace most handwritten components.xml with annotations

fixes #275
  • Loading branch information
hboutemy authored Dec 30, 2022
1 parent e98cde5 commit 33c8523
Show file tree
Hide file tree
Showing 47 changed files with 134 additions and 306 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,30 @@
* SOFTWARE.
*/

import java.util.Map;

import org.codehaus.modello.ModelloRuntimeException;
import org.codehaus.modello.plugin.AbstractPluginManager;
import org.codehaus.modello.plugin.ModelloGenerator;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;

/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*/
@Component( role = GeneratorPluginManager.class )
public class DefaultGeneratorPluginManager
extends AbstractPluginManager<ModelloGenerator>
implements GeneratorPluginManager
{
@Requirement
private Map<String, ModelloGenerator> plugins;

public Map<String, ModelloGenerator> getPlugins()
{
return plugins;
}

public ModelloGenerator getGeneratorPlugin( String generatorId )
{
ModelloGenerator generator = getPlugin( generatorId );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,30 @@
* SOFTWARE.
*/

import java.util.Map;

import org.codehaus.modello.ModelloRuntimeException;
import org.codehaus.modello.metadata.MetadataPlugin;
import org.codehaus.modello.plugin.AbstractPluginManager;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;

/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*/
@Component( role = MetadataPluginManager.class )
public class DefaultMetadataPluginManager
extends AbstractPluginManager<MetadataPlugin>
implements MetadataPluginManager
{
@Requirement
private Map<String, MetadataPlugin> plugins;

public Map<String, MetadataPlugin> getPlugins()
{
return plugins;
}

public MetadataPlugin getMetadataPlugin( String metadataId )
{
MetadataPlugin metadata = getPlugin( metadataId );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import org.codehaus.modello.model.ModelInterface;
import org.codehaus.modello.model.ModelValidationException;
import org.codehaus.modello.plugin.ModelloGenerator;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.util.ReaderFactory;

import java.io.File;
Expand All @@ -55,17 +57,14 @@
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
* @author <a href="mailto:evenisse@codehaus.org">Emmanuel Venisse</a>
*/
@Component( role = ModelloCore.class )
public class DefaultModelloCore
extends AbstractModelloCore
{
/**
* @requirement
*/
@Requirement
private MetadataPluginManager metadataPluginManager;

/**
* @requirement
*/
@Requirement
private GeneratorPluginManager generatorPluginManager;

public MetadataPluginManager getMetadataPluginManager()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/

import org.codehaus.modello.ModelloRuntimeException;

import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;

Expand All @@ -37,26 +38,20 @@ public abstract class AbstractPluginManager<T>
extends AbstractLogEnabled
implements Initializable
{
/* injected by Plexus: see META-INF/plexus/components.xml */
private Map<String, T> plugins = new HashMap<String, T>();

public void initialize()
{
}

public Map<String, T> getPlugins()
{
return plugins;
}
abstract public Map<String, T> getPlugins();

public Iterator<T> getPluginsIterator()
{
return plugins.values().iterator();
return getPlugins().values().iterator();
}

public T getPlugin( String name )
{
T plugin = plugins.get( name );
T plugin = getPlugins().get( name );

if ( plugin == null )
{
Expand All @@ -68,6 +63,6 @@ public T getPlugin( String name )

public boolean hasPlugin( String name )
{
return plugins.containsKey( name );
return getPlugins().containsKey( name );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@
import org.codehaus.modello.model.ModelField;
import org.codehaus.modello.model.ModelInterface;

import org.codehaus.plexus.component.annotations.Component;

import java.util.Map;

/**
* @author <a href="mailto:evenisse@codehaus.org">Emmanuel Venisse</a>
*/
@Component( role = MetadataPlugin.class, hint = "model" )
public class ModelMetadataPlugin
extends AbstractMetadataPlugin
implements MetadataPlugin
Expand Down
45 changes: 0 additions & 45 deletions modello-core/src/main/resources/META-INF/plexus/components.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.codehaus.modello.model.ModelField;
import org.codehaus.modello.model.Version;
import org.codehaus.modello.model.VersionDefinition;
import org.codehaus.modello.plugin.ModelloGenerator;
import org.codehaus.modello.plugin.java.AbstractJavaModelloGenerator;
import org.codehaus.modello.plugin.java.javasource.JClass;
import org.codehaus.modello.plugin.java.javasource.JInterface;
Expand All @@ -43,6 +44,7 @@
import org.codehaus.modello.plugin.java.javasource.JType;
import org.codehaus.modello.plugin.java.metadata.JavaClassMetadata;
import org.codehaus.modello.plugin.java.metadata.JavaFieldMetadata;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.IOUtil;

import java.io.IOException;
Expand All @@ -54,6 +56,7 @@
/**
* Generate a basic conversion class between two versions of a model.
*/
@Component( role = ModelloGenerator.class, hint = "converters" )
public class ConverterGenerator
extends AbstractJavaModelloGenerator
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.codehaus.modello.model.ModelClass;
import org.codehaus.modello.model.ModelDefault;
import org.codehaus.modello.model.ModelField;
import org.codehaus.modello.plugin.ModelloGenerator;
import org.codehaus.modello.plugin.java.javasource.JClass;
import org.codehaus.modello.plugin.java.javasource.JMethod;
import org.codehaus.modello.plugin.java.javasource.JParameter;
Expand All @@ -37,6 +38,7 @@
import org.codehaus.modello.plugins.xml.AbstractXmlJavaGenerator;
import org.codehaus.modello.plugins.xml.metadata.XmlAssociationMetadata;
import org.codehaus.modello.plugins.xml.metadata.XmlFieldMetadata;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.StringUtils;

import java.io.IOException;
Expand All @@ -49,6 +51,7 @@
*
* @author <a href="mailto:brett@codehaus.org">Brett Porter</a>
*/
@Component( role = ModelloGenerator.class, hint = "dom4j-reader" )
public class Dom4jReaderGenerator
extends AbstractXmlJavaGenerator
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.codehaus.modello.model.ModelClass;
import org.codehaus.modello.model.ModelDefault;
import org.codehaus.modello.model.ModelField;
import org.codehaus.modello.plugin.ModelloGenerator;
import org.codehaus.modello.plugin.java.javasource.JClass;
import org.codehaus.modello.plugin.java.javasource.JMethod;
import org.codehaus.modello.plugin.java.javasource.JParameter;
Expand All @@ -39,6 +40,7 @@
import org.codehaus.modello.plugins.xml.metadata.XmlAssociationMetadata;
import org.codehaus.modello.plugins.xml.metadata.XmlFieldMetadata;
import org.codehaus.modello.plugins.xml.metadata.XmlModelMetadata;
import org.codehaus.plexus.component.annotations.Component;

import java.io.IOException;
import java.util.List;
Expand All @@ -52,6 +54,7 @@
*
* @author <a href="mailto:brett@codehaus.org">Brett Porter</a>
*/
@Component( role = ModelloGenerator.class, hint = "dom4j-writer" )
public class Dom4jWriterGenerator
extends AbstractXmlJavaGenerator
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.codehaus.modello.model.ModelClass;
import org.codehaus.modello.model.ModelDefault;
import org.codehaus.modello.model.ModelField;
import org.codehaus.modello.plugin.ModelloGenerator;
import org.codehaus.modello.plugin.java.javasource.JClass;
import org.codehaus.modello.plugin.java.javasource.JConstructor;
import org.codehaus.modello.plugin.java.javasource.JField;
Expand All @@ -46,11 +47,13 @@
import org.codehaus.modello.plugins.xml.metadata.XmlAssociationMetadata;
import org.codehaus.modello.plugins.xml.metadata.XmlClassMetadata;
import org.codehaus.modello.plugins.xml.metadata.XmlFieldMetadata;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.StringUtils;

/**
* @author <a href="mailto:simonetripodi@apache.org">Simone Tripodi</a>
*/
@Component( role = ModelloGenerator.class, hint = "jackson-reader" )
public class JacksonReaderGenerator
extends AbstractJacksonGenerator
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.codehaus.modello.model.ModelClass;
import org.codehaus.modello.model.ModelDefault;
import org.codehaus.modello.model.ModelField;
import org.codehaus.modello.plugin.ModelloGenerator;
import org.codehaus.modello.plugin.java.javasource.JClass;
import org.codehaus.modello.plugin.java.javasource.JConstructor;
import org.codehaus.modello.plugin.java.javasource.JField;
Expand All @@ -42,10 +43,12 @@
import org.codehaus.modello.plugin.java.metadata.JavaFieldMetadata;
import org.codehaus.modello.plugins.xml.metadata.XmlAssociationMetadata;
import org.codehaus.modello.plugins.xml.metadata.XmlFieldMetadata;
import org.codehaus.plexus.component.annotations.Component;

/**
* @author <a href="mailto:simonetripodi@apache.org">Simone Tripodi</a>
*/
@Component( role = ModelloGenerator.class, hint = "jackson-writer" )
public class JacksonWriterGenerator
extends AbstractJacksonGenerator
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.codehaus.modello.model.ModelDefault;
import org.codehaus.modello.model.ModelField;
import org.codehaus.modello.model.ModelInterface;
import org.codehaus.modello.plugin.ModelloGenerator;
import org.codehaus.modello.plugin.java.javasource.JArrayType;
import org.codehaus.modello.plugin.java.javasource.JClass;
import org.codehaus.modello.plugin.java.javasource.JCollectionType;
Expand All @@ -59,11 +60,13 @@
import org.codehaus.modello.plugin.java.metadata.JavaClassMetadata;
import org.codehaus.modello.plugin.java.metadata.JavaFieldMetadata;
import org.codehaus.modello.plugin.model.ModelClassMetadata;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.StringUtils;

/**
* @author <a href="mailto:jason@modello.org">Jason van Zyl</a>
*/
@Component( role = ModelloGenerator.class, hint = "java" )
public class JavaModelloGenerator
extends AbstractJavaModelloGenerator
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@
import org.codehaus.modello.model.ModelClass;
import org.codehaus.modello.model.ModelField;
import org.codehaus.modello.model.ModelInterface;
import org.codehaus.plexus.component.annotations.Component;

import java.util.Map;

/**
* @author <a href="mailto:evenisse@codehaus.org">Emmanuel Venisse </a>
*/
@Component( role = MetadataPlugin.class, hint = "java" )
public class JavaMetadataPlugin
extends AbstractMetadataPlugin
implements MetadataPlugin
Expand Down
Loading

0 comments on commit 33c8523

Please sign in to comment.