crafterm 2002/10/08 09:30:18
Modified: xfc build.xml
Added: xfc/src/java/org/apache/excalibur/xfc/ant
ModuleDefinition.java XFCTask.java
Log:
Addition of XFC ant task.
Revision Changes Path
1.6 +13 -0 jakarta-avalon-excalibur/xfc/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/xfc/build.xml,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- build.xml 8 Oct 2002 15:02:02 -0000 1.5
+++ build.xml 8 Oct 2002 16:30:18 -0000 1.6
@@ -197,6 +197,19 @@
</batchtest>
</junit>
+ <!-- Test XFC Ant task -->
+ <taskdef name="xfc"
+ classname="org.apache.excalibur.xfc.ant.XFCTask">
+ <classpath refid="test.class.path"/>
+ </taskdef>
+
+ <xfc>
+ <input module="ecm"
+
context="build/testclasses/org/apache/excalibur/xfc/test/ecm.roles:ecm.xconf"/>
+ <output module="fortress"
+
context="build/tests/fortress-ant-generated.roles:fortress-generated.xconf"/>
+ </xfc>
+
</target>
<target name="test-reports" depends="test" description="Generate Reports for
the unit tests">
1.1
jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/ant/ModuleDefinition.java
Index: ModuleDefinition.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) @year@ The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
must not be used to endorse or promote products derived from this software
without prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation. For more information on the
Apache Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.excalibur.xfc.ant;
import org.apache.tools.ant.BuildException;
/**
* Class used to hold information about a module definition in an XFC ANT
* task.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
* @version CVS $Id: ModuleDefinition.java,v 1.1 2002/10/08 16:30:18 crafterm Exp $
*/
public final class ModuleDefinition
{
// internals
String m_module;
String m_context;
/**
* Get the value of m_module.
* @return value of m_module.
*/
public String getModule()
{
return m_module;
}
/**
* Set the value of m_module.
* @param v Value to assign to m_module.
*/
public void setModule(String v)
{
m_module = v;
}
/**
* Get the value of m_context.
* @return value of m_context.
*/
public String getContext()
{
return m_context;
}
/**
* Set the value of m_context.
* @param v Value to assign to m_context.
*/
public void setContext(String v)
{
m_context = v;
}
}
1.1
jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/ant/XFCTask.java
Index: XFCTask.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) @year@ The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
must not be used to endorse or promote products derived from this software
without prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation. For more information on the
Apache Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.excalibur.xfc.ant;
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.avalon.framework.logger.Logger;
import org.apache.excalibur.xfc.Converter;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
/**
* ANT Task based XFC entry point.
*
* <p>
* <pre>
* <xfc>
* <input module="ecm" context="ecm.roles:ecm.xconf"/>
* <output module="fortress" context="fortress.roles:fortress.xconf"/>
* </xfc>
* </pre>
* </p>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
* @version CVS $Id: XFCTask.java,v 1.1 2002/10/08 16:30:18 crafterm Exp $
*/
public final class XFCTask extends Task
{
private Logger m_logger = new ConsoleLogger( ConsoleLogger.LEVEL_WARN );
private ModuleDefinition m_input;
private ModuleDefinition m_output;
/**
* Method to set the input {@link ModuleDefinition} object.
*
* @param input a {@link ModuleDefinition} instance
*/
public void addConfiguredInput( final ModuleDefinition input )
{
m_input = input;
}
/**
* Method to set the output {@link ModuleDefinition} object
*
* @param output a {@link ModuleDefinition} instance
*/
public void addConfiguredOutput( final ModuleDefinition output )
{
m_output = output;
}
/**
* Executes the task, converts input format to output format
*
* @exception BuildException if an error occurs
*/
public void execute()
throws BuildException
{
validate();
try
{
// create converter
final Converter cv = new Converter( getLogger() );
// set up input and output modules
cv.setInputModule( getClass( m_input.getModule() ) );
cv.setInputModuleContext( m_input.getContext() );
cv.setOutputModule( getClass( m_output.getModule() ) );
cv.setOutputModuleContext( m_output.getContext() );
// convert
cv.convert();
// all done, good show
}
catch ( Exception e )
{
throw new BuildException(
"Error occured during XFC task conversion", e
);
}
}
/**
* Method to validate that the input and output module definition
* objects have been set and are valid.
*
* @exception BuildException if definitions are invalid
*/
private void validate()
throws BuildException
{
// check the input task
if ( m_input == null ||
m_input.getModule() == null ||
m_input.getContext() == null
)
{
throw new BuildException( "XFC input task missing input criteria" );
}
// check the output task
if ( m_output == null ||
m_output.getModule() == null ||
m_output.getContext() == null
)
{
throw new BuildException( "XFC output task missing output criteria" );
}
}
/**
* Obtain the {@link Class} object for the plugin module
* specified. This method makes a simple check with some pre-defined
* plugin's and returns their {@link Class} objects if specified.
*
* <p>
* If the specified plugin is not known, it's assumed to be a
* fully qualified class name of a custom plugin, and is loaded manually.
* </p>
*
* @param clazz class name as a <code>String</code> object
* @return a <code>Class</code> instance
* @exception ClassNotFoundException if an error occurs
*/
private Class getClass( final String clazz )
throws ClassNotFoundException
{
if ( "ecm".equalsIgnoreCase( clazz ) )
{
return Class.forName( "org.apache.excalibur.xfc.modules.ECM" );
}
if ( "fortress".equalsIgnoreCase( clazz ) )
{
return Class.forName( "org.apache.excalibur.xfc.modules.Fortress" );
}
if ( "merlin".equalsIgnoreCase( clazz ) )
{
return Class.forName( "org.apache.excalibur.xfc.modules.Merlin" );
}
// assume custom module
return Class.forName( clazz );
}
private Logger getLogger()
{
return m_logger;
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>