Browse Source

Simplify deployment so that it uses files instead of URLs and does not name deployments.

Moved RoleManager and separated interface/implementation into deployer package.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269091 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 25 years ago
parent
commit
5872737ff5
10 changed files with 185 additions and 132 deletions
  1. +5
    -12
      proposal/myrmidon/src/java/org/apache/ant/modules/core/AbstractTypeDefinition.java
  2. +16
    -17
      proposal/myrmidon/src/java/org/apache/ant/modules/core/RegisterConverter.java
  3. +12
    -7
      proposal/myrmidon/src/java/org/apache/ant/modules/core/RegisterDataType.java
  4. +12
    -7
      proposal/myrmidon/src/java/org/apache/ant/modules/core/RegisterTasklet.java
  5. +2
    -7
      proposal/myrmidon/src/java/org/apache/ant/modules/core/RegisterTasklib.java
  6. +38
    -15
      proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer/DefaultRoleManager.java
  7. +41
    -57
      proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer/DefaultTskDeployer.java
  8. +41
    -0
      proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer/RoleManager.java
  9. +7
    -8
      proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer/TskDeployer.java
  10. +11
    -2
      proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor/MyrmidonEmbeddor.java

+ 5
- 12
proposal/myrmidon/src/java/org/apache/ant/modules/core/AbstractTypeDefinition.java View File

@@ -8,8 +8,6 @@
package org.apache.ant.modules.core; package org.apache.ant.modules.core;


import java.io.File; import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import org.apache.avalon.framework.component.ComponentException; import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentManager; import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.component.Composable; import org.apache.avalon.framework.component.Composable;
@@ -69,9 +67,9 @@ public abstract class AbstractTypeDefinition
"lib parameter" ); "lib parameter" );
} }


final URL url = getURL( m_lib );
final File file = getFile( m_lib );


registerResource( m_name, m_classname, url );
registerResource( m_name, m_classname, file );
} }


protected final TskDeployer getDeployer() protected final TskDeployer getDeployer()
@@ -84,17 +82,12 @@ public abstract class AbstractTypeDefinition
return m_typeManager; return m_typeManager;
} }


private final URL getURL( final String libName )
private final File getFile( final String libName )
throws TaskException throws TaskException
{ {
if( null != libName ) if( null != libName )
{ {
final File lib = getContext().resolveFile( libName );
try { return lib.toURL(); }
catch( final MalformedURLException mue )
{
throw new TaskException( "Malformed task-lib parameter " + m_lib, mue );
}
return getContext().resolveFile( libName );
} }
else else
{ {
@@ -102,6 +95,6 @@ public abstract class AbstractTypeDefinition
} }
} }


protected abstract void registerResource( String name, String classname, URL url )
protected abstract void registerResource( String name, String classname, File file )
throws TaskException; throws TaskException;
} }

+ 16
- 17
proposal/myrmidon/src/java/org/apache/ant/modules/core/RegisterConverter.java View File

@@ -76,10 +76,10 @@ public class RegisterConverter
throw new TaskException( "Must specify classname parameter" ); throw new TaskException( "Must specify classname parameter" );
} }


final URL url = getURL( m_lib );

boolean isFullyDefined = true; boolean isFullyDefined = true;


final File file = getFile( m_lib );

if( null == m_sourceType && null == m_destinationType ) if( null == m_sourceType && null == m_destinationType )
{ {
isFullyDefined = false; isFullyDefined = false;
@@ -90,7 +90,7 @@ public class RegisterConverter
"parameters when supplying a name" ); "parameters when supplying a name" );
} }


