KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > kernel > plugins > deployment > xml > BeanSchemaBindingHelper


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2006, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.kernel.plugins.deployment.xml;
23
24 import javax.xml.namespace.QName JavaDoc;
25
26 import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
27 import org.jboss.xb.binding.sunday.unmarshalling.TypeBinding;
28 import org.jboss.xb.binding.sunday.unmarshalling.WildcardBinding;
29
30 /**
31  * BeanSchemaBindingHelper.
32  *
33  * @author <a HREF="adrian@jboss.com">Adrian Brock</a>
34  * @version $Revision: 57679 $
35  */

36 public class BeanSchemaBindingHelper
37 {
38    public static void initAll(SchemaBinding schemaBinding)
39    {
40       
41    }
42    
43    /**
44     * Initialize the handlers for the deployment type
45     *
46     * @param deploymentType the deployment type
47     */

48    public static void initDeploymentHandlers(TypeBinding deploymentType)
49    {
50       deploymentType.setHandler(DeploymentHandler.HANDLER);
51
52       // deployment has a classloader
53
deploymentType.pushInterceptor(BeanSchemaBinding20.classloaderQName, DeploymentClassLoaderInterceptor.INTERCEPTOR);
54
55       // deployment has a list beans
56
deploymentType.pushInterceptor(BeanSchemaBinding20.beanQName, DeploymentBeanInterceptor.INTERCEPTOR);
57
58       // deployment has a list beanfactorys
59
deploymentType.pushInterceptor(BeanSchemaBinding20.beanFactoryQName, DeploymentBeanInterceptor.INTERCEPTOR);
60
61       // Deployment can take wildcards
62
deploymentType.getWildcard().setWildcardHandler(DeploymentWildcardHandler.HANDLER);
63    }
64
65    /**
66     * Initialize the handlers for the bean type
67     *
68     * @param beanType the bean type
69     */

70    public static void initBeanHandlers(TypeBinding beanType)
71    {
72       beanType.setHandler(BeanHandler.HANDLER);
73
74       // bean has a classloader
75
beanType.pushInterceptor(BeanSchemaBinding20.classloaderQName, BeanClassLoaderInterceptor.INTERCEPTOR);
76
77       // bean has a constructor
78
beanType.pushInterceptor(BeanSchemaBinding20.constructorQName, BeanConstructorInterceptor.INTERCEPTOR);
79
80       // bean has properties
81
beanType.pushInterceptor(BeanSchemaBinding20.propertyQName, BeanPropertyInterceptor.INTERCEPTOR);
82
83       // bean has a create
84
beanType.pushInterceptor(BeanSchemaBinding20.createQName, BeanCreateInterceptor.INTERCEPTOR);
85
86       // bean has a start
87
beanType.pushInterceptor(BeanSchemaBinding20.startQName, BeanStartInterceptor.INTERCEPTOR);
88
89       // bean has a stop
90
beanType.pushInterceptor(BeanSchemaBinding20.stopQName, BeanStopInterceptor.INTERCEPTOR);
91
92       // bean has a destroy
93
beanType.pushInterceptor(BeanSchemaBinding20.destroyQName, BeanDestroyInterceptor.INTERCEPTOR);
94
95       // bean has annotations
96
beanType.pushInterceptor(BeanSchemaBinding20.annotationQName, BeanAnnotationInterceptor.INTERCEPTOR);
97
98       // bean has installs
99
beanType.pushInterceptor(BeanSchemaBinding20.installQName, BeanInstallInterceptor.INTERCEPTOR);
100
101       // bean has uninstalls
102
beanType.pushInterceptor(BeanSchemaBinding20.uninstallQName, BeanUninstallInterceptor.INTERCEPTOR);
103
104       // bean has depends
105
beanType.pushInterceptor(BeanSchemaBinding20.dependsQName, BeanDependsInterceptor.INTERCEPTOR);
106
107       // bean has demands
108
beanType.pushInterceptor(BeanSchemaBinding20.demandQName, BeanDemandsInterceptor.INTERCEPTOR);
109
110       // bean has supplies
111
beanType.pushInterceptor(BeanSchemaBinding20.supplyQName, BeanSuppliesInterceptor.INTERCEPTOR);
112    }
113
114    /**
115     * Initialize the handlers for the bean factory type
116     *
117     * @param beanFactoryType the bean factory type
118     */

119    public static void initBeanFactoryHandlers(TypeBinding beanFactoryType)
120    {
121       beanFactoryType.setHandler(BeanFactoryHandler.HANDLER);
122
123       // bean factory has a classloader
124
beanFactoryType.pushInterceptor(BeanSchemaBinding20.classloaderQName, BeanClassLoaderInterceptor.INTERCEPTOR);
125
126       // bean factory has a constructor
127
beanFactoryType.pushInterceptor(BeanSchemaBinding20.constructorQName, BeanFactoryConstructorInterceptor.INTERCEPTOR);
128
129       // bean factory has properties
130
beanFactoryType.pushInterceptor(BeanSchemaBinding20.propertyQName, BeanFactoryPropertyInterceptor.INTERCEPTOR);
131
132       // bean factory has a create
133
beanFactoryType.pushInterceptor(BeanSchemaBinding20.createQName, BeanFactoryCreateInterceptor.INTERCEPTOR);
134
135       // bean factory has a start
136
beanFactoryType.pushInterceptor(BeanSchemaBinding20.startQName, BeanFactoryStartInterceptor.INTERCEPTOR);
137
138       // bean factory has installs
139
beanFactoryType.pushInterceptor(BeanSchemaBinding20.installQName, BeanInstallInterceptor.INTERCEPTOR);
140
141       // bean factory has uninstalls
142
beanFactoryType.pushInterceptor(BeanSchemaBinding20.uninstallQName, BeanUninstallInterceptor.INTERCEPTOR);
143
144       // bean factory has depends
145
beanFactoryType.pushInterceptor(BeanSchemaBinding20.dependsQName, BeanDependsInterceptor.INTERCEPTOR);
146
147       // bean factory has demands
148
beanFactoryType.pushInterceptor(BeanSchemaBinding20.demandQName, BeanDemandsInterceptor.INTERCEPTOR);
149
150       // bean factory has supplies
151
beanFactoryType.pushInterceptor(BeanSchemaBinding20.supplyQName, BeanSuppliesInterceptor.INTERCEPTOR);
152    }
153
154    /**
155     * Initialize the handlers for the classloader type
156     *
157     * @param classloaderType the classloader type
158     */

159    public static void initClassLoaderHandlers(TypeBinding classloaderType)
160    {
161       classloaderType.setHandler(ClassLoaderHandler.HANDLER);
162
163       configureValueBindings(classloaderType);
164    }
165
166    /**
167     * Initialize the handlers for the constructor type
168     *
169     * @param constructorType the constructor type
170     */

171    public static void initConstructorHandlers(TypeBinding constructorType)
172    {
173       constructorType.setHandler(ConstructorHandler.HANDLER);
174
175       // constructor has annotations
176
constructorType.pushInterceptor(BeanSchemaBinding20.annotationQName, ConstructorAnnotationsInterceptor.INTERCEPTOR);
177
178       // constructor has a factory
179
constructorType.pushInterceptor(BeanSchemaBinding20.factoryQName, ConstructorFactoryInterceptor.INTERCEPTOR);
180
181       // constructor has parameters
182
constructorType.pushInterceptor(BeanSchemaBinding20.parameterQName, ConstructorParametersInterceptor.INTERCEPTOR);
183       
184       configureValueBindings(constructorType);
185    }
186
187    /**
188     * Initialize the handlers for the property type
189     *
190     * @param propertyType the property type
191     */

192    public static void initPropertyHandlers(TypeBinding propertyType)
193    {
194       propertyType.setHandler(PropertyHandler.HANDLER);
195
196       // property has annotations
197
propertyType.pushInterceptor(BeanSchemaBinding20.annotationQName, PropertyAnnotationsInterceptor.INTERCEPTOR);
198
199       // property can take characters
200
propertyType.setSimpleType(PropertyCharactersHandler.HANDLER);
201       
202       configureValueBindings(propertyType);
203    }
204
205    /**
206     * Initialize the handlers for the parameter type
207     *
208     * @param parameterType the parameter type
209     */

210    public static void initParameterHandlers(TypeBinding parameterType)
211    {
212       parameterType.setHandler(ParameterHandler.HANDLER);
213
214       // parameter has annotations
215
parameterType.pushInterceptor(BeanSchemaBinding20.annotationQName, ParameterAnnotationsInterceptor.INTERCEPTOR);
216
217       // parameter can take characters
218
parameterType.setSimpleType(ParameterCharactersHandler.HANDLER);
219       
220       configureValueBindings(parameterType);
221    }
222
223    /**
224     * Initialize the handlers for the lifecycle type
225     *
226     * @param lifecycleType the lifecycle type
227     */

228    public static void initLifecycleHandlers(TypeBinding lifecycleType)
229    {
230       lifecycleType.setHandler(LifecycleHandler.HANDLER);
231
232       // lifecycle has annotations
233
lifecycleType.pushInterceptor(BeanSchemaBinding20.annotationQName, LifecycleAnnotationsInterceptor.INTERCEPTOR);
234
235       // lifecycle has parameters
236
lifecycleType.pushInterceptor(BeanSchemaBinding20.parameterQName, LifecycleParametersInterceptor.INTERCEPTOR);
237    }
238
239    /**
240     * Initialize the handlers for the install type
241     *
242     * @param installType the install type
243     */

244    public static void initInstallHandlers(TypeBinding installType)
245    {
246       installType.setHandler(InstallHandler.HANDLER);
247
248       // install has annotations
249
installType.pushInterceptor(BeanSchemaBinding20.annotationQName, InstallAnnotationsInterceptor.INTERCEPTOR);
250
251       // install has parameters
252
installType.pushInterceptor(BeanSchemaBinding20.parameterQName, InstallParametersInterceptor.INTERCEPTOR);
253    }
254
255    /**
256     * Initialize the handlers for the annotation type
257     *
258     * @param annotationType the annotation type
259     */

260    public static void initAnnotationHandlers(TypeBinding annotationType)
261    {
262       annotationType.setHandler(AnnotationHandler.HANDLER);
263    }
264
265    /**
266     * Initialize the handlers for the depends type
267     *
268     * @param dependsType the depends type
269     */

270    public static void initDependsHandlers(TypeBinding dependsType)
271    {
272       dependsType.setHandler(DependsHandler.HANDLER);
273
274       // depends can take characters
275
dependsType.setSimpleType(DependsCharactersHandler.HANDLER);
276    }
277
278    /**
279     * Initialize the handlers for the demands type
280     *
281     * @param demandType the demand type
282     */

283    public static void initDemandHandlers(TypeBinding demandType)
284    {
285       demandType.setHandler(DemandHandler.HANDLER);
286
287       // demand can take characters
288
demandType.setSimpleType(DemandCharactersHandler.HANDLER);
289    }
290
291    /**
292     * Initialize the handlers for the supply type
293     *
294     * @param supplyType the supply type
295     */

296    public static void initSupplyHandlers(TypeBinding supplyType)
297    {
298       supplyType.setHandler(SupplyHandler.HANDLER);
299
300       // supply can take characters
301
supplyType.setSimpleType(SupplyCharactersHandler.HANDLER);
302    }
303
304    /**
305     * Initialize the handlers for the dependency type
306     *
307     * @param dependencyType the dependency type
308     */

309    public static void initDependencyHandlers(TypeBinding dependencyType)
310    {
311       dependencyType.setHandler(DependencyHandler.HANDLER);
312    }
313
314    /**
315     * Initialize the handlers for the injection type
316     *
317     * @param dependencyType the dependency type
318     */

319    public static void initInjectionHandlers(TypeBinding dependencyType)
320    {
321       dependencyType.setHandler(InjectionHandler.HANDLER);
322    }
323
324    /**
325     * Initialize the handlers for the factory type
326     *
327     * @param factoryType the factory type
328     */

329    public static void initFactoryHandlers(TypeBinding factoryType)
330    {
331       factoryType.setHandler(FactoryHandler.HANDLER);
332       
333       // factory has a wildcard
334
factoryType.getWildcard().setWildcardHandler(FactoryWildcardHandler.WILDCARD);
335    }
336
337    /**
338     * Initialize the handlers for the plain value type
339     *
340     * @param plainValueType the plain value type
341     */

342    public static void initPlainValueHandlers(TypeBinding plainValueType)
343    {
344       plainValueType.setHandler(PlainValueHandler.HANDLER);
345
346       // plain value can take characters
347
plainValueType.setSimpleType(PlainValueCharactersHandler.HANDLER);
348    }
349
350    /**
351     * Initialize the handlers for the value type
352     *
353     * @param valueType the value type
354     */

355    public static void initValueHandlers(TypeBinding valueType)
356    {
357       valueType.setHandler(ValueHandler.HANDLER);
358
359       // value can take characters
360
valueType.setSimpleType(ValueCharactersHandler.HANDLER);
361       
362       BeanSchemaBindingHelper.configureValueBindings(valueType);
363    }
364
365    /**
366     * Initialize the handlers for the map type
367     *
368     * @param mapType the map type
369     */

370    public static void initMapHandlers(TypeBinding mapType)
371    {
372       mapType.setHandler(MapHandler.HANDLER);
373
374       // entry has an entry
375
mapType.pushInterceptor(BeanSchemaBinding20.entryQName, MapEntryInterceptor.INTERCEPTOR);
376    }
377
378    /**
379     * Initialize the handlers for the map entry type
380     *
381     * @param entryType the map entry type
382     */

383    public static void initEntryHandlers(TypeBinding entryType)
384    {
385       entryType.setHandler(EntryHandler.HANDLER);
386
387       // entry has a key
388
entryType.pushInterceptor(BeanSchemaBinding20.keyQName, EntryKeyInterceptor.INTERCEPTOR);
389
390       // entry has value
391
entryType.pushInterceptor(BeanSchemaBinding20.valueQName, EntryValueInterceptor.INTERCEPTOR);
392    }
393    
394    /**
395     * Configure a collection.
396     *
397     * @param schemaBinding the schemabinding
398     * @param qname the name of the type
399     */

400    public static void configureCollection(SchemaBinding schemaBinding, QName JavaDoc qname)
401    {
402       TypeBinding collectionType = schemaBinding.getType(qname);
403       collectionType.setHandler(CollectionHandler.HANDLER);
404       configureValueBindings(collectionType);
405    }
406    
407    /**
408     * Configure value bindings
409     *
410     * @param typeBinding the type binding
411     */

412    public static void configureValueBindings(TypeBinding typeBinding)
413    {
414       // type has values
415
typeBinding.pushInterceptor(BeanSchemaBinding20.valueQName, ValueMetaDataElementInterceptor.VALUES);
416
417       // type has injections
418
typeBinding.pushInterceptor(BeanSchemaBinding20.injectQName, ValueMetaDataElementInterceptor.VALUES);
419
420       // type can take a collection
421
typeBinding.pushInterceptor(BeanSchemaBinding20.collectionQName, ValueMetaDataElementInterceptor.VALUES);
422
423       // type can take a list
424
typeBinding.pushInterceptor(BeanSchemaBinding20.listQName, ValueMetaDataElementInterceptor.VALUES);
425
426       // type can take a set
427
typeBinding.pushInterceptor(BeanSchemaBinding20.setQName, ValueMetaDataElementInterceptor.VALUES);
428
429       // type can take an array
430
typeBinding.pushInterceptor(BeanSchemaBinding20.arrayQName, ValueMetaDataElementInterceptor.VALUES);
431
432       // type can take a map
433
typeBinding.pushInterceptor(BeanSchemaBinding20.mapQName, ValueMetaDataElementInterceptor.VALUES);
434
435       // type has a null
436
typeBinding.pushInterceptor(BeanSchemaBinding20.nullQName, NullValueElementInterceptor.NULLVALUES);
437
438       // type has a this
439
typeBinding.pushInterceptor(BeanSchemaBinding20.thisQName, ThisValueElementInterceptor.THISVALUES);
440       
441       // type has wildcard
442
WildcardBinding wcb = typeBinding.getWildcard();
443       if( wcb != null )
444          wcb.setWildcardHandler(ValueWildcardHandler.WILDCARD);
445    }
446 }
447
Popular Tags