git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268320 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -1,37 +0,0 @@ | |||||
| /* | |||||
| * 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.ant.convert; | |||||
| import org.apache.ant.convert.Converter; | |||||
| import org.apache.avalon.camelot.AbstractEntry; | |||||
| /** | |||||
| * An entry representing an instance of Converter. | |||||
| * See Cameloy documentation for more details. | |||||
| * | |||||
| * @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||||
| */ | |||||
| public class ConverterEntry | |||||
| extends AbstractEntry | |||||
| { | |||||
| public ConverterEntry( final ConverterInfo info, final Converter converter ) | |||||
| { | |||||
| super( info, converter ); | |||||
| } | |||||
| /** | |||||
| * Retrieve instance of converter. | |||||
| * | |||||
| * @return the component instance | |||||
| */ | |||||
| public Converter getConverter() | |||||
| { | |||||
| return (Converter)getInstance(); | |||||
| } | |||||
| } | |||||
| @@ -25,6 +25,6 @@ public interface ConverterFactory | |||||
| * @return the entry | * @return the entry | ||||
| * @exception FactoryException if an error occurs | * @exception FactoryException if an error occurs | ||||
| */ | */ | ||||
| ConverterEntry create( ConverterInfo info ) | |||||
| Converter createConverter( ConverterInfo info ) | |||||
| throws FactoryException; | throws FactoryException; | ||||
| } | } | ||||
| @@ -65,8 +65,7 @@ public class DefaultConverterEngine | |||||
| " conversion" ); | " conversion" ); | ||||
| } | } | ||||
| final ConverterEntry entry = m_converterFactory.create( info ); | |||||
| final Converter converter = entry.getConverter(); | |||||
| final Converter converter = m_converterFactory.createConverter( info ); | |||||
| return converter.convert( destination, original ); | return converter.convert( destination, original ); | ||||
| } | } | ||||
| } | } | ||||
| @@ -34,7 +34,7 @@ public class DefaultConverterFactory | |||||
| * @return the created entry | * @return the created entry | ||||
| * @exception FactoryException if an error occurs | * @exception FactoryException if an error occurs | ||||
| */ | */ | ||||
| public Entry create( final Info info ) | |||||
| public Object create( final Info info ) | |||||
| throws FactoryException | throws FactoryException | ||||
| { | { | ||||
| if( info.getClass().equals( ConverterInfo.class ) ) | if( info.getClass().equals( ConverterInfo.class ) ) | ||||
| @@ -51,27 +51,23 @@ public class DefaultConverterFactory | |||||
| * @return the created entry | * @return the created entry | ||||
| * @exception FactoryException if an error occurs | * @exception FactoryException if an error occurs | ||||
| */ | */ | ||||
| public ConverterEntry create( final ConverterInfo info ) | |||||
| public Converter createConverter( final ConverterInfo info ) | |||||
| throws FactoryException | throws FactoryException | ||||
| { | { | ||||
| final ConverterLoader loader = getLoader( info.getLocation() ); | final ConverterLoader loader = getLoader( info.getLocation() ); | ||||
| Object object = null; | |||||
| try { object = loader.load( info.getClassname() ); } | |||||
| try { return (Converter)loader.load( info.getClassname() ); } | |||||
| catch( final Exception e ) | catch( final Exception e ) | ||||
| { | { | ||||
| throw new FactoryException( "Failed loading converter from " + info.getLocation() + | throw new FactoryException( "Failed loading converter from " + info.getLocation() + | ||||
| " due to " + e, e ); | " due to " + e, e ); | ||||
| } | } | ||||
| return new ConverterEntry( info, (Converter)object ); | |||||
| } | } | ||||
| /** | /** | ||||
| * Get a loader for a particular location | * Get a loader for a particular location | ||||
| * | * | ||||
| * @param locationthe location | |||||
| * @param location the location | |||||
| * @return the loader | * @return the loader | ||||
| */ | */ | ||||
| protected ConverterLoader getLoader( final URL location ) | protected ConverterLoader getLoader( final URL location ) | ||||
| @@ -244,9 +244,7 @@ public class DefaultTaskletEngine | |||||
| throw new AntException( "Unable to locate task " + name, re ); | throw new AntException( "Unable to locate task " + name, re ); | ||||
| } | } | ||||
| TaskletEntry entry = null; | |||||
| try { entry = m_taskletFactory.create( info ); } | |||||
| try { return m_taskletFactory.createTasklet( info ); } | |||||
| catch( final FactoryException fe ) | catch( final FactoryException fe ) | ||||
| { | { | ||||
| throw new AntException( "Unable to create task " + name + | throw new AntException( "Unable to create task " + name + | ||||
| @@ -254,7 +252,5 @@ public class DefaultTaskletEngine | |||||
| info.getLocation() + ")", | info.getLocation() + ")", | ||||
| fe ); | fe ); | ||||
| } | } | ||||
| return entry.getTasklet(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -27,7 +27,7 @@ public class DefaultTaskletFactory | |||||
| extends DefaultConverterFactory | extends DefaultConverterFactory | ||||
| implements TaskletFactory | implements TaskletFactory | ||||
| { | { | ||||
| public Entry create( final Info info ) | |||||
| public Object create( final Info info ) | |||||
| throws FactoryException | throws FactoryException | ||||
| { | { | ||||
| if( !info.getClass().equals( TaskletInfo.class ) ) | if( !info.getClass().equals( TaskletInfo.class ) ) | ||||
| @@ -36,25 +36,23 @@ public class DefaultTaskletFactory | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| return create( (TaskletInfo)info ); | |||||
| return createTasklet( (TaskletInfo)info ); | |||||
| } | } | ||||
| } | } | ||||
| public TaskletEntry create( final TaskletInfo info ) | |||||
| public Tasklet createTasklet( final TaskletInfo info ) | |||||
| throws FactoryException | throws FactoryException | ||||
| { | { | ||||
| final TaskletLoader loader = (TaskletLoader)getLoader( info.getLocation() ); | final TaskletLoader loader = (TaskletLoader)getLoader( info.getLocation() ); | ||||
| Object object = null; | Object object = null; | ||||
| try { object = loader.load( info.getClassname() ); } | |||||
| try { return (Tasklet)loader.load( info.getClassname() ); } | |||||
| catch( final Exception e ) | catch( final Exception e ) | ||||
| { | { | ||||
| throw new FactoryException( "Failed loading tasklet from " + info.getLocation() + | throw new FactoryException( "Failed loading tasklet from " + info.getLocation() + | ||||
| " due to " + e, e ); | " due to " + e, e ); | ||||
| } | } | ||||
| return new TaskletEntry( info, (Tasklet)object ); | |||||
| } | } | ||||
| protected ConverterLoader createLoader( final URL location ) | protected ConverterLoader createLoader( final URL location ) | ||||
| @@ -1,31 +0,0 @@ | |||||
| /* | |||||
| * 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.ant.tasklet.engine; | |||||
| import org.apache.ant.tasklet.Tasklet; | |||||
| import org.apache.avalon.camelot.AbstractEntry; | |||||
| public class TaskletEntry | |||||
| extends AbstractEntry | |||||
| { | |||||
| public TaskletEntry( final TaskletInfo info, final Tasklet tasklet ) | |||||
| { | |||||
| super( info, tasklet ); | |||||
| } | |||||
| /** | |||||
| * Retrieve instance of tasklet. | |||||
| * | |||||
| * @return the component instance | |||||
| */ | |||||
| public Tasklet getTasklet() | |||||
| { | |||||
| return (Tasklet)getInstance(); | |||||
| } | |||||
| } | |||||
| @@ -9,6 +9,7 @@ package org.apache.ant.tasklet.engine; | |||||
| import org.apache.avalon.camelot.Factory; | import org.apache.avalon.camelot.Factory; | ||||
| import org.apache.avalon.camelot.FactoryException; | import org.apache.avalon.camelot.FactoryException; | ||||
| import org.apache.ant.tasklet.Tasklet; | |||||
| /** | /** | ||||
| * Facility used to load Tasklets. | * Facility used to load Tasklets. | ||||
| @@ -18,6 +19,6 @@ import org.apache.avalon.camelot.FactoryException; | |||||
| public interface TaskletFactory | public interface TaskletFactory | ||||
| extends Factory | extends Factory | ||||
| { | { | ||||
| TaskletEntry create( TaskletInfo info ) | |||||
| Tasklet createTasklet( TaskletInfo info ) | |||||
| throws FactoryException; | throws FactoryException; | ||||
| } | } | ||||