if( !isFullyDefined && null == url )
if( !isFullyDefined && null == file )
{ {
throw new TaskException( "Must supply parameter if not fully specifying converter" ); throw new TaskException( "Must supply parameter if not fully specifying converter" );
} }
@@ -99,22 +99,26 @@ public class RegisterConverter
{ {
try try
{ {
m_tskDeployer.deployConverter( m_classname, url.toString(), url );
m_tskDeployer.deployConverter( m_classname, file );
} }
catch( final DeploymentException de ) catch( final DeploymentException de )
{ {
throw new TaskException( "Failed deploying " + m_classname + throw new TaskException( "Failed deploying " + m_classname +
" from " + url, de );
" from " + file, de );
} }
} }
else else
{ {
m_converterRegistry.registerConverter( m_classname, m_sourceType, m_destinationType );

final DefaultTypeFactory factory = new DefaultTypeFactory( new URL[] { url } );
factory.addNameClassMapping( m_classname, m_classname );
try
{
m_converterRegistry.registerConverter( m_classname, m_sourceType, m_destinationType );


try { m_typeManager.registerType( Converter.ROLE, m_classname, factory ); }
final URL url = file.toURL();
final DefaultTypeFactory factory = new DefaultTypeFactory( new URL[] { url } );
factory.addNameClassMapping( m_classname, m_classname );
m_typeManager.registerType( Converter.ROLE, m_classname, factory );
}
catch( final Exception e ) catch( final Exception e )
{ {
throw new TaskException( "Failed to register converter " + m_classname, e ); throw new TaskException( "Failed to register converter " + m_classname, e );
@@ -122,17 +126,12 @@ public class RegisterConverter
} }
} }


