From 2ca4d55559f17f4f93b4cf893964e0f7c7567fe3 Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Wed, 7 Feb 2001 05:38:06 +0000 Subject: [PATCH] Moved DataType engine components to tasklet hierarchy as it can not exist independenct of tasklets. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268603 13f79535-47bb-0310-9956-ffa450edef68 --- .../ant/tasklet/engine/DataTypeEngine.java | 43 +++++++++++ .../tasklet/engine/DefaultDataTypeEngine.java | 71 +++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/DataTypeEngine.java create mode 100644 proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/DefaultDataTypeEngine.java diff --git a/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/DataTypeEngine.java b/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/DataTypeEngine.java new file mode 100644 index 000000000..ba880d6c4 --- /dev/null +++ b/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/DataTypeEngine.java @@ -0,0 +1,43 @@ +/* + * 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.DataType; +import org.apache.avalon.Component; +import org.apache.avalon.camelot.FactoryException; +import org.apache.avalon.camelot.LocatorRegistry; +import org.apache.avalon.camelot.RegistryException; + +/** + * This is basically a engine that can be used to access data-types. + * The engine acts as a repository and factory for these types. + * + * @author Peter Donald + */ +public interface DataTypeEngine + extends Component +{ + /** + * Retrieve registry of data-types. + * This is used by deployer to add types into engine. + * + * @return the registry + */ + LocatorRegistry getRegistry(); + + /** + * Create a data-type of type registered under name. + * + * @param name the name of data type + * @return the DataType + * @exception RegistryException if an error occurs + * @exception FactoryException if an error occurs + */ + DataType createDataType( String name ) + throws RegistryException, FactoryException; +} diff --git a/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/DefaultDataTypeEngine.java b/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/DefaultDataTypeEngine.java new file mode 100644 index 000000000..9105e2061 --- /dev/null +++ b/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/DefaultDataTypeEngine.java @@ -0,0 +1,71 @@ +/* + * 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.DataType; +import org.apache.avalon.ComponentManager; +import org.apache.avalon.ComponentManagerException; +import org.apache.avalon.Composer; +import org.apache.avalon.Composer; +import org.apache.avalon.camelot.DefaultLocatorRegistry; +import org.apache.avalon.camelot.Factory; +import org.apache.avalon.camelot.FactoryException; +import org.apache.avalon.camelot.Locator; +import org.apache.avalon.camelot.LocatorRegistry; +import org.apache.avalon.camelot.RegistryException; + +/** + * This is basically a engine that can be used to access data-types. + * The engine acts as a repository and factory for these types. + * + * @author Peter Donald + */ +public class DefaultDataTypeEngine + implements DataTypeEngine, Composer +{ + protected Factory m_factory; + protected LocatorRegistry m_registry = new DefaultLocatorRegistry(); + + /** + * Retrieve registry of data-types. + * This is used by deployer to add types into engine. + * + * @return the registry + */ + public LocatorRegistry getRegistry() + { + return m_registry; + } + + /** + * Retrieve relevent services needed to deploy. + * + * @param componentManager the ComponentManager + * @exception ComponentManagerException if an error occurs + */ + public void compose( final ComponentManager componentManager ) + throws ComponentManagerException + { + m_factory = (Factory)componentManager.lookup( "org.apache.avalon.camelot.Factory" ); + } + + /** + * Create a data-type of type registered under name. + * + * @param name the name of data type + * @return the DataType + * @exception RegistryException if an error occurs + * @exception FactoryException if an error occurs + */ + public DataType createDataType( final String name ) + throws RegistryException, FactoryException + { + final Locator locator = m_registry.getLocator( name ); + return (DataType)m_factory.create( locator, DataType.class ); + } +}