KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > compiler > FacesBackingGenerator


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * $Header:$
17  */

18 package org.apache.beehive.netui.compiler;
19
20 import org.apache.beehive.netui.compiler.typesystem.declaration.ClassDeclaration;
21 import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationInstance;
22 import org.apache.beehive.netui.compiler.typesystem.declaration.MethodDeclaration;
23 import org.apache.beehive.netui.compiler.typesystem.env.AnnotationProcessorEnvironment;
24
25 import java.io.File JavaDoc;
26
27 public class FacesBackingGenerator
28         extends BaseGenerator
29         implements JpfLanguageConstants
30 {
31     public FacesBackingGenerator( AnnotationProcessorEnvironment env, SourceFileInfo sourceFileInfo, Diagnostics diagnostics )
32     {
33         super( env, sourceFileInfo, diagnostics );
34     }
35
36     public void generate( ClassDeclaration publicClass )
37         throws FatalCompileTimeException
38     {
39         File JavaDoc sourceFile = CompilerUtils.getSourceFile( publicClass, true );
40         AnnotationInstance facesBackingAnnotation = CompilerUtils.getAnnotation( publicClass, FACES_BACKING_TAG_NAME );
41         assert facesBackingAnnotation != null; // checker should enforce this
42
AnnotationToXML atx = new AnnotationToXML( publicClass );
43         
44         // Add the class-level @Jpf.FacesBacking annotation.
45
atx.include( publicClass, facesBackingAnnotation );
46         
47         // For each method, add the @Jpf.CommandHandler annotation.
48
MethodDeclaration[] methods = CompilerUtils.getClassMethods( publicClass, COMMAND_HANDLER_TAG_NAME );
49         for ( int i = 0; i < methods.length; i++ )
50         {
51             MethodDeclaration method = methods[i];
52             AnnotationInstance commandHandlerAnn = CompilerUtils.getAnnotation( method, COMMAND_HANDLER_TAG_NAME );
53             atx.include( method, commandHandlerAnn );
54         }
55         
56         // Add @Jpf.SharedFlowField, @Jpf.PageFlowField, @Control.
57
FlowControllerGenerator.includeFieldAnnotations( atx, publicClass, PAGE_FLOW_FIELD_TAG_NAME );
58         
59         // Write the file.
60
atx.writeXml( CompilerUtils.getWebBuildRoot( getEnv() ), getDiagnostics() );
61     }
62 }
63
Popular Tags