KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > xdoclet > NetuiSubTask


1 package org.apache.beehive.netui.xdoclet;
2
3 import org.apache.beehive.netui.compiler.processor.PageFlowAnnotationProcessor;
4 import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationTypeDeclaration;
5 import org.apache.beehive.netui.compiler.typesystem.env.AnnotationProcessorEnvironment;
6 import org.apache.beehive.netui.compiler.xdoclet.typesystem.impl.declaration.DeclarationImpl;
7 import org.apache.beehive.netui.compiler.xdoclet.typesystem.impl.env.AnnotationProcessorEnvironmentImpl;
8 import xdoclet.DocletContext;
9 import xdoclet.SubTask;
10 import xdoclet.XDocletException;
11 import xjavadoc.SourceClass;
12 import xjavadoc.XJavaDoc;
13
14 import java.util.Collection JavaDoc;
15 import java.util.Iterator JavaDoc;
16
17
18 /**
19  * XJavaDoc subtask to run through a set of page flows in a webapp and generate Struts XML config files for them.
20  *
21  * @ant.element display-name="Netui" name="netui" parent="org.apache.beehive.netui.xdoclet.NetuiDocletTask"
22  */

23 public class NetuiSubTask extends SubTask
24 {
25     private SourceClass _currentSourceClass;
26     
27     /**
28      * Main entry point for xjavadoc tasks. Here we iterate through all the classes found by
29      * xjavadoc and process the ones that we recognize as pageflows.
30      *
31      * @throws XDocletException
32      */

33     public void execute() throws XDocletException
34     {
35     /*
36         if ( DocletContext.getInstance().isVerbose() )
37             System.out.println( CompilerUtil.genMessage( "compiler.info.gen.location",
38                     new String[] {getDestDir().getPath()} ) );
39     */

40         Collection JavaDoc classes = getXJavaDoc().getSourceClasses();
41         
42         /*
43         // issue a warning if xjavadoc didn't find any classes at all
44         if ( classes.size() == 0 )
45         {
46             System.out.println( CompilerUtil.genMessage( "no.classes.found" ) );
47             return;
48         }
49         
50         _pageflowCount = 0;
51         */

52         
53         Iterator JavaDoc iter = classes.iterator();
54         while ( iter.hasNext() )
55         {
56             SourceClass sourceClass = ( SourceClass ) iter.next();
57             AnnotationProcessorEnvironment env = AnnotationProcessorEnvironmentImpl.get( getContext(), this, sourceClass );
58             AnnotationTypeDeclaration[] decls = DeclarationImpl.getAllAnnotations(); // TODO: filter appropriately
59

60             PageFlowAnnotationProcessor pfap = new PageFlowAnnotationProcessor( decls, env );
61             
62             try
63             {
64                 _currentSourceClass = sourceClass;
65                 pfap.process();
66             }
67             finally
68             {
69                 _currentSourceClass = null;
70             }
71         }
72     }
73
74     public static NetuiSubTask get()
75     {
76         SubTask subtask = DocletContext.getInstance().getActiveSubTask();
77         assert subtask instanceof NetuiSubTask : subtask.getClass().getName();
78         return ( NetuiSubTask ) subtask;
79     }
80
81     public XJavaDoc getXJavaDoc()
82     {
83         return super.getXJavaDoc();
84     }
85
86     public SourceClass getCurrentSourceClass()
87     {
88         return _currentSourceClass;
89     }
90 }
91
Popular Tags