private URL getURL( final String libName )
private File getFile( final String libName )
throws TaskException throws TaskException
{ {
if( null != libName ) if( null != libName )
{ {
final File lib = getContext().resolveFile( libName );
try { return lib.toURL(); }
catch( final MalformedURLException mue )
{
throw new TaskException( "Malformed task-lib parameter " + m_lib, mue );
}
return getContext().resolveFile( libName );
} }
else else
{ {


+ 12
- 7
proposal/myrmidon/src/java/org/apache/ant/modules/core/RegisterDataType.java View File

@@ -7,6 +7,7 @@
*/ */
package org.apache.ant.modules.core; package org.apache.ant.modules.core;


import java.io.File;
import java.net.URL; import java.net.URL;
import org.apache.myrmidon.api.DataType; import org.apache.myrmidon.api.DataType;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;
@@ -23,25 +24,29 @@ public class RegisterDataType
{ {
protected void registerResource( final String name, protected void registerResource( final String name,
final String className, final String className,
final URL url )
final File file )
throws TaskException throws TaskException
{ {
if( null == className ) if( null == className )
{ {
try { getDeployer().deployDataType( name, url.toString(), url ); }
try { getDeployer().deployDataType( name, file ); }
catch( final DeploymentException de ) catch( final DeploymentException de )
{ {
throw new TaskException( "Failed deploying " + name + " from " + url, de );
throw new TaskException( "Failed deploying " + name + " from " + file, de );
} }
} }
else else
{ {
final DefaultTypeFactory factory = new DefaultTypeFactory( new URL[] { url } );
factory.addNameClassMapping( name, className );
try { getTypeManager().registerType( DataType.ROLE, name, factory ); }
try
{
final URL url = file.toURL();
final DefaultTypeFactory factory = new DefaultTypeFactory( new URL[] { url } );
factory.addNameClassMapping( name, className );
getTypeManager().registerType( DataType.ROLE, name, factory );
}
catch( final Exception e ) catch( final Exception e )
{ {
throw new TaskException( "Failed registering " + name + " from " + url, e );
throw new TaskException( "Failed registering " + name + " from " + file, e );
} }
} }
} }


+ 12
- 7
proposal/myrmidon/src/java/org/apache/ant/modules/core/RegisterTasklet.java View File

@@ -7,6 +7,7 @@
*/ */
package org.apache.ant.modules.core; package org.apache.ant.modules.core;


import java.io.File;
import java.net.URL; import java.net.URL;
import org.apache.myrmidon.api.Task; import org.apache.myrmidon.api.Task;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;
@@ -23,25 +24,29 @@ public class RegisterTasklet
{ {
protected void registerResource( final String name, protected void registerResource( final String name,
final String className, final String className,
final URL url )
final File file )
throws TaskException throws TaskException
{ {
if( null == className ) if( null == className )
{ {
try { getDeployer().deployTask( name, url.toString(), url ); }
try { getDeployer().deployTask( name, file ); }
catch( final DeploymentException de ) catch( final DeploymentException de )
{ {
throw new TaskException( "Failed deploying " + name + " from " + url, de );
throw new TaskException( "Failed deploying " + name + " from " + file, de );
} }
} }
else else
{ {
final DefaultTypeFactory factory = new DefaultTypeFactory( new URL[] { url } );
factory.addNameClassMapping( name, className );
try { getTypeManager().registerType( Task.ROLE, name, factory ); }
try
{
final URL url = file.toURL();
final DefaultTypeFactory factory = new DefaultTypeFactory( new URL[] { url } );
factory.addNameClassMapping( name, className );
getTypeManager().registerType( Task.ROLE, name, factory );
}
catch( final Exception e ) catch( final Exception e )
{ {
throw new TaskException( "Failed registering " + name + " from " + url, e );
throw new TaskException( "Failed registering " + name + " from " + file, e );
} }
} }
} }


+ 2
- 7
proposal/myrmidon/src/java/org/apache/ant/modules/core/RegisterTasklib.java View File

@@ -51,16 +51,11 @@ public class RegisterTasklib


URL url = null; URL url = null;


final File lib = getContext().resolveFile( m_lib );
try { url = lib.toURL(); }
catch( final MalformedURLException mue )
{
throw new TaskException( "Malformed task-lib parameter " + m_lib, mue );
}
final File file = getContext().resolveFile( m_lib );


try try
{ {
m_tskDeployer.deploy( url.toString(), url );
m_tskDeployer.deploy( file );
} }
catch( final DeploymentException de ) catch( final DeploymentException de )
{ {


proposal/myrmidon/src/java/org/apache/myrmidon/components/type/RoleManager.java → proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer/DefaultRoleManager.java View File

@@ -5,7 +5,7 @@
* version 1.1, a copy of which has been included with this distribution in * version 1.1, a copy of which has been included with this distribution in
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.myrmidon.components.type;
package org.apache.myrmidon.components.deployer;


import java.util.HashMap; import java.util.HashMap;


@@ -18,18 +18,22 @@ import java.util.HashMap;
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
* @version CVS $Revision$ $Date$ * @version CVS $Revision$ $Date$
*/ */
public class RoleManager
public class DefaultRoleManager
implements RoleManager
{ {
/** Parent <code>RoleManager</code> for nested resolution */ /** Parent <code>RoleManager</code> for nested resolution */
private final RoleManager m_parent; private final RoleManager m_parent;


/** Map for shorthand to role mapping */
private final HashMap m_shorthands = new HashMap();
/** Map for name to role mapping */
private final HashMap m_names = new HashMap();

/** Map for role to name mapping */
private final HashMap m_roles = new HashMap();


/** /**
* constructor--this RoleManager has no parent. * constructor--this RoleManager has no parent.
*/ */
public RoleManager()
public DefaultRoleManager()
{ {
this( null ); this( null );
} }
@@ -40,7 +44,7 @@ public class RoleManager
* *
* @param parent The parent <code>RoleManager</code>. * @param parent The parent <code>RoleManager</code>.
*/ */
public RoleManager( final RoleManager parent )
public DefaultRoleManager( final RoleManager parent )
{ {
m_parent = parent; m_parent = parent;
} }
@@ -48,32 +52,50 @@ public class RoleManager
/** /**
* Find Role name based on shorthand name. * Find Role name based on shorthand name.
* *
* @param shorthandName the shorthand name
* @param name the shorthand name
* @return the role * @return the role
*/ */
public String getRoleForName( final String shorthandName )
public String getRoleForName( final String name )
{ {
final String role = (String)m_shorthands.get( shorthandName );
final String role = (String)m_names.get( name );


if( null == role && null != m_parent ) if( null == role && null != m_parent )
{ {
return m_parent.getRoleForName( shorthandName );
return m_parent.getRoleForName( name );
} }


return role; return role;
} }


/** /**
* Add a mapping between shorthand name and role
* Find name based on role.
*
* @param role the role
* @return the name
*/
public String getNameForRole( final String role )
{
final String name = (String)m_roles.get( role );

if( null == name && null != m_parent )
{
return m_parent.getNameForRole( name );
}

return name;
}

/**
* Add a mapping between name and role
* *
* @param shorthandName the shorthand name
* @param name the shorthand name
* @param role the role * @param role the role
* @exception IllegalArgumentException if an name is already mapped to a different role * @exception IllegalArgumentException if an name is already mapped to a different role
*/ */
public void addNameRoleMapping( final String shorthandName, final String role )
public void addNameRoleMapping( final String name, final String role )
throws IllegalArgumentException throws IllegalArgumentException
{ {
final String oldRole = (String)m_shorthands.get( shorthandName );
final String oldRole = (String)m_names.get( name );


if( null != oldRole && oldRole.equals( role ) ) if( null != oldRole && oldRole.equals( role ) )
{ {
@@ -81,6 +103,7 @@ public class RoleManager
oldRole + ")" ); oldRole + ")" );
} }


m_shorthands.put( shorthandName, role );
m_names.put( name, role );
m_roles.put( role, name );
} }
} }

+ 41
- 57
proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer/DefaultTskDeployer.java View File

@@ -47,15 +47,7 @@ public class DefaultTskDeployer
private DefaultConfigurationBuilder m_configurationBuilder = new DefaultConfigurationBuilder(); private DefaultConfigurationBuilder m_configurationBuilder = new DefaultConfigurationBuilder();
private ConverterRegistry m_converterRegistry; private ConverterRegistry m_converterRegistry;
private TypeManager m_typeManager; private TypeManager m_typeManager;

/**
* Default constructor.
*/
public DefaultTskDeployer()
{
//m_autoUndeploy = true;
//m_type = "Task";
}
private RoleManager m_roleManager;


/** /**
* Retrieve relevent services needed to deploy. * Retrieve relevent services needed to deploy.
@@ -68,42 +60,29 @@ public class DefaultTskDeployer
{ {
m_converterRegistry = (ConverterRegistry)componentManager.lookup( ConverterRegistry.ROLE ); m_converterRegistry = (ConverterRegistry)componentManager.lookup( ConverterRegistry.ROLE );
m_typeManager = (TypeManager)componentManager.lookup( TypeManager.ROLE ); m_typeManager = (TypeManager)componentManager.lookup( TypeManager.ROLE );
m_roleManager = (RoleManager)componentManager.lookup( RoleManager.ROLE );
} }


public void deploy( final String location, final URL url )
public void deploy( final File file )
throws DeploymentException throws DeploymentException
{ {
//checkDeployment( location, url );
final File file = getFileFor( url );
getLogger().info( "Deploying AntLib file (" + file + ")" );


getLogger().info( "Deploying AntLib file (" + file + ") as " + location );
deployFromFile( location, file );
}
final URL url = getURL( file );


/**
* Deploy a file.
* Eventually this should be cached for performance reasons.
*
* @param location the location
* @param file the file
* @exception DeploymentException if an error occurs
*/
protected void deployFromFile( final String location, final File file )
throws DeploymentException
{
final ZipFile zipFile = getZipFileFor( file ); final ZipFile zipFile = getZipFileFor( file );

URL url = null;

try try
{ {
try { url = file.toURL(); }
catch( final MalformedURLException mue )
{
throw new DeploymentException( "Unable to form url", mue );
}
loadResources( zipFile, location, url );
loadResources( zipFile, url );
} }
catch( final DeploymentException de )
{
throw de;
}
catch( final Exception e )
{
throw new DeploymentException( "Error deploying library", e );
}
finally finally
{ {
try { zipFile.close(); } try { zipFile.close(); }
@@ -111,10 +90,10 @@ public class DefaultTskDeployer
} }
} }


private void loadResources( final ZipFile zipFile, final String location, final URL url )
throws DeploymentException
private void loadResources( final ZipFile zipFile, final URL url )
throws Exception
{ {
final Configuration taskdefs = loadConfiguration( zipFile, TSKDEF_FILE );
final Configuration taskdefs = getDescriptor( zipFile );
final DefaultTypeFactory factory = new DefaultTypeFactory( new URL[] { url } ); final DefaultTypeFactory factory = new DefaultTypeFactory( new URL[] { url } );


try try
@@ -141,18 +120,13 @@ public class DefaultTskDeployer
{ {
throw new DeploymentException( "Malformed taskdefs.xml", ce ); throw new DeploymentException( "Malformed taskdefs.xml", ce );
} }
catch( final Exception e )
{
throw new DeploymentException( "Failed to deploy " + location, e );
}
} }


public void deployConverter( String name, String location, URL url )
public void deployConverter( final String name, final File file )
throws DeploymentException throws DeploymentException
{ {
//checkDeployment( location, url );
final ZipFile zipFile = getZipFileFor( getFileFor( url ) );
final Configuration taskdefs = loadConfiguration( zipFile, TSKDEF_FILE );
final ZipFile zipFile = getZipFileFor( file );
final Configuration taskdefs = getDescriptor( zipFile );


try try
{ {
@@ -161,6 +135,7 @@ public class DefaultTskDeployer
{ {
if( converters[ i ].getAttribute( "classname" ).equals( name ) ) if( converters[ i ].getAttribute( "classname" ).equals( name ) )
{ {
final URL url = getURL( file );
final DefaultTypeFactory factory = new DefaultTypeFactory( new URL[] { url } ); final DefaultTypeFactory factory = new DefaultTypeFactory( new URL[] { url } );
handleConverter( converters[ i ], url, factory ); handleConverter( converters[ i ], url, factory );
break; break;
@@ -177,13 +152,11 @@ public class DefaultTskDeployer
} }
} }


public void deployDataType( final String name, final String location, final URL url )
public void deployDataType( final String name, final File file )
throws DeploymentException throws DeploymentException
{ {
//checkDeployment( location, url );
final ZipFile zipFile = getZipFileFor( getFileFor( url ) );
final Configuration datatypedefs =
loadConfiguration( zipFile, TSKDEF_FILE );
final ZipFile zipFile = getZipFileFor( file );
final Configuration datatypedefs = getDescriptor( zipFile );


try try
{ {
@@ -192,6 +165,7 @@ public class DefaultTskDeployer
{ {
if( datatypes[ i ].getAttribute( "name" ).equals( name ) ) if( datatypes[ i ].getAttribute( "name" ).equals( name ) )
{ {
final URL url = getURL( file );
final DefaultTypeFactory factory = new DefaultTypeFactory( new URL[] { url } ); final DefaultTypeFactory factory = new DefaultTypeFactory( new URL[] { url } );
handleDataType( datatypes[ i ], url, factory ); handleDataType( datatypes[ i ], url, factory );
break; break;
@@ -208,12 +182,11 @@ public class DefaultTskDeployer
} }
} }


public void deployTask( final String name, final String location, final URL url )
public void deployTask( final String name, final File file )
throws DeploymentException throws DeploymentException
{ {
//checkDeployment( location, url );
final ZipFile zipFile = getZipFileFor( getFileFor( url ) );
final Configuration taskdefs = loadConfiguration( zipFile, TSKDEF_FILE );
final ZipFile zipFile = getZipFileFor( file );
final Configuration taskdefs = getDescriptor( zipFile );


try try
{ {
@@ -222,6 +195,7 @@ public class DefaultTskDeployer
{ {
if( tasks[ i ].getAttribute( "name" ).equals( name ) ) if( tasks[ i ].getAttribute( "name" ).equals( name ) )
{ {
final URL url = getURL( file );
final DefaultTypeFactory factory = new DefaultTypeFactory( new URL[] { url } ); final DefaultTypeFactory factory = new DefaultTypeFactory( new URL[] { url } );
handleTask( tasks[ i ], url, factory ); handleTask( tasks[ i ], url, factory );
break; break;
@@ -265,10 +239,10 @@ public class DefaultTskDeployer
* @return the Configuration * @return the Configuration
* @exception DeploymentException if an error occurs * @exception DeploymentException if an error occurs
*/ */
private Configuration loadConfiguration( final ZipFile zipFile, final String filename )
private Configuration getDescriptor( final ZipFile zipFile )
throws DeploymentException throws DeploymentException
{ {
return buildConfiguration( loadResourceStream( zipFile, filename ) );
return buildConfiguration( loadResourceStream( zipFile, TSKDEF_FILE ) );
} }


/** /**
@@ -403,4 +377,14 @@ public class DefaultTskDeployer
ioe ); ioe );
} }
} }

private URL getURL( final File file )
throws DeploymentException
{
try { return file.toURL(); }
catch( final MalformedURLException mue )
{
throw new DeploymentException( "Unable to form url", mue );
}
}
} }

+ 41
- 0
proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer/RoleManager.java View File

@@ -0,0 +1,41 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.myrmidon.components.deployer;

import org.apache.avalon.framework.component.Component;

/**
* Interface to manage roles and mapping to shorthand names.
*
* @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
* @author <a href="mailto:ricardo@apache,org">Ricardo Rocha</a>
* @author <a href="mailto:giacomo@apache,org">Giacomo Pati</a>
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
* @version CVS $Revision$ $Date$
*/
public interface RoleManager
extends Component
{
String ROLE = "org.apache.myrmidon.components.deployer.RoleManager";

/**
* Find Role name based on shorthand name.
*
* @param shorthandName the shorthand name
* @return the role
*/
String getRoleForName( String shorthandName );

/**
* Find name based on role.
*
* @param role the role
* @return the name
*/
String getNameForRole( String role );
}

+ 7
- 8
proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer/TskDeployer.java View File

@@ -7,7 +7,7 @@
*/ */
package org.apache.myrmidon.components.deployer; package org.apache.myrmidon.components.deployer;


import java.net.URL;
import java.io.File;
import org.apache.avalon.framework.component.Component; import org.apache.avalon.framework.component.Component;


/** /**
@@ -21,22 +21,21 @@ public interface TskDeployer
String ROLE = "org.apache.myrmidon.components.deployer.TskDeployer"; String ROLE = "org.apache.myrmidon.components.deployer.TskDeployer";


/** /**
* Deploy a resource indicate by url to location.
* Deploy a library.
* *
* @param location the location to deploy to
* @param url the url of deployment
* @param file the file deployment
* @exception DeploymentException if an error occurs * @exception DeploymentException if an error occurs
*/ */
void deploy( String location, URL url )
void deploy( File file )
throws DeploymentException; throws DeploymentException;


void deployConverter( String name, String location, URL url )
void deployConverter( String name, File file )
throws DeploymentException; throws DeploymentException;


void deployDataType( String name, String location, URL url )
void deployDataType( String name, File file )
throws DeploymentException; throws DeploymentException;


void deployTask( String name, String location, URL url )
void deployTask( String name, File file )
throws DeploymentException; throws DeploymentException;
} }



+ 11
- 2
proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor/MyrmidonEmbeddor.java View File

@@ -24,6 +24,7 @@ import org.apache.myrmidon.api.JavaVersion;
import org.apache.myrmidon.components.builder.ProjectBuilder; import org.apache.myrmidon.components.builder.ProjectBuilder;
import org.apache.myrmidon.components.configurer.Configurer; import org.apache.myrmidon.components.configurer.Configurer;
import org.apache.myrmidon.components.deployer.TskDeployer; import org.apache.myrmidon.components.deployer.TskDeployer;
import org.apache.myrmidon.components.deployer.RoleManager;
import org.apache.myrmidon.components.deployer.DeploymentException; import org.apache.myrmidon.components.deployer.DeploymentException;
import org.apache.myrmidon.components.executor.Executor; import org.apache.myrmidon.components.executor.Executor;
import org.apache.myrmidon.components.manager.ProjectManager; import org.apache.myrmidon.components.manager.ProjectManager;
@@ -42,6 +43,7 @@ public class MyrmidonEmbeddor
private ProjectManager m_projectManager; private ProjectManager m_projectManager;
private ProjectBuilder m_builder; private ProjectBuilder m_builder;
private TskDeployer m_deployer; private TskDeployer m_deployer;
private RoleManager m_roleManager;


private TypeManager m_typeManager; private TypeManager m_typeManager;
private MasterConverter m_converter; private MasterConverter m_converter;
@@ -133,8 +135,8 @@ public class MyrmidonEmbeddor
* @exception Exception if an error occurs * @exception Exception if an error occurs
*/ */
public void dispose() public void dispose()
throws Exception
{ {
m_roleManager = null;
m_converterRegistry = null; m_converterRegistry = null;
m_converter = null; m_converter = null;
m_executor = null; m_executor = null;
@@ -166,6 +168,8 @@ public class MyrmidonEmbeddor
defaults.setParameter( "myrmidon.lib.path", "lib" ); defaults.setParameter( "myrmidon.lib.path", "lib" );


//create all the default properties for components //create all the default properties for components
defaults.setParameter( RoleManager.ROLE,
"org.apache.myrmidon.components.deployer.DefaultRoleManager" );
defaults.setParameter( MasterConverter.ROLE, defaults.setParameter( MasterConverter.ROLE,
"org.apache.myrmidon.components.converter.DefaultMasterConverter" ); "org.apache.myrmidon.components.converter.DefaultMasterConverter" );
defaults.setParameter( ConverterRegistry.ROLE, defaults.setParameter( ConverterRegistry.ROLE,
@@ -202,6 +206,7 @@ public class MyrmidonEmbeddor
componentManager.put( ProjectBuilder.ROLE, m_builder ); componentManager.put( ProjectBuilder.ROLE, m_builder );


//Following components required when Myrmidon allows user deployment of tasks etal. //Following components required when Myrmidon allows user deployment of tasks etal.
componentManager.put( RoleManager.ROLE, m_roleManager );
componentManager.put( TskDeployer.ROLE, m_deployer ); componentManager.put( TskDeployer.ROLE, m_deployer );


//Following components used when want to types (ie tasks/mappers etc) //Following components used when want to types (ie tasks/mappers etc)
@@ -237,6 +242,9 @@ public class MyrmidonEmbeddor
component = getParameter( TypeManager.ROLE ); component = getParameter( TypeManager.ROLE );
m_typeManager = (TypeManager)createComponent( component, TypeManager.class ); m_typeManager = (TypeManager)createComponent( component, TypeManager.class );


component = getParameter( RoleManager.ROLE );
m_roleManager = (RoleManager)createComponent( component, RoleManager.class );

component = getParameter( TskDeployer.ROLE ); component = getParameter( TskDeployer.ROLE );
m_deployer = (TskDeployer)createComponent( component, TskDeployer.class ); m_deployer = (TskDeployer)createComponent( component, TskDeployer.class );


@@ -258,6 +266,7 @@ public class MyrmidonEmbeddor
private void setupComponents() private void setupComponents()
throws Exception throws Exception
{ {
setupComponent( m_roleManager );
setupComponent( m_converterRegistry ); setupComponent( m_converterRegistry );
setupComponent( m_converter ); setupComponent( m_converter );
setupComponent( m_executor ); setupComponent( m_executor );
@@ -452,7 +461,7 @@ public class MyrmidonEmbeddor
try try
{ {
final File file = files[ i ].getCanonicalFile(); final File file = files[ i ].getCanonicalFile();
deployer.deploy( name, file.toURL() );
deployer.deploy( file );
} }
catch( final DeploymentException de ) catch( final DeploymentException de )
{ {


Loading…
Cancel
Save