Browse Source

Reworked TypeDef classes to work with immutable TypeDefinition objects

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271108 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 23 years ago
parent
commit
0f4ea3d22b
3 changed files with 60 additions and 36 deletions
  1. +20
    -1
      proposal/myrmidon/src/java/org/apache/antlib/runtime/ConverterDef.java
  2. +16
    -2
      proposal/myrmidon/src/java/org/apache/antlib/runtime/TypeDef.java
  3. +24
    -33
      proposal/myrmidon/src/java/org/apache/myrmidon/framework/AbstractTypeDef.java

+ 20
- 1
proposal/myrmidon/src/java/org/apache/antlib/runtime/ConverterDef.java View File

@@ -20,8 +20,27 @@ import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
public class ConverterDef
extends AbstractTypeDef
{
private String m_sourceType;
private String m_destinationType;

/**
* Sets the converter's source type.
*/
public void setSourceType( final String sourceType )
{
m_sourceType = sourceType;
}

/**
* Sets the converter's destination type.
*/
public void setDestinationType( final String destinationType )
{
m_destinationType = destinationType;
}

protected TypeDefinition createTypeDefinition()
{
return new ConverterDefinition();
return new ConverterDefinition( getClassname(), m_sourceType, m_destinationType );
}
}

+ 16
- 2
proposal/myrmidon/src/java/org/apache/antlib/runtime/TypeDef.java View File

@@ -8,7 +8,6 @@
package org.apache.antlib.runtime;

import org.apache.myrmidon.framework.AbstractTypeDef;
import org.apache.myrmidon.interfaces.deployer.GeneralTypeDefinition;
import org.apache.myrmidon.interfaces.deployer.TypeDefinition;

/**
@@ -20,8 +19,23 @@ import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
public class TypeDef
extends AbstractTypeDef
{
private String m_role;

public void setName( final String name )
{
super.setName( name );
}

/**
* Sets the type's role.
*/
public void setRole( final String role )
{
m_role = role;
}

protected TypeDefinition createTypeDefinition()
{
return new GeneralTypeDefinition();
return new TypeDefinition( getName(), m_role, getClassname() );
}
}

+ 24
- 33
proposal/myrmidon/src/java/org/apache/myrmidon/framework/AbstractTypeDef.java View File

@@ -10,9 +10,6 @@ package org.apache.myrmidon.framework;
import java.io.File;
import org.apache.avalon.excalibur.i18n.ResourceManager;
import org.apache.avalon.excalibur.i18n.Resources;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.interfaces.deployer.Deployer;
import org.apache.myrmidon.interfaces.deployer.DeploymentException;
@@ -28,45 +25,38 @@ import org.apache.myrmidon.interfaces.deployer.TypeDeployer;
*/
public abstract class AbstractTypeDef
extends AbstractContainerTask
implements Configurable
{
private final static Resources REZ =
ResourceManager.getPackageResources( AbstractTypeDef.class );

// TODO - replace lib with class-path
private File m_lib;
private TypeDefinition m_typeDef;
private String m_name;
private String m_classname;

/**
* Configures this task.
*/
public void configure( Configuration configuration ) throws ConfigurationException
protected void setName( final String name )
{
m_typeDef = createTypeDefinition();
m_name = name;
}

// Configure attributes
final String[] attrs = configuration.getAttributeNames();
for( int i = 0; i < attrs.length; i++ )
{
final String name = attrs[ i ];
final String value = configuration.getAttribute( name );
if( name.equalsIgnoreCase( "lib" ) )
{
m_lib = (File)convert( File.class, value );
}
else
{
configure( m_typeDef, name, value );
}
}
public void setClassname( final String classname )
{
m_classname = classname;
}

// Configure nested elements
final Configuration[] elements = configuration.getChildren();
for( int i = 0; i < elements.length; i++ )
{
Configuration element = elements[ i ];
configure( m_typeDef, element );
}
public void setLib( final File lib )
{
m_lib = lib;
}

protected final String getName()
{
return m_name;
}

protected final String getClassname()
{
return m_classname;
}

/**
@@ -86,7 +76,8 @@ public abstract class AbstractTypeDef
// Locate the deployer, and use it to deploy the type
final Deployer deployer = (Deployer)getService( Deployer.class );
final TypeDeployer typeDeployer = deployer.createDeployer( m_lib );
typeDeployer.deployType( m_typeDef );
final TypeDefinition typeDef = createTypeDefinition();
typeDeployer.deployType( typeDef );
}
catch( DeploymentException e )
{


Loading…
Cancel
Save