CVS: jcontainer/loom/plugins/maven-sar/src/java/org/jcontainer/loom/info PhoenixJavaClassFilter.java,NONE,1.1 PhoenixAttributeInterceptor.java,NONE,1.1 GenerateLoomDescriptorsTask.java,NONE,1.1
mauro-yCVjj/[email protected]
| Newsgroups | gmane.comp.java.jcontainer.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/jcontainer/jcontainer/loom/plugins/maven-sar/src/java/org/jcontainer/loom/info
In directory hogshead.codehaus.org:/tmp/cvs-serv13989/loom/plugins/maven-sar/src/java/org/jcontainer/loom/info
Added Files:
PhoenixJavaClassFilter.java PhoenixAttributeInterceptor.java
GenerateLoomDescriptorsTask.java
Log Message:
Folded loom-info code in maven-sar plugin
--- NEW FILE: PhoenixJavaClassFilter.java ---
/*
* Copyright (C) The JContainer Group. All rights reserved.
*
* This software is published under the terms of the JContainer
* Software License version 1.1, a copy of which has been included
* with this distribution in the LICENSE.txt file.
*/
package org.jcontainer.loom.info;
import org.realityforge.metaclass.tools.compiler.JavaClassFilter;
import com.thoughtworks.qdox.model.JavaClass;
import com.thoughtworks.qdox.model.DocletTag;
/**
* Filter that only accepts classes annotated with Phoenix
* metadata. The onyl classes processed are those the JavaDoc tags
* "phoenix:mx-topic" or "phoenix:block" at the class level.
*
* @author <a href="mailto:peter at realityforge.org">Peter Donald</a>
* @version $Revision: 1.1 $ $Date: 2003/11/01 13:15:31 $
*/
public class PhoenixJavaClassFilter
implements JavaClassFilter
{
/**
* @see JavaClassFilter#filterClass(JavaClass)
*/
public JavaClass filterClass( final JavaClass javaClass )
{
final DocletTag dnaTag = javaClass.getTagByName( "dna.component" );
final DocletTag mxTag = javaClass.getTagByName( "mx.component" );
final DocletTag pmxTag = javaClass.getTagByName( "phoenix:mx-topic" );
final DocletTag blockTag = javaClass.getTagByName( "phoenix:block" );
if( null != pmxTag ||
null != mxTag ||
null != dnaTag ||
null != blockTag )
{
return javaClass;
}
else
{
return null;
}
}
}
--- NEW FILE: PhoenixAttributeInterceptor.java ---
/*
* Copyright (C) The JContainer Group. All rights reserved.
*
* This software is published under the terms of the JContainer
* Software License version 1.1, a copy of which has been included
* with this distribution in the LICENSE.txt file.
*/
package org.jcontainer.loom.info;
import com.thoughtworks.qdox.model.DocletTag;
import com.thoughtworks.qdox.model.JavaClass;
import com.thoughtworks.qdox.model.JavaMethod;
import java.util.ArrayList;
import java.util.Properties;
import org.realityforge.metaclass.model.Attribute;
import org.realityforge.metaclass.tools.qdox.DefaultQDoxAttributeInterceptor;
import org.realityforge.metaclass.tools.qdox.QDoxAttributeInterceptor;
/**
* This is an Attribute interceptor that invoked during construction
* of ClassDescriptors that will translate legacy Loom attributes
* into modern DNA and MX attributes.
*
* @author <a href="mailto:peter at realityforge.org">Peter Donald</a>
* @version $Revision: 1.1 $ $Date: 2003/11/01 13:15:31 $
*/
public class PhoenixAttributeInterceptor
extends DefaultQDoxAttributeInterceptor
implements QDoxAttributeInterceptor
{
/**
* @see QDoxAttributeInterceptor#processClassAttribute(JavaClass, Attribute)
*/
public Attribute processClassAttribute( final JavaClass clazz,
final Attribute attribute )
{
final String name = attribute.getName();
if( name.equals( "phoenix:block" ) )
{
return new Attribute( "dna.component" );
}
else if( name.equals( "phoenix:service" ) )
{
final Properties parameters = new Properties();
final String type = attribute.getParameter( "name", null );
setParameter( parameters, "type", type );
return new Attribute( "dna.service", parameters );
}
else if( name.equals( "phoenix:mx-topic" ) )
{
final String description = attribute.getParameter( "name", "" );
final Properties parameters = new Properties();
setParameter( parameters, "description", description );
return new Attribute( "mx.component", parameters );
}
else if( name.equals( "phoenix:mx-proxy" ) )
{
final Properties parameters = new Properties();
final String type = attribute.getParameter( "class", "" );
setParameter( parameters, "type", type );
return new Attribute( "mx.proxy", parameters );
}
else
{
return attribute;
}
}
/**
* @see QDoxAttributeInterceptor#processMethodAttribute(JavaMethod, Attribute)
*/
public Attribute processMethodAttribute( final JavaMethod method,
final Attribute attribute )
{
final String name = attribute.getName();
if( name.equals( "phoenix:configuration-schema" ) )
{
final String type =
attribute.getParameter( "type", null );
final Properties parameters = new Properties();
if( "relax-ng".equals( type ) )
{
setParameter( parameters,
"type",
"http://relaxng.org/ns/structure/1.0" );
}
else
{
setParameter( parameters, "type", type );
}
return new Attribute( "dna.configuration", parameters );
}
else if( name.equals( "phoenix:dependency" ) )
{
final Properties parameters = new Properties();
final String key = attribute.getParameter( "role", null );
final String type = attribute.getParameter( "name", null );
setParameter( parameters, "type", type );
setParameter( parameters, "key", key );
return new Attribute( "dna.dependency", parameters );
}
else if( name.equals( "phoenix:mx-operation" ) )
{
final DocletTag descriptionTag =
method.getTagByName( "phoenix:mx-description" );
final String description;
if( null != descriptionTag )
{
description = descriptionTag.getValue();
}
else
{
description = method.getComment();
}
final Properties parameters = new Properties();
setParameter( parameters, "description", description );
return new Attribute( "mx.operation", parameters );
}
if( name.equals( "phoenix:mx-attribute" ) )
{
final DocletTag descriptionTag =
method.getTagByName( "phoenix:mx-description" );
final String description;
if( null != descriptionTag )
{
description = descriptionTag.getValue();
}
else
{
description = method.getComment();
}
final Properties parameters = new Properties();
setParameter( parameters, "description", description );
return new Attribute( "mx.attribute", parameters );
}
else if( name.equals( "phoenix:mx-description" ) )
{
return null;
}
else
{
return attribute;
}
}
/**
* @see QDoxAttributeInterceptor#processClassAttributes(JavaClass, Attribute[])
*/
public Attribute[] processClassAttributes( final JavaClass clazz,
final Attribute[] attributes )
{
final ArrayList result = new ArrayList();
for( int i = 0; i < attributes.length; i++ )
{
final Attribute attribute = attributes[ i ];
final String name = attribute.getName();
if( !name.equals( "phoenix:mx" ) )
{
result.add( attribute );
}
else
{
final Properties parameters = new Properties();
final String type = attribute.getParameter( "name", "" );
setParameter( parameters, "type", type );
result.add( new Attribute( "dna.service", parameters ) );
final Properties mxParameters = new Properties();
setParameter( mxParameters, "type", type );
final String topic = type.substring( type.lastIndexOf( '.' ) + 1 );
setParameter( mxParameters, "topic", topic );
result.add( new Attribute( "mx.interface", mxParameters ) );
}
}
return (Attribute[])result.toArray( new Attribute[ result.size() ] );
}
/**
* @see QDoxAttributeInterceptor#processMethodAttributes(JavaMethod, Attribute[])
*/
public Attribute[] processMethodAttributes( final JavaMethod method,
final Attribute[] attributes )
{
final ArrayList result = new ArrayList();
boolean isMxOperation = false;
for( int i = 0; i < attributes.length; i++ )
{
final Attribute attribute = attributes[ i ];
if( attribute.getName().equals( "mx.operation" ) )
{
isMxOperation = true;
}
result.add( attribute );
}
if( isMxOperation )
{
for( int i = 0; i < attributes.length; i++ )
{
final Attribute attribute = attributes[ i ];
if( attribute.getName().equals( "param" ) )
{
final String value = attribute.getValue();
final int index = value.indexOf( " " );
if( -1 == index )
{
continue;
}
final String name = value.substring( 0, index ).trim();
final String description = value.substring( index + 1 );
final Properties parameters = new Properties();
setParameter( parameters, "name", name );
setParameter( parameters, "description", description );
result.add( new Attribute( "mx.parameter", parameters ) );
}
}
}
return (Attribute[])result.toArray( new Attribute[ result.size() ] );
}
/**
* Set parameter if value not null.
*
* @param parameters the parameters object
* @param key the key
* @param value the value
*/
private void setParameter( final Properties parameters,
final String key,
final String value )
{
if( null != value )
{
parameters.setProperty( key, value );
}
}
}
--- NEW FILE: GenerateLoomDescriptorsTask.java ---
/*
* Copyright (C) The JContainer Group. All rights reserved.
*
* This software is published under the terms of the JContainer
* Software License version 1.1, a copy of which has been included
* with this distribution in the LICENSE.txt file.
*/
package org.jcontainer.loom.info;
import org.jcontainer.dna.tools.metaclass.DNAAttributeInterceptor;
import org.realityforge.metaclass.tools.tasks.GenerateClassDescriptorsTask;
import org.realityforge.metaclass.tools.tasks.PluginElement;
/**
* Custom Loom Descriptor creation task. This task replaces
* the old Lomm metadata generation task and compiles the
* information into MetaClass descriptors.
*
* @author <a href="mailto:peter at realityforge.org">Peter Donald</a>
* @version $Revision: 1.1 $ $Date: 2003/11/01 13:15:31 $
*/
public class GenerateLoomDescriptorsTask
extends GenerateClassDescriptorsTask
{
/**
* Overide execute to add in custom
* Loom Filters and interceptors.
*/
public void execute()
{
final PluginElement filter = new PluginElement();
filter.setName( PhoenixJavaClassFilter.class.getName() );
addFilter( filter );
final PluginElement phoenixInterceptor = new PluginElement();
phoenixInterceptor.setName( PhoenixAttributeInterceptor.class.getName() );
addInterceptor( phoenixInterceptor );
final PluginElement dnaInterceptor = new PluginElement();
dnaInterceptor.setName( DNAAttributeInterceptor.class.getName() );
addInterceptor( dnaInterceptor );
super.execute();
}
}