leosutic 2003/08/10 06:46:09
Added: attributes/compiler/src/java/org/apache/avalon/attributes/compiler
AttributeCompiler.java
attributes/api/src/test/org/apache/avalon/attributes/test
AttributeDemo.java Dependency.java Sample.java
Sample2.java SampleService.java SuperSample.java
ThreadSafe.java
attributes/api/src/java/org/apache/avalon/attributes
AttributeRepositoryClass.java Attributes.java
CachedRepository.java DefaultCachedRepository.java
EmptyCachedRepository.java Inheritable.java
Util.java
attributes/site/xdocs index.xml navigation.xml
attributes/site maven.xml project.properties project.xml
attributes/api project.xml
attributes/compiler project.xml
attributes/site/etc site.jsl stylesheet.css
Log:
Initial commit.
Revision Changes Path
1.1
avalon-sandbox/attributes/compiler/src/java/org/apache/avalon/attributes/compiler/AttributeCompiler.java
Index: AttributeCompiler.java
===================================================================
package org.apache.avalon.attributes.compiler;
import java.io.*;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.types.FileSet;
import xjavadoc.*;
import xjavadoc.ant.*;
import java.util.*;
/**
* Ant task to compile attributes.
*/
public class AttributeCompiler extends XJavadocTask {
private final ArrayList fileSets = new ArrayList ();
private File destDir;
public AttributeCompiler () {
}
public void addFileset (FileSet set) {
super.addFileset (set);
fileSets.add (set);
}
public void setDestdir (File destDir) {
this.destDir = destDir;
}
protected void copyImports (File source, PrintWriter dest) throws Exception {
BufferedReader br = new BufferedReader (new FileReader (source));
try {
String line = null;
while ((line = br.readLine ()) != null) {
if (line.startsWith ("import ")) {
dest.println (line);
}
}
} finally {
br.close ();
}
}
protected void addExpressions (Collection tags, PrintWriter pw, String
collectionName, String fileName) {
Iterator iter = tags.iterator ();
while (iter.hasNext ()) {
XTag tag = (XTag) iter.next ();
String expression = tag.getName () + " " + tag.getValue ();
if (Character.isUpperCase (expression.charAt (0))) {
pw.println (" " + collectionName + ".add (\n" +
"new " + expression + " // " + fileName + ":" +
tag.getLineNumber () + "\n" +
");");
}
}
}
protected boolean elementHasAttributes (Collection xElements) {
Iterator iter = xElements.iterator ();
while (iter.hasNext ()) {
XProgramElement element = (XProgramElement) iter.next ();
if (tagHasAttributes (element.getDoc ().getTags ())) {
return true;
}
}
return false;
}
protected String getParameterTypes (Collection parameters) {
StringBuffer sb = new StringBuffer ();
for (Iterator params = parameters.iterator (); params.hasNext ();) {
XParameter parameter = (XParameter) params.next ();
sb.append (parameter.getType ().getQualifiedName ());
sb.append (parameter.getDimensionAsString ());
if (params.hasNext ()) {
sb.append (",");
}
}
return sb.toString ();
}
protected void generateClass (XClass xClass) throws Exception {
if (!hasAttributes (xClass)) {
return;
}
String name = xClass.getQualifiedName ();
File sourceFile = getSourceFile (name);
File destFile = new File (destDir, name.replace ('.', '/') +
"$Attributes.java");
if (destFile.exists () && destFile.lastModified () >=
sourceFile.lastModified ()) {
return;
}
String packageName = xClass.getContainingPackage().getName ();
String className = xClass.getName ();
destFile.getParentFile ().mkdirs ();
PrintWriter pw = new PrintWriter (new FileWriter (destFile));
if (packageName != null && !packageName.equals ("")) {
pw.println ("package " + packageName + ";");
}
copyImports (sourceFile, pw);
pw.println ("public class " + className + "$Attributes implements
org.apache.avalon.attributes.AttributeRepositoryClass {");
{
pw.println (" private static final java.util.Set classAttributes =
new java.util.HashSet ();");
pw.println (" private static final java.util.Map fieldAttributes =
new java.util.HashMap ();");
pw.println (" private static final java.util.Map methodAttributes =
new java.util.HashMap ();");
pw.println (" private static final java.util.Map
constructorAttributes = new java.util.HashMap ();");
pw.println ();
pw.println (" static {");
pw.println (" initClassAttributes ();");
pw.println (" initMethodAttributes ();");
pw.println (" initFieldAttributes ();");
pw.println (" initConstructorAttributes ();");
pw.println (" }");
pw.println ();
pw.println (" public java.util.Set getClassAttributes () { return
classAttributes; }");
pw.println (" public java.util.Map getFieldAttributes () { return
fieldAttributes; }");
pw.println (" public java.util.Map getConstructorAttributes () {
return constructorAttributes; }");
pw.println (" public java.util.Map getMethodAttributes () { return
methodAttributes; }");
pw.println ();
pw.println (" private static void initClassAttributes () {");
addExpressions (xClass.getDoc ().getTags (), pw, "classAttributes",
sourceFile.getPath ());
pw.println (" }");
pw.println ();
// ---- Field Attributes
pw.println (" private static void initFieldAttributes () {");
pw.println (" java.util.Set attrs = null;");
for (Iterator iter = xClass.getFields ().iterator (); iter.hasNext ();) {
XField member = (XField) iter.next ();
String key = member.getName ();
pw.println (" attrs = new java.util.HashSet ();");
addExpressions (member.getDoc ().getTags (), pw, "attrs",
sourceFile.getPath ());
pw.println (" fieldAttributes.put (\"" + key + "\", attrs);");
pw.println (" attrs = null;");
pw.println ();
}
pw.println (" }");
// ---- Method Attributes
pw.println (" private static void initMethodAttributes () {");
pw.println (" java.util.Set attrs = null;");
for (Iterator iter = xClass.getMethods ().iterator (); iter.hasNext ();)
{
XMethod member = (XMethod) iter.next ();
StringBuffer sb = new StringBuffer ();
sb.append (member.getName ()).append ("(");
sb.append (getParameterTypes (member.getParameters ()));
sb.append (")");
String key = sb.toString ();
pw.println (" attrs = new java.util.HashSet ();");
addExpressions (member.getDoc ().getTags (), pw, "attrs",
sourceFile.getPath ());
pw.println (" methodAttributes.put (\"" + key + "\",
attrs);");
pw.println (" attrs = null;");
pw.println ();
}
pw.println (" }");
// ---- Constructor Attributes
pw.println (" private static void initConstructorAttributes () {");
pw.println (" java.util.Set attrs = null;");
for (Iterator iter = xClass.getConstructors ().iterator (); iter.hasNext
();) {
XConstructor member = (XConstructor) iter.next ();
StringBuffer sb = new StringBuffer ();
sb.append ("(");
sb.append (getParameterTypes (member.getParameters ()));
sb.append (")");
String key = sb.toString ();
pw.println (" attrs = new java.util.HashSet ();");
addExpressions (member.getDoc ().getTags (), pw, "attrs",
sourceFile.getPath ());
pw.println (" constructorAttributes.put (\"" + key + "\",
attrs);");
pw.println (" attrs = null;");
pw.println ();
}
pw.println (" }");
}
pw.println ("}");
pw.close ();
}
protected File getSourceFile (String qualifiedName) throws BuildException {
String path = qualifiedName.replace ('.', '/') + ".java";
Iterator iter = fileSets.iterator ();
while (iter.hasNext ()) {
FileSet fs = (FileSet) iter.next ();
File maybe = new File (fs.getDir (project), path);
if (maybe.exists ()) {
return maybe;
}
}
throw new BuildException ("Could not find source file for " + qualifiedName);
}
protected boolean hasAttributes (XClass xClass) {
if (tagHasAttributes (xClass.getDoc ().getTags ()) ||
elementHasAttributes (xClass.getFields ()) ||
elementHasAttributes (xClass.getMethods ()) ||
elementHasAttributes (xClass.getConstructors ()) ) {
return true;
}
return false;
}
protected boolean isAttribute (XTag tag) {
return Character.isUpperCase (tag.getName ().charAt (0));
}
protected void start() throws BuildException {
destDir.mkdirs ();
XJavaDoc doc = getXJavaDoc ();
Iterator iter = doc.getSourceClasses ().iterator ();
try {
while (iter.hasNext ()) {
XClass xClass = (XClass) iter.next ();
if (!xClass.isInner ()) {
generateClass (xClass);
}
}
} catch (Exception e) {
throw new BuildException (e.toString (), e);
}
}
protected boolean tagHasAttributes (Collection tags) {
Iterator iter = tags.iterator ();
while (iter.hasNext ()) {
XTag tag = (XTag) iter.next ();
if (isAttribute (tag)) {
return true;
}
}
return false;
}
}
1.1
avalon-sandbox/attributes/api/src/test/org/apache/avalon/attributes/test/AttributeDemo.java
Index: AttributeDemo.java
===================================================================
package org.apache.avalon.attributes.test;
import org.apache.avalon.attributes.Attributes;
public class AttributeDemo {
public static void main (String[] args) throws Exception {
Class sample = Class.forName ("org.apache.avalon.attributes.test.Sample");
System.out.println ("Getting attributes for class Sample...");
System.out.println ("Sample has the following class attributes:\n" +
Attributes.getAttributes (sample));
System.out.println ("Getting attributes for the method
Sample.someMethod(int)...");
System.out.println ("Sample.someMethod(int) has the following class
attributes:\n" + Attributes.getAttributes (sample.getMethod ("someMethod", new
Class[]{ Integer.TYPE })));
}
}
1.1
avalon-sandbox/attributes/api/src/test/org/apache/avalon/attributes/test/Dependency.java
Index: Dependency.java
===================================================================
package org.apache.avalon.attributes.test;
import org.apache.avalon.attributes.Inheritable;
/**
* Declares a dependency.
*
* @Inheritable ()
*/
public class Dependency {
private final Class clazz;
private final String name;
public Dependency (Class clazz, String name) {
this.clazz = clazz;
this.name = name;
}
public Class getDependencyClass () {
return clazz;
}
public String getDependencyName () {
return name;
}
public String toString () {
return "[Dependency on " + clazz.getName () + " via name \"" + name + "\"]";
}
}
1.1
avalon-sandbox/attributes/api/src/test/org/apache/avalon/attributes/test/Sample.java
Index: Sample.java
===================================================================
package org.apache.avalon.attributes.test;
/**
* @ThreadSafe ()
* @Dependency ( SampleService.class, "sample" )
*/
public class Sample extends SuperSample {
/**
* @ThreadSafe ()
*/
public Object aaaa;
/**
* @Dependency ( SampleService.class, "sample-ctor1" )
*/
public Sample () {
}
/**
* @Dependency ( SampleService.class, "sample-ctor2" )
*/
public Sample (String input, String[][] array) {
}
/**
* @Dependency ( SampleService.class, "sample-some-method1" )
*/
public void someMethod () {
}
/**
* @Dependency ( SampleService.class, "sample-some-method2" )
*/
public void someMethod (int parameter) {
}
}
1.1
avalon-sandbox/attributes/api/src/test/org/apache/avalon/attributes/test/Sample2.java
Index: Sample2.java
===================================================================
package org.apache.avalon.attributes.test;
public class Sample2 {
public Object aaaa;
public Sample2 () {
}
public Sample2 (String input) {
}
public void someMethod () {
}
public void someMethod (int parameter) {
}
}
1.1
avalon-sandbox/attributes/api/src/test/org/apache/avalon/attributes/test/SampleService.java
Index: SampleService.java
===================================================================
package org.apache.avalon.attributes.test;
public interface SampleService {}
1.1
avalon-sandbox/attributes/api/src/test/org/apache/avalon/attributes/test/SuperSample.java
Index: SuperSample.java
===================================================================
package org.apache.avalon.attributes.test;
/**
* @Dependency ( SampleService.class, "super-sample" )
*/
public class SuperSample {
/**
* @Dependency ( SampleService.class, "super-some-method-sample" )
* @ThreadSafe ()
*/
public void someMethod (int parameter) {
}
}
1.1
avalon-sandbox/attributes/api/src/test/org/apache/avalon/attributes/test/ThreadSafe.java
Index: ThreadSafe.java
===================================================================
package org.apache.avalon.attributes.test;
public class ThreadSafe {
public ThreadSafe () {
}
public String toString () {
return "[ThreadSafe]";
}
}
1.1
avalon-sandbox/attributes/api/src/java/org/apache/avalon/attributes/AttributeRepositoryClass.java
Index: AttributeRepositoryClass.java
===================================================================
package org.apache.avalon.attributes;
import java.util.Set;
import java.util.Map;
/**
* Interface implemented by all attribute repository classes.
* This interface is used internally and should not be used
* by clients. The only reason it is public is because the
* classes implementing it may be in any package.
*/
public interface AttributeRepositoryClass {
public Set getClassAttributes ();
public Map getFieldAttributes ();
public Map getMethodAttributes ();
public Map getConstructorAttributes ();
}
1.1
avalon-sandbox/attributes/api/src/java/org/apache/avalon/attributes/Attributes.java
Index: Attributes.java
===================================================================
package org.apache.avalon.attributes;
import java.lang.reflect.Field;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.*;
/**
* API for accessing attributes.
*/
public class Attributes {
private final static HashMap classRepositories = new HashMap ();
protected synchronized static CachedRepository getCachedRepository (Class clazz)
throws Exception {
if (classRepositories.containsKey (clazz)) {
return (CachedRepository) classRepositories.get (clazz);
} else {
Class attributeRepo;
CachedRepository cached;
try {
attributeRepo = Class.forName (clazz.getName () + "$Attributes",
true, clazz.getClassLoader ());
AttributeRepositoryClass repo = (AttributeRepositoryClass)
attributeRepo.newInstance ();
cached = new DefaultCachedRepository (clazz, repo);
} catch (ClassNotFoundException cnfe) {
cached = CachedRepository.EMPTY;
}
classRepositories.put (clazz, cached); // Should be keyed on ClassLoader
as well.
return cached;
}
}
/**
* Gets all attributes for a class.
*/
public static Collection getAttributes (Class clazz) throws Exception {
return getCachedRepository (clazz).getAttributes ();
}
/**
* Gets all attributes for a method.
*/
public static Collection getAttributes (Method method) throws Exception {
return getCachedRepository (method.getDeclaringClass()).getAttributes
(method);
}
/**
* Gets all attributes for a field.
*/
public static Collection getAttributes (Field field) throws Exception {
return getCachedRepository (field.getDeclaringClass()).getAttributes (field);
}
/**
* Gets all attributes for a constructor.
*/
public static Collection getAttributes (Constructor cons) throws Exception {
return getCachedRepository (cons.getDeclaringClass()).getAttributes (cons);
}
/**
* Selects from a collection of attributes only those with a given class.
*/
private static Collection getAttributes (Collection attrs, Class attributeClass)
throws Exception {
HashSet result = new HashSet ();
Iterator iter = attrs.iterator ();
while (iter.hasNext ()) {
Object attr = iter.next ();
if (attr.getClass () == attributeClass) {
result.add (attr);
}
}
return result;
}
/**
* Get all attributes of a given type from a class.
*/
public static Collection getAttributes (Class clazz, Class attributeClass)
throws Exception {
return getAttributes (getAttributes (clazz), attributeClass);
}
/**
* Get all attributes of a given type from a field.
*/
public static Collection getAttributes (Field field, Class attributeClass)
throws Exception {
return getAttributes (getAttributes (field), attributeClass);
}
/**
* Get all attributes of a given type from a constructor.
*/
public static Collection getAttributes (Constructor ctor, Class attributeClass)
throws Exception {
return getAttributes (getAttributes (ctor), attributeClass);
}
/**
* Get all attributes of a given type from a method.
*/
public static Collection getAttributes (Method method, Class attributeClass)
throws Exception {
return getAttributes (getAttributes (method), attributeClass);
}
/**
* Convenience function to test whether a collection of attributes contain
* an attribute of a given class.
*/
private static boolean hasAttribute (Collection attrs, Class attributeClass)
throws Exception {
Iterator iter = attrs.iterator ();
while (iter.hasNext ()) {
Object attr = iter.next ();
if (attr.getClass () == attributeClass) {
return true;
}
}
return false;
}
/**
* Tests if a class has an attribute of a given type.
*/
public static boolean hasAttribute (Class clazz, Class attributeClass) throws
Exception {
return hasAttribute (getAttributes (clazz), attributeClass);
}
/**
* Tests if a class has an attribute of a given type.
*/
public static boolean hasAttribute (Field field, Class attributeClass) throws
Exception {
return hasAttribute (getAttributes (field), attributeClass);
}
/**
* Tests if a class has an attribute of a given type.
*/
public static boolean hasAttribute (Constructor ctor, Class attributeClass)
throws Exception {
return hasAttribute (getAttributes (ctor), attributeClass);
}
/**
* Tests if a class has an attribute of a given type.
*/
public static boolean hasAttribute (Method method, Class attributeClass) throws
Exception {
return hasAttribute (getAttributes (method), attributeClass);
}
}
1.1
avalon-sandbox/attributes/api/src/java/org/apache/avalon/attributes/CachedRepository.java
Index: CachedRepository.java
===================================================================
package org.apache.avalon.attributes;
import java.lang.reflect.Field;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.*;
interface CachedRepository {
public static final CachedRepository EMPTY = new EmptyCachedRepository ();
public Collection getAttributes () throws Exception;
public Collection getAttributes (Field f) throws Exception;
public Collection getAttributes (Method m) throws Exception;
public Collection getAttributes (Constructor c) throws Exception;
}
1.1
avalon-sandbox/attributes/api/src/java/org/apache/avalon/attributes/DefaultCachedRepository.java
Index: DefaultCachedRepository.java
===================================================================
package org.apache.avalon.attributes;
import java.lang.reflect.Field;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.*;
class DefaultCachedRepository implements CachedRepository {
private final Set classAttributes = new HashSet ();
private final Map fields = new HashMap ();
private final Map methods = new HashMap ();
private final Map constructors = new HashMap ();
public DefaultCachedRepository (Class clazz, AttributeRepositoryClass repo)
throws Exception {
// ---- Fix up class attributes
this.classAttributes.addAll (repo.getClassAttributes ());
Class c = clazz.getSuperclass ();
while (c != null) {
this.classAttributes.addAll (getInheritableAttributes
(Attributes.getAttributes (c)));
c = c.getSuperclass ();
}
// ---- Fix up method attributes
Method[] methods = clazz.getDeclaredMethods ();
for (int i = 0; i < methods.length; i++) {
Method m = methods[i];
String key = Util.getSignature (m);
Set attributes = new HashSet ();
attributes.addAll ((Collection) repo.getMethodAttributes ().get (key));
c = clazz.getSuperclass ();
while (c != null) {
try {
// Get equivalent method in superclass
Method m2 = c.getMethod (m.getName (), m.getParameterTypes ());
if (m2.getDeclaringClass () == c) {
attributes.addAll (getInheritableAttributes
(Attributes.getAttributes (m2)));
}
} catch (NoSuchMethodException nsme) {
}
c = c.getSuperclass ();
}
this.methods.put (m, attributes);
}
}
private static Collection getInheritableAttributes (Collection attrs) throws
Exception {
HashSet result = new HashSet ();
Iterator iter = attrs.iterator ();
while (iter.hasNext ()) {
Object attr = iter.next ();
if (Attributes.hasAttribute (attr.getClass (), Inheritable.class)) {
result.add (attr);
}
}
return result;
}
public Collection getAttributes () throws Exception {
return classAttributes;
}
public Collection getAttributes (Field f) throws Exception {
return (Collection) fields.get (f);
}
public Collection getAttributes (Method m) throws Exception {
return (Collection) methods.get (m);
}
public Collection getAttributes (Constructor c) throws Exception {
return (Collection) constructors.get (c);
}
}
1.1
avalon-sandbox/attributes/api/src/java/org/apache/avalon/attributes/EmptyCachedRepository.java
Index: EmptyCachedRepository.java
===================================================================
package org.apache.avalon.attributes;
import java.lang.reflect.Field;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.*;
class EmptyCachedRepository implements CachedRepository {
private final static Collection EMPTY_COLLECTION = new ArrayList (0);
public Collection getAttributes () throws Exception {
return EMPTY_COLLECTION;
}
public Collection getAttributes (Field f) throws Exception {
return EMPTY_COLLECTION;
}
public Collection getAttributes (Method m) throws Exception {
return EMPTY_COLLECTION;
}
public Collection getAttributes (Constructor c) throws Exception {
return EMPTY_COLLECTION;
}
}
1.1
avalon-sandbox/attributes/api/src/java/org/apache/avalon/attributes/Inheritable.java
Index: Inheritable.java
===================================================================
package org.apache.avalon.attributes;
/**
* This attribute is used to mark attributes as being inheritable.
* Inheritable attributes are inherited down the class and interface
* hierarchy. See Dependency for an example of an inheritable attribute.
*/
public class Inheritable {
}
1.1
avalon-sandbox/attributes/api/src/java/org/apache/avalon/attributes/Util.java
Index: Util.java
===================================================================
package org.apache.avalon.attributes;
import java.lang.reflect.Field;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
class Util {
public static String getSignature (Method m) throws Exception {
return m.getName () + "(" + getParameterList (m.getParameterTypes ()) + ")";
}
public static String getSignature (Constructor c) throws Exception {
return "(" + getParameterList (c.getParameterTypes ()) + ")";
}
public static String decodedClassName (String rawName) throws Exception {
if (!rawName.startsWith ("[")) {
return rawName;
} else {
StringBuffer nesting = new StringBuffer ();
int i = 0;
while (rawName.charAt (i) == '[') {
nesting.append ("[]");
i++;
}
String type = "";
switch (rawName.charAt (i)) {
case 'B': type = "byte"; break;
case 'C': type = "char"; break;
case 'D': type = "double"; break;
case 'F': type = "float"; break;
case 'I': type = "int"; break;
case 'J': type = "long"; break;
case 'L': type = rawName.substring (i + 1, rawName.length () - 1); break;
case 'S': type = "short"; break;
case 'Z': type = "boolean"; break;
default: throw new IllegalArgumentException ("Can't decode " + rawName);
}
return type + nesting.toString ();
}
}
public static String getParameterList (Class[] params) throws Exception {
StringBuffer sb = new StringBuffer ();
for (int i = 0; i < params.length; i++) {
if (i > 0) {
sb.append (",");
}
sb.append (decodedClassName (params[i].getName ()));
}
return sb.toString ();
}
}
1.1 avalon-sandbox/attributes/site/xdocs/index.xml
Index: index.xml
===================================================================
<?xml version="1.0"?>
<document>
<properties>
<author email="[EMAIL PROTECTED]">Leo Sutic</author>
<title>Avalon Attribute Compiler</title>
</properties>
<body>
<section name="Avalon Attribute Compiler">
<p>
The Avalon Attribute Compiler (attrc) is a proof-of-concept
demo to show how attributes can be implemented in a simple way.
</p>
<subsection name="The Demo">
<p>
Since I'm not very good with Maven, part of the demo was done
with Ant.
Compile the package first by running maven. Then run the demo
with ant.
</p>
</subsection>
</section>
</body>
</document>
1.1 avalon-sandbox/attributes/site/xdocs/navigation.xml
Index: navigation.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<project>
<title>Avalon Sandbox</title>
<body>
<links>
<item name="Home" href="http://avalon.apache.org/"/>
<item name="Framework" href="http://avalon.apache.org/framework/"/>
<item name="Components" href="http://avalon.apache.org/components"/>
<item name="Containers" href="http://avalon.apache.org/containers/"/>
<item name="Sandbox" href="http://avalon.apache.org/sandbox/"/>
</links>
<menu name="About Avalon Attributes">
<item name="Overview" href="/index.html"/>
</menu>
</body>
</project>
1.1 avalon-sandbox/attributes/site/maven.xml
Index: maven.xml
===================================================================
<project default="site" xmlns:maven="jelly:maven" xmlns:j="jelly:core"
xmlns:util="jelly:util">
<property file="${basedir}/build.properties"/>
<property file="${basedir}/project.properties"/>
<property name="maven.license.licenseFile"
value="${basedir}/../LICENSE.txt"/>
<property name="maven.javadoc.stylesheet"
value="${basedir}/etc/stylesheet.css"/>
<preGoal name="site">
<attainGoal name="license"/>
</preGoal>
</project>
1.1 avalon-sandbox/attributes/site/project.properties
Index: project.properties
===================================================================
#
# Banner background and foreground colors.
#
maven.ui.banner.background = #fff
maven.ui.banner.foreground = #000
maven.xdoc.jsl = file:/${basedir}/etc/site.jsl
maven.javadoc.stylesheet =${basedir}/etc/stylesheet.css
#
# Declaration of the remote links to assign on javadoc generation.
# Link declarations can be overriden in the user's build.properties
# file.
#
sun.j2se.link = http://java.sun.com/j2se/1.4/docs/api/
avalon.framework.link = http://avalon.apache.org/framework/api/
maven.javadoc.links = ${sun.j2se.link},${avalon.framework.link}
1.1 avalon-sandbox/attributes/site/project.xml
Index: project.xml
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<project>
<extend>${basedir}/../project.xml</extend>
<package>org.apache.avalon.meta</package>
<dependencies>
<!-- avalon dependecies -->
<dependency>
<id>ant</id>
<version>1.5</version>
</dependency>
<dependency>
<id>qdox</id>
<version>1.1</version>
</dependency>
<!-- pre JDK 1.4 dependencies -->
<dependency>
<id>xml-apis</id>
<version>1.0.b2</version>
<url>http://xml.apache.org/xerces2-j/</url>
</dependency>
<dependency>
<id>xerces</id>
<version>2.2.1</version>
<url>http://xml.apache.org/xerces2-j/</url>
</dependency>
</dependencies>
<packageGroups>
</packageGroups>
<reports>
<report>maven-changelog-plugin</report>
<report>maven-file-activity-plugin</report>
<report>maven-developer-activity-plugin</report>
</reports>
</project>
1.1 avalon-sandbox/attributes/api/project.xml
Index: project.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<project>
<extend>${basedir}/../project.xml</extend>
<id>avalon-attributes-api</id>
<name>Avalon Attribute Compiler API</name>
<package>org.apache.avalon.attributes</package>
<currentVersion>0.1</currentVersion>
<inceptionYear>2003</inceptionYear>
<shortDescription>Proof-of-concept client API for Attributes in
Java.</shortDescription>
<description>
A precompiler for java that enables the use of attributes as seen in C#.
</description>
<dependencies>
</dependencies>
<packageGroups>
<packageGroup>
<title>Application Program Interface (API)</title>
<packages>org.apache.avalon.attributes</packages>
</packageGroup>
</packageGroups>
</project>
1.1 avalon-sandbox/attributes/compiler/project.xml
Index: project.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<project>
<extend>${basedir}/../project.xml</extend>
<id>avalon-attributes-compiler</id>
<name>Avalon Attribute Compiler Ant Task</name>
<package>org.apache.avalon.attributes.compiler</package>
<currentVersion>0.1</currentVersion>
<inceptionYear>2003</inceptionYear>
<shortDescription>Attribute Compiler</shortDescription>
<description>
An Ant task that will precompile Java source.
</description>
<dependencies>
<dependency>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<id>xdoclet+xjavadoc</id>
<version>1.0</version>
</dependency>
</dependencies>
<packageGroups>
<packageGroup>
<title>Compiler</title>
<packages>org.apache.avalon.attributes.compiler</packages>
</packageGroup>
</packageGroups>
</project>
1.1 avalon-sandbox/attributes/site/etc/site.jsl
Index: site.jsl
===================================================================
<?xml version="1.0"?>
<!-- stylesheet to be used -->
<jsl:stylesheet select="$doc"
xmlns:define="jelly:define"
xmlns:j="jelly:core"
xmlns:jsl="jelly:jsl"
xmlns:log="jelly:log"
xmlns:util="jelly:util"
xmlns:x="jelly:xml"
xmlns:doc="doc"
xmlns="dummy" trim="false">
<jsl:template match="document" trim="false">
<x:doctype name="html"
publicId="-//CollabNet//DTD XHTML 1.0 Transitional//EN"
systemId="http://www.collabnet.com/dtds/collabnet_transitional_10.dtd"/>
<html>
<head>
<j:set var="docTitle">
<x:expr select="./properties/title"/>
</j:set>
<x:if select="$nav/title">
<title>
<x:expr select="$nav/title"/> - ${docTitle}
</title>
</x:if>
<x:if select="not($nav/title)">
<title>${pom.name} - ${docTitle}</title>
</x:if>
<j:set var="tigrisCss" value='"${relativePath}/style/tigris.css"'/>
<j:set var="mavenCss" value='"${relativePath}/style/maven.css"'/>
<j:set var="osmCss" value='"${relativePath}/style/osm.css"'/>
<style type="text/css"><![CDATA[
@import url(${tigrisCss});
@import url(${mavenCss});
@import url(${osmCss});
]]></style>
<!-- FIXME: once someone works out how to stop this breaking
<x:element name="script"><x:attribute
name="type">text/javascript</x:attribute>
if (document.layers) {
document.writeln(''+
'<link rel="stylesheet" type="text/css"
href="${relativePath}/style/ns4_only.css" media="screen" /><link rel="stylesheet"
type="text/css" href="${relativePath}/style/maven_ns4_only.css" media="screen"/>');
}
</x:element>
-->
<link rel="stylesheet" type="text/css"
href="${relativePath}/style/print.css" media="print"/>
<x:forEach var="author" select="./properties/author">
<meta name="author" value="${author.text}"/>
<meta name="email" value="${author.attribute('email').value}"/>
</x:forEach>
</head>
<body class="composite" marginwidth="0" marginheight="0">
<div id="banner">
<table border="0" cellspacing="0" cellpadding="8" width="100%"
height="103">
<tr>
<!-- organization logo -->
<td>
<j:set var="logo" value="${pom.organization.logo}"/>
<j:if test="${!empty(logo)}">
<!-- set url to org or project url -->
<j:set var="url" value="${pom.organization.url}"/>
<j:if test="${!empty(url)}">
<j:set var="home" value="${pom.organization.url}"/>
</j:if>
<j:if test="${empty(url)}">
<j:set var="home" value="${pom.url}"/>
</j:if>
<!-- set image to relative or complete -->
<j:set var="image" value="${pom.organization.logo}"/>
<j:if test="${!image.startsWith('http://')}">
<j:set var="image" value="${relativePath}${image}"/>
</j:if>
<a href="${home}">
<img src="${image}" align="left" alt="${pom.organization.name}"
border="0"/>
</a>
</j:if>
</td>
<!-- project logo and link -->
<td>
<div align="right" id="login">
<j:set var="logo" value="${pom.logo}"/>
<j:if test="${logo != null and logo != ''}">
<!-- set image to relative or complete -->
<j:set var="image" value="${pom.logo}"/>
<j:if test="${!image.startsWith('http://')}">
<j:set var="image" value="${relativePath}${image}"/>
</j:if>
<a href="${pom.url}">
<img src="${image}" align="right" alt="${pom.name}"
border="0"/>
</a>
</j:if>
</div>
</td>
</tr>
</table>
</div>
<div id="breadcrumbs">
<table border="0" cellspacing="0" cellpadding="4" width="100%">
<tr>
<j:if test="${date == 'left'}">
<j:set var="version" value="${maven.xdoc.version}"/>
<td>Last published: ${build.date}
<j:if test="${!empty(version)}">| Doc for ${version}</j:if>
</td>
</j:if>
<td>
<div align="right">
<j:if test="${date == 'right'}">
Last published: ${build.date}
<x:if select="$nav/body/links">|</x:if>
</j:if>
<!-- render links -->
<x:if select="$nav/body/links">
<jsl:applyTemplates select="$nav/body/links"/>
</x:if>
<x:if select="not($nav/body/links)">
<!-- FIXME -->
</x:if>
</div>
</td>
</tr>
</table>
</div>
<!-- Body of the page -->
<table border="0" cellspacing="0" cellpadding="8" width="100%">
<!--id="main" -->
<tr valign="top">
<td id="leftcol" width="200">
<div id="navcolumn">
<j:if test="${context.findVariable('maven.xdoc.date') ==
'navigation-top'}">
<div>
<small>Last published: ${buildDate}</small>
</div>
</j:if>
<x:if select="$nav">
<jsl:applyTemplates select="$nav/body/menu"/>
</x:if>
<!-- Standard Maven Navigation -->
<j:set var="fileName">${file}</j:set>
<!--
! Check to see if the user wishes to include the
! maven-generated docs on their site.
!-->
<j:if test="${includeProjectDocumentation.equals('yes')}">
<div>
<strong>Project Documentation</strong>
<!--
<div>
<small>
<a href="${relativePath}/index.html">Front Page</a>
</small>
</div>
-->
<div>
<small>
<a href="${relativePath}/project-info.html">Project Info</a>
</small>
<util:tokenize var="projectInfoFiles"
delim=",">${maven.xdoc.projectInfo}</util:tokenize>
<j:forEach var="infoFile" items="${projectInfoFiles}">
<j:if test="${relativePath == '.' and
fileName.endsWith(infoFile)}">
<div>
<small>
<a href="${relativePath}/mail-lists.html">Mailing
Lists</a>
</small>
</div>
<div>
<small>
<a href="${relativePath}/team-list.html">Project Team</a>
</small>
</div>
<div>
<small>
<a
href="${relativePath}/dependencies.html">Dependencies</a>
</small>
</div>
<j:if test="${!empty(pom.repository.url)}">
<div>
<small>
<a href="${relativePath}/cvs-usage.html">Source
Repository</a>
</small>
</div>
</j:if>
<j:if test="${!empty(pom.issueTrackingUrl)}">
<div>
<small>
<a href="${relativePath}/issue-tracking.html">Issue
Tracking</a>
</small>
</div>
</j:if>
</j:if>
</j:forEach>
</div>
<div>
<small>
<a href="${relativePath}/maven-reports.html">Project
Reports</a>
</small>
<j:choose>
<j:when test="${!pom.reports.isEmpty()}">
<!--
| Check to see if we need to include the report
| links in this document. The only time we
| need to do this is when the current document
| either the maven-reports.xml doc (the page
| is displayed when clicking on Project
| Reports) or when the current document is one
| of the actual reports (in which case we want
| to leave the project report links expanded.
|-->
<j:set var="includeReportLinks" value="false"/>
<j:forEach var="report" items="${reports}">
<j:set var="linkWithXmlExt" value="${report.link}.xml"/>
<j:if test="${relativePath == '.' and
(fileName.endsWith('maven-reports.xml') or fileName.endsWith(linkWithXmlExt))}">
<j:set var="includeReportLinks" value="true"/>
</j:if>
</j:forEach>
<!--
| If we need to include the report links, then
| do so. This is determined by the above
| block.
|-->
<j:if test="${includeReportLinks == 'true'}">
<j:forEach var="report" items="${reports}">
<div>
<small>
<a href="${relativePath}/${report.link}.html">
${report.name}
</a>
</small>
</div>
</j:forEach>
</j:if>
</j:when>
<j:otherwise>
<!-- The old static method -->
<util:tokenize var="projectReportFiles"
delim=",">${maven.xdoc.projectReports}</util:tokenize>
<j:forEach var="reportFile" items="${projectReportFiles}">
<j:if test="${relativePath == '.' and
fileName.endsWith(reportFile.trim())}">
<util:available file="${maven.docs.src}/tasks.xml">
<div>
<small>
<a href="${relativePath}/tasks.html">Tasks</a>
</small>
</div>
</util:available>
<util:available file="${maven.gen.docs}/task-list.xml">
<div>
<small>
<a href="${relativePath}/task-list.html">Task
List</a>
</small>
</div>
</util:available>
<util:available file="${maven.docs.src}/changes.xml">
<div>
<small>
<a href="${relativePath}/changes.html">Changes</a>
</small>
</div>
</util:available>
<j:if test="${!empty(pom.repository.connection)}">
<div>
<small>
<a
href="${relativePath}/changelog-report.html">Change Log</a>
</small>
</div>
<div>
<small>
<a
href="${relativePath}/developer-activity-report.html">Developer Activity</a>
</small>
</div>
<div>
<small>
<a
href="${relativePath}/file-activity-report.html">File Activity</a>
</small>
</div>
</j:if>
<j:if test="${unitTestSourcesPresent}">
<div>
<small>
<a href="${relativePath}/junit-report.html">Unit
Tests</a>
</small>
</div>
</j:if>
<j:if test="${sourcesPresent}">
<div>
<small>
<a
href="${relativePath}/jdepend-report.html">Metric Results</a>
</small>
</div>
<div>
<small>
<a
href="${relativePath}/checkstyle-report.html">Checkstyle Report</a>
</small>
</div>
<div>
<small>
<a href="${relativePath}/javadoc.html">Javadoc
Report</a>
</small>
</div>
</j:if>
<util:available file="${maven.docs.dest}/clover">
<div>
<small>
<a href="${relativePath}/clover/index.html">Clover
Test Coverage</a>
</small>
</div>
</util:available>
<util:available
file="${maven.gen.docs}/cactus-report.xml">
<div>
<small>
<a
href="${relativePath}/cactus-report.html">Cactus Tests</a>
</small>
</div>
</util:available>
</j:if>
</j:forEach>
</j:otherwise>
</j:choose>
</div>
<j:if test="${pom.reports.isEmpty()}">
<j:if test="${sourcesPresent}">
<div>
<small>
<a href="${relativePath}/apidocs/index.html">JavaDocs</a>
</small>
</div>
<div>
<small>
<a href="${relativePath}/xref/index.html">Source
XReference</a>
</small>
</div>
<j:if test="${unitTestSourcesPresent == 'true'}">
<div>
<small>
<a href="${relativePath}/xref-test/index.html">Test
XReference</a>
</small>
</div>
</j:if>
</j:if>
</j:if>
<!--
<j:set var="devProcess" value="false"/>
<util:available file="${maven.docs.src}/development-process.xml">
<j:set var="devProcess" value="true"/>
</util:available>
<j:if test="${devProcess}">
<div>
<small>
<a
href="${relativePath}/development-process.html">Development Process</a>
</small>
</div>
</j:if>
<j:if test="${!devProcess}">
<div>
<small>
<j:set
var="devProcess">${maven.xdoc.developmentProcessUrl}</j:set>
<a href="${devProcess}">Development Process</a>
</small>
</div>
</j:if>
-->
<div>
<small>
<a href="${relativePath}/license.html">License</a>
</small>
</div>
</div>
</j:if>
<j:if test="${context.findVariable('maven.xdoc.date') ==
'navigation-bottom'}">
<div>
<small>Last published: ${build.date}</small>
</div>
</j:if>
</div>
</td>
<td>
<div id="bodycol">
<!-- Insert MAIN body here -->
<div class="app">
<!-- FIXME really shouldn't use $doc, but jelly loses it's context
again -->
<jsl:applyTemplates select="$doc/document/body/section"/>
<jsl:applyTemplates select="$doc/document/body/glossary" />
<jsl:applyTemplates select="$doc/document/body/release" />
<jsl:applyTemplates select="$doc/document/body/changelog" />
<jsl:applyTemplates select="$doc/document/body/taskList" />
<jsl:applyTemplates select="$doc/document/body/goals" />
</div>
</div>
</td>
</tr>
</table>
<div id="footer">
<table border="0" cellspacing="0" cellpadding="4">
<tr>
<td>
<j:if test="${!empty(pom.organization.name)}">
<j:if test="${!empty(pom.inceptionYear)}">
<j:if test="${pom.inceptionYear == mavenCurrentYear}">
<!-- FIXME © -->${mavenCurrentYear},
${pom.organization.name}
</j:if>
<j:if test="${pom.inceptionYear != mavenCurrentYear}">
<!-- FIXME © -->
${pom.inceptionYear}-${mavenCurrentYear}, ${pom.organization.name}
</j:if>
</j:if>
<j:if test="${empty(pom.inceptionYear)}">
<!-- FIXME © --> ${mavenCurrentYear},
${pom.organization.name}
</j:if>
</j:if>
<j:if test="${context.findVariable('maven.xdoc.date') == 'bottom'}">
- Last published: ${build.date}
</j:if>
</td>
<j:if test="${context.findVariable('maven.xdoc.date') ==
'bottom-right'}">
<td align="right">Last published: ${build.date}</td>
</j:if>
</tr>
</table>
</div>
</body>
</html>
</jsl:template>
<!-- process the properties of the doc -->
<jsl:template match="properties" trim="false">
<!-- stick head block here later -->
</jsl:template>
<!-- Process a menu for the navigation bar -->
<jsl:template match="menu" trim="false">
<div>
<strong><x:expr select="@name"/></strong>
<jsl:applyTemplates select="item"/>
</div>
</jsl:template>
<jsl:template match="item" trim="false">
<div>
<j:set var="_name"><x:expr select="@name"/></j:set>
<j:set var="_link"><x:expr select="@href"/></j:set>
<small><doc:itemLink name="${_name}" link="${_link}"/></small>
<jsl:applyTemplates select="item"/>
</div>
</jsl:template>
<!-- Process the breadcrumb navbar -->
<jsl:template match="links" trim="false">
<j:set var="linkCount" value="1"/>
<x:forEach var="link" select="item">
<j:if test="${linkCount != 1}">|</j:if>
<j:set var="_name">
<x:expr select="@name"/>
</j:set>
<j:set var="_link">
<x:expr select="@href"/>
</j:set>
<doc:itemLink name="${_name}" link="${_link}"/>
<j:set var="linkCount" value="${1+linkCount}"/>
</x:forEach>
</jsl:template>
<!-- process a documentation section -->
<jsl:template match="section" trim="false">
<div class="h3">
<j:set var="_sectionName"><x:expr select="@name"/></j:set>
<j:if test="${!empty(_sectionName)}">
<h3>
<a name="${_sectionName}">${_sectionName}</a>
</h3>
</j:if>
<jsl:applyTemplates select="*"/>
</div>
</jsl:template>
<jsl:template match="subsection" trim="false">
<div class="h4">
<j:set var="_sectionName"><x:expr select="@name"/></j:set>
<j:if test="${!empty(_sectionName)}">
<h4>
<a name="${_sectionName}">${_sectionName}</a>
</h4>
</j:if>
<jsl:applyTemplates select="*"/>
</div>
</jsl:template>
<jsl:template match="source" trim="false">
<div id="source">
<pre><x:expr select="."/></pre>
</div>
</jsl:template>
<jsl:template match="table" trim="false">
<j:set var="rowcount" value="0"/>
<table cellpadding="3" cellspacing="2" border="1" width="100%">
<jsl:applyTemplates select="*"/>
</table>
</jsl:template>
<jsl:template match="tr" trim="false">
<j:choose>
<j:when test="${rowMode == 'a'}">
<j:set var="rowMode" value="b"/>
</j:when>
<j:otherwise>
<j:set var="rowMode" value="a"/>
</j:otherwise>
</j:choose>
<!-- copy attributes FIXME: Shouldn't this only be colspan|rowspan? -->
<x:element name="tr"><j:whitespace trim="true">
<x:attribute name="class">${rowMode}</x:attribute>
<x:forEach var="attr" select="@*">
<x:attribute name="${attr.name}">${attr.value}</x:attribute>
</x:forEach>
<jsl:applyTemplates select="*"/>
</j:whitespace></x:element>
</jsl:template>
<!--************************-->
<!-- glossary documentation -->
<!--************************-->
<jsl:template match="glossary" trim="false">
<jsl:applyTemplates select="glossary-entries/glossary-entry" />
</jsl:template>
<jsl:template match="glossary-entry" trim="false">
<strong><x:expr select="name" /></strong>
<br/>
<x:expr select="definition" />
<p/>
</jsl:template>
<!--************************-->
<!-- goals documentation -->
<!--************************-->
<jsl:template match="goals" trim="false">
<!-- reset row alternation -->
<j:set var="rowMode" value="" />
<div class="h3">
<h3><a name="Goals">Goals</a></h3>
<table>
<tr width='100%'><th>Goal</th><th>Description</th></tr>
<jsl:applyTemplates select="goal"/>
</table>
</div>
</jsl:template>
<!-- a goal -->
<!-- FIXME: this is copied from tr - there must be a way of
calling templates in jsl? -->
<jsl:template match="goal" trim="false">
<j:choose>
<j:when test="${rowMode == 'a'}">
<j:set var="rowMode" value="b"/>
</j:when>
<j:otherwise>
<j:set var="rowMode" value="a"/>
</j:otherwise>
</j:choose>
<x:element name="tr"><j:whitespace trim="true">
<x:attribute name="class">${rowMode}</x:attribute>
<j:set var="_goalName"><x:expr select="./name" /></j:set>
<td width='200'><a name="${_goalName}">${_goalName}</a></td>
<td><jsl:applyTemplates select="description" /></td>
</j:whitespace></x:element>
</jsl:template>
<jsl:template match="description">
<x:expr select="."/>
</jsl:template>
<!--************************-->
<!-- changelog documentation-->
<!--************************-->
<jsl:template match="changelog" trim="false">
<j:set var="rowMode" value="" />
<table width="100%">
<tr>
<th>Date</th><th>Author</th><th>Files/Message</th>
</tr>
<jsl:applyTemplates select="changelog-entry" />
</table>
</jsl:template>
<!-- transform a changelog entry -->
<!-- FIXME: tr code copied from above -->
<jsl:template match="changelog-entry" trim="false">
<j:choose>
<j:when test="${rowMode == 'a'}">
<j:set var="rowMode" value="b"/>
</j:when>
<j:otherwise>
<j:set var="rowMode" value="a"/>
</j:otherwise>
</j:choose>
<x:element name="tr"><j:whitespace trim="true">
<x:attribute name="class">${rowMode}</x:attribute>
<td><x:expr select="date" /> <x:expr select="time" /></td>
<td><x:expr select="author"/></td>
<td><jsl:applyTemplates select="*" />
<pre><x:expr select="msg"/></pre>
</td>
</j:whitespace></x:element>
</jsl:template>
<jsl:template match="file">
<j:set var="url">${pom.repository.url}<x:expr select="name"/></j:set>
<j:set var="revUrl">${url}?<x:expr
select="revision"/>&content-type=text/vnd.viewcvs-markup</j:set>
<a href="${url}"><x:expr select="name"/></a> -
<a href="${revUrl}">v<x:expr select="revision"/></a>
<br/>
</jsl:template>
<!-- copy any other elements through -->
<jsl:template match="*" trim="false">
<jsl:copy trim="false">
<jsl:applyTemplates trim="false"/>
</jsl:copy>
</jsl:template>
<!-- element values don't pass through as text -->
<jsl:template match="@*"/>
</jsl:stylesheet>
1.1 avalon-sandbox/attributes/site/etc/stylesheet.css
Index: stylesheet.css
===================================================================
/* Javadoc style sheet */
/* Define colors, fonts and other style attributes here to override the defaults */
/* Page background color */
body { background-color: #FFFFFF }
/* Table colors */
.TableHeadingColor { background: #CCCCFF } /* Dark mauve */
.TableSubHeadingColor { background: #EEEEFF } /* Light mauve */
.TableRowColor { background: #FFFFFF } /* White */
/* Font used in left-hand frame lists */
.FrameTitleFont { font-size: 10pts; font-family: Helvetica, Arial, san-serif }
.FrameHeadingFont { font-size: 10pts; font-family: Helvetica, Arial, san-serif }
.FrameItemFont { font-size: 10pts; font-family: Helvetica, Arial, san-serif }
/* Example of smaller, sans-serif font in frames */
/* .FrameItemFont { font-size: 10pt; font-family: Helvetica, Arial, sans-serif } */
/* Navigation bar fonts and colors */
.NavBarCell1 { background-color:#EEEEFF;}/* Light mauve */
.NavBarCell1Rev { background-color:#00008B;}/* Dark Blue */
.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;}
.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;}
.NavBarCell2 { font-family: Arial, Helvetica, sans-serif;
background-color:#FFFFFF;}
.NavBarCell3 { font-family: Arial, Helvetica, sans-serif;
background-color:#FFFFFF;}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]