You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by bl...@apache.org on 2003/05/23 18:52:53 UTC
cvs commit: avalon-excalibur/sourceresolve/src/fortress.meta services.list
bloritsch 2003/05/23 09:52:53
Modified: fortress/src/tools/org/apache/avalon/fortress/tools
ComponentMetaInfoCollector.java
Added: sourceresolve/src/fortress.meta/org/apache/excalibur/source/impl
URLSourceFactory.meta FileSourceFactory.meta
ResourceSourceFactory.meta SourceResolverImpl.deps
SourceResolverImpl.meta
sourceresolve/src/fortress.meta services.list
Log:
Add default meta files as part of hack, and perform some refactoring on the ComponentMetaInfoCollector to ensure I get the proper info
Revision Changes Path
1.1 avalon-excalibur/sourceresolve/src/fortress.meta/org/apache/excalibur/source/impl/URLSourceFactory.meta
Index: URLSourceFactory.meta
===================================================================
#Meta information for org.apache.excalibur.source.impl.URLSourceFactory
#Fri May 23 12:28:13 EDT 2003
x-avalon.lifestyle=singleton
x-avalon.name=url-source
1.1 avalon-excalibur/sourceresolve/src/fortress.meta/org/apache/excalibur/source/impl/FileSourceFactory.meta
Index: FileSourceFactory.meta
===================================================================
#Meta information for org.apache.excalibur.source.impl.FileSourceFactory
#Fri May 23 12:28:13 EDT 2003
x-avalon.lifestyle=singleton
x-avalon.name=file-source
1.1 avalon-excalibur/sourceresolve/src/fortress.meta/org/apache/excalibur/source/impl/ResourceSourceFactory.meta
Index: ResourceSourceFactory.meta
===================================================================
#Meta information for org.apache.excalibur.source.impl.ResourceSourceFactory
#Fri May 23 12:28:13 EDT 2003
x-avalon.lifestyle=singleton
x-avalon.name=resource-source
1.1 avalon-excalibur/sourceresolve/src/fortress.meta/org/apache/excalibur/source/impl/SourceResolverImpl.deps
Index: SourceResolverImpl.deps
===================================================================
org.apache.excalibur.source.SourceFactory
1.1 avalon-excalibur/sourceresolve/src/fortress.meta/org/apache/excalibur/source/impl/SourceResolverImpl.meta
Index: SourceResolverImpl.meta
===================================================================
#Meta information for org.apache.excalibur.source.impl.SourceResolverImpl
#Fri May 23 12:28:13 EDT 2003
x-avalon.lifestyle=singleton
x-avalon.name=resolver
1.19 +52 -21 avalon-excalibur/fortress/src/tools/org/apache/avalon/fortress/tools/ComponentMetaInfoCollector.java
Index: ComponentMetaInfoCollector.java
===================================================================
RCS file: /home/cvs/avalon-excalibur/fortress/src/tools/org/apache/avalon/fortress/tools/ComponentMetaInfoCollector.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- ComponentMetaInfoCollector.java 22 May 2003 12:48:14 -0000 1.18
+++ ComponentMetaInfoCollector.java 23 May 2003 16:52:53 -0000 1.19
@@ -98,6 +98,20 @@
* The service list destination.
*/
private File m_serviceFile;
+ private static final String POOLABLE = "org.apache.avalon.excalibur.pool.Poolable";
+ private static final String RECYCLABLE = "org.apache.avalon.excalibur.pool.Recyclable";
+ private static final String SERVICE_MANAGER = "org.apache.avalon.framework.service.ServiceManager";
+ private static final String TAG_DEPENDENCY = "avalon.dependency";
+ private static final String ATTR_TYPE = "type";
+ private static final String ATTR_NAME = "name";
+ private static final String TAG_LIFESTYLE = "x-avalon.lifestyle";
+ private static final String TAG_HANDLER = "fortress.handler";
+ private static final String TAG_INFO = "x-avalon.info";
+ private static final String TAG_NAME = "fortress.name";
+ private static final String TAG_COMPONENT = "avalon.component";
+ private static final String TAG_SERVICE = "avalon.service";
+ private static final String META_NAME = "x-avalon.name";
+ private static final String METH_SERVICE = "service";
/**
* Set the destination directory for the meta information.
@@ -225,22 +239,22 @@
while ( it.hasNext() )
{
final JavaClass javaClass = (JavaClass) it.next();
- final DocletTag tag = javaClass.getTagByName( "avalon.component" );
+ final DocletTag tag = javaClass.getTagByName( TAG_COMPONENT );
if ( null != tag )
{
final Component comp = new Component( javaClass.getFullyQualifiedName() );
- final DocletTag[] tags = javaClass.getTagsByName( "avalon.service" );
+ final DocletTag[] tags = javaClass.getTagsByName( TAG_SERVICE );
for ( int t = 0; t < tags.length; t++ )
{
- final String serviceName = resolveClassName( javaClass, tags[t].getNamedParameter( "type" ) );
+ final String serviceName = resolveClassName( javaClass, tags[t].getNamedParameter( ATTR_TYPE ) );
final Service service = getService( serviceName );
service.addComponent( comp );
}
- final DocletTag avalonLifecycle = javaClass.getTagByName( "x-avalon.lifestyle" );
- final DocletTag fortressHandler = javaClass.getTagByName( "fortress.handler" );
+ final DocletTag avalonLifecycle = javaClass.getTagByName( TAG_LIFESTYLE );
+ final DocletTag fortressHandler = javaClass.getTagByName( TAG_HANDLER );
String lifecycle = null;
String handler = null;
@@ -253,8 +267,8 @@
{
handler = ThreadSafeComponentHandler.class.getName();
}
- else if ( interfaces[i].getClass().getName().equals( "org.apache.avalon.excalibur.pool.Poolable" ) ||
- interfaces[i].getClass().getName().equals( "org.apache.avalon.excalibur.pool.Recyclable" ) )
+ else if ( interfaces[i].getClass().getName().equals( POOLABLE ) ||
+ interfaces[i].getClass().getName().equals( RECYCLABLE ) )
{
handler = PoolableComponentHandler.class.getName();
}
@@ -267,35 +281,37 @@
if ( null != avalonLifecycle )
{
- lifecycle = avalonLifecycle.getNamedParameter( "type" );
+ lifecycle = stripQuotes(avalonLifecycle.getNamedParameter( ATTR_TYPE ));
}
else if ( handler != null )
{
- handler = ( null == fortressHandler ) ? PerThreadComponentHandler.class.getName() : fortressHandler.getNamedParameter( "type" );
+ handler = ( null == fortressHandler ) ? PerThreadComponentHandler.class.getName() : stripQuotes(fortressHandler.getNamedParameter( ATTR_TYPE ));
}
- if ( null != lifecycle ) comp.setAttribute( "x-avalon.lifestyle", lifecycle );
- if ( null != handler ) comp.setAttribute( "fortress.handler", handler );
+ if ( null != lifecycle ) comp.setAttribute( TAG_LIFESTYLE, lifecycle );
+ if ( null != handler ) comp.setAttribute( TAG_HANDLER, handler );
- DocletTag avalonConfigName = javaClass.getTagByName( "x-avalon.info" );
- if ( null == avalonConfigName ) avalonConfigName = javaClass.getTagByName( "fortress.name" );
-
- comp.setAttribute( "x-avalon.name", ( avalonConfigName == null ) ? MetaInfoEntry.createShortName( javaClass.getName() ) : avalonConfigName.getNamedParameter( "name" ) );
+ DocletTag avalonConfigName = javaClass.getTagByName( TAG_INFO );
+ if ( null == avalonConfigName ) avalonConfigName = javaClass.getTagByName( TAG_NAME );
+ comp.setAttribute( META_NAME, ( avalonConfigName == null ) ? MetaInfoEntry.createShortName( javaClass.getName() ) : avalonConfigName.getNamedParameter( ATTR_NAME ) );
JavaMethod[] methods = javaClass.getMethods();
for (int i = 0; i < methods.length; i++)
{
- if (methods[i].getName().equals("service"))
+ if (methods[i].getName().equals(METH_SERVICE))
{
- if (methods[i].getParameters().length == 1 && methods[i].getParameters()[0].getType().getValue().equals("ServiceManager"))
+ System.out.println(methods[i].getParameters()[0].getType().getValue());
+ if (methods[i].getParameters().length == 1 && methods[i].getParameters()[0].getType().getValue().equals(SERVICE_MANAGER))
{
- DocletTag[] dependencies = methods[i].getTagsByName("avalon.dependency");
+ DocletTag[] dependencies = methods[i].getTagsByName(TAG_DEPENDENCY);
for(int d = 0; d < dependencies.length; d++)
{
- String type = dependencies[d].getNamedParameter("type");
+ String type = stripQuotes(dependencies[d].getNamedParameter(ATTR_TYPE));
//String optional = dependencies[d].getNamedParameter("optional");
+ System.out.println(type);
+
Service service = getService(type);
comp.addDependency(service);
}
@@ -306,6 +322,21 @@
}
}
+ private String stripQuotes(final String value)
+ {
+ if ( null == value ) return null;
+ if ( value.length() < 2 ) return value;
+
+ String retVal = value.trim();
+
+ if ( retVal.startsWith("\"") && retVal.endsWith("\"") )
+ {
+ retVal = retVal.substring(1, retVal.length() - 1);
+ }
+
+ return retVal;
+ }
+
/**
* Resolve the classname from the "@avalon.service" javadoc tags.
*
@@ -318,7 +349,7 @@
if ( null == javaClass ) throw new NullPointerException( "javaClass" );
if ( null == serviceName ) throw new BuildException( "(" + javaClass.getFullyQualifiedName() + ") You must specify the service name with the \"type\" parameter" );
- String className = serviceName.trim();
+ String className = stripQuotes(serviceName);
if ( className != null || className.length() > 0 )
{
if ( className.indexOf( '.' ) < 0 )
1.1 avalon-excalibur/sourceresolve/src/fortress.meta/services.list
Index: services.list
===================================================================
"org.apache.excalibur.source.SourceFactory"
org.apache.excalibur.source.SourceResolver
org.apache.excalibur.source.SourceFactory
---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org