KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > controls > api > assembly > ControlAssemblyContext


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

20
21 import java.io.File JavaDoc;
22 import java.lang.annotation.Annotation JavaDoc;
23 import java.lang.reflect.Method JavaDoc;
24 import java.util.Map JavaDoc;
25 import java.util.Set JavaDoc;
26
27 import com.sun.mirror.apt.Messager;
28
29 /**
30  * Control assemblers are passed a ControlAssemblyContext at the time they are
31  * invoked; the context allows the assemblers to interact with their external
32  * environment (checking files, side-effecting deployment descriptors, emitting
33  * code parameterized by the specifics of the control extension, etc).
34  *
35  * Beehive provides ControlAssemblyContext implementations that expose the
36  * standard environments of J2EE applications and modules. Vendor-specific
37  * implementations may provide access to their specific environment information,
38  * such as vendor-specific descriptors, via definition and implementation
39  * of additional interfaces. ControlAssemblers should use reflection to
40  * determine if the ControlAssemblyContext implementation they are passed
41  * supports a particular set of environment features.
42  */

43 public interface ControlAssemblyContext
44 {
45     /**
46      * Providers of ControlAssemblyContext implementations MUST implement
47      * Factory and newInstance to return their implementation.
48      */

49     interface Factory
50     {
51         /**
52          * Creates a new instance of a ControlAssemblyContext implementation.
53          *
54          * @param controlIntfOrExt public interface/extension of the control
55          * type being assembled
56          * @param bindings map of control implementation bindings, null
57          * means use defaults.
58          * @param clients set of clients that use this control type.
59          * @param moduleRoot file root of the J2EE module containing the
60          * control clients to be assembled
61          * @param moduleName name of the J2EE module containing the
62          * control clients to be assembled
63          * @param srcOutputRoot file root of a location where assemblers
64          * should output any sources they create that
65          * may need further processing before use.
66          * @return a new instance of a ControlAssemblyContext implementation
67          */

68         ControlAssemblyContext newInstance( Class JavaDoc controlIntfOrExt,
69                                             Map JavaDoc<String JavaDoc,String JavaDoc> bindings,
70                                             Set JavaDoc<String JavaDoc> clients,
71                                             File JavaDoc moduleRoot,
72                                             String JavaDoc moduleName,
73                                             File JavaDoc srcOutputRoot )
74             throws ControlAssemblyException;
75     }
76
77     /**
78      * Providers of ControlAssemblyContext implementations may implement
79      * EJBModule to provide access to an EJB module environment.
80      */

81     interface EJBModule
82     {
83         // TODO: Provide more abstract helpers for common tasks.
84
// E.g. addResourceRef().
85

86         File JavaDoc getEjbJarXml();
87     }
88
89     /**
90      * Providers of ControlAssemblyContext implementations may implement
91      * WebAppModule to provide access to a webapp module environment.
92      */

93     interface WebAppModule
94     {
95         File JavaDoc getWebXml();
96     }
97
98     /**
99      * Providers of ControlAssemblyContext implementations may implement
100      * EntAppModule to provide access to an enterprise application module
101      * environment.
102      */

103     interface EntAppModule
104     {
105         File JavaDoc getApplicationXml();
106     }
107
108     /**
109      * @return the interface type of the control being assembled (annotated
110      * w/ ControlExtension or ControlInterface)
111      */

112     Class JavaDoc getControlType();
113
114     /**
115      * @return the most derived interface of the control being assembled that
116      * is annotated with ControlInterface (may return the same as
117      * getControlType() if the control type is non-extended)
118      */

119     Class JavaDoc getMostDerivedControlInterface();
120
121     /**
122      * @return an annotation on the interface returned by
123      * getControlType()
124      */

125     <T extends Annotation JavaDoc> T
126         getControlAnnotation(Class JavaDoc<T> annotationClass);
127
128     /**
129      * @return an annotation on a method on the interface
130      * returned by getControlType()
131      */

132     <T extends Annotation JavaDoc> T
133         getControlMethodAnnotation(Class JavaDoc<T> annotationClass, Method JavaDoc m)
134             throws NoSuchMethodException JavaDoc;
135
136     /**
137      * @return the defaultBinding member of the ControlInterface
138      */

139     String JavaDoc getDefaultImplClassName();
140
141     /**
142      * @return the output directory into which "compilable" source should be output.
143      */

144     File JavaDoc getSrcOutputDir();
145
146     /**
147      * @return the root of the module for which assembly is taking place.
148      */

149     File JavaDoc getModuleDir();
150
151     /**
152      * @return the name of the module for which assembly is taking place.
153      */

154     String JavaDoc getModuleName();
155
156     /**
157      * @return the set of clients (by class name) which use the control type
158      */

159     Set JavaDoc<String JavaDoc> getClients();
160
161     /**
162      * @return a Messager implementation that can be used to emit diagnostics during the
163      * assembly process.
164      */

165     Messager getMessager();
166
167     /**
168      * @return true if the assembly process reported errors via the Messager
169      */

170     boolean hasErrors();
171 }
172
Popular Tags