KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > pageflow > internal > CachedSharedFlowRefInfo


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.pageflow.internal;
19
20 import org.apache.beehive.netui.compiler.schema.annotations.ProcessedAnnotation;
21
22 import javax.servlet.ServletContext JavaDoc;
23 import java.util.List JavaDoc;
24 import java.util.ArrayList JavaDoc;
25 import java.lang.reflect.Field JavaDoc;
26
27 public class CachedSharedFlowRefInfo
28 {
29     public static class SharedFlowFieldInfo
30     {
31         public Field JavaDoc field;
32         public String JavaDoc sharedFlowName;
33     }
34     
35     /**
36      * The SharedFlowController-initialized member fields -- may or may not be present.
37      */

38     private SharedFlowFieldInfo[] _sharedFlowMemberFields;
39     
40     protected void initSharedFlowFields( AnnotationReader annReader, Field JavaDoc[] fields )
41     {
42         List JavaDoc/*< SharedFlowFieldInfo >*/ sharedFlowFields = null;
43         
44         for ( int i = 0; i < fields.length; i++ )
45         {
46             Field JavaDoc field = fields[i];
47             
48             ProcessedAnnotation sharedFlowFieldAnn = annReader.getJpfAnnotation( field, "SharedFlowField" );
49             
50             if ( sharedFlowFieldAnn != null )
51             {
52                 field.setAccessible( true );
53                 if ( sharedFlowFields == null ) sharedFlowFields = new ArrayList JavaDoc/*< SharedFlowFieldInfo >*/();
54                 SharedFlowFieldInfo info = new SharedFlowFieldInfo();
55                 info.field = field;
56                 info.sharedFlowName = AnnotationReader.getStringAttribute( sharedFlowFieldAnn, "name" );
57                 sharedFlowFields.add( info );
58             }
59             else if ( field.getName().equals( InternalConstants.GLOBALAPP_MEMBER_NAME ) )
60             {
61                 //
62
// Legacy behavior: initialize a field called 'globalApp' with the Global.app instance.
63
//
64
field.setAccessible( true );
65                 if ( sharedFlowFields == null ) sharedFlowFields = new ArrayList JavaDoc/*< SharedFlowFieldInfo >*/();
66                 SharedFlowFieldInfo info = new SharedFlowFieldInfo();
67                 info.field = field;
68                 info.sharedFlowName = null;
69                 sharedFlowFields.add( info );
70             }
71         }
72         
73         if ( sharedFlowFields != null )
74         {
75             _sharedFlowMemberFields = ( SharedFlowFieldInfo[] ) sharedFlowFields.toArray( new SharedFlowFieldInfo[ sharedFlowFields.size() ] );
76         }
77     }
78     
79     public SharedFlowFieldInfo[] getSharedFlowMemberFields()
80     {
81         return _sharedFlowMemberFields;
82     }
83 }
84
Popular Tags