KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > riotfamily > website > generic > config > GenericNamespaceHandler


1 /* ***** BEGIN LICENSE BLOCK *****
2  * Version: MPL 1.1
3  * The contents of this file are subject to the Mozilla Public License Version
4  * 1.1 (the "License"); you may not use this file except in compliance with
5  * the License. You may obtain a copy of the License at
6  * http://www.mozilla.org/MPL/
7  *
8  * Software distributed under the License is distributed on an "AS IS" basis,
9  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
10  * for the specific language governing rights and limitations under the
11  * License.
12  *
13  * The Original Code is Riot.
14  *
15  * The Initial Developer of the Original Code is
16  * Neteye GmbH.
17  * Portions created by the Initial Developer are Copyright (C) 2006
18  * the Initial Developer. All Rights Reserved.
19  *
20  * Contributor(s):
21  * Felix Gnass [fgnass at neteye dot de]
22  * Carsten Woelk [cwoelk at neteye dot de]
23  *
24  * ***** END LICENSE BLOCK ***** */

25 package org.riotfamily.website.generic.config;
26
27
28 import org.riotfamily.common.beans.xml.GenericNamespaceHandlerSupport;
29 import org.riotfamily.common.beans.xml.NestedListDecorator;
30 import org.riotfamily.common.beans.xml.NestedPropertyDecorator;
31 import org.riotfamily.website.generic.GenericController;
32 import org.riotfamily.website.generic.GenericViewController;
33 import org.riotfamily.website.generic.model.hibernate.CurrentDateResolver;
34 import org.riotfamily.website.generic.model.hibernate.CurrentLanguageResolver;
35 import org.riotfamily.website.generic.model.hibernate.CurrentLocaleResolver;
36 import org.riotfamily.website.generic.model.hibernate.DefaultParameterResolver;
37 import org.riotfamily.website.generic.model.hibernate.HqlListModelBuilder;
38 import org.riotfamily.website.generic.model.hibernate.HqlModelBuilder;
39 import org.riotfamily.website.generic.model.hibernate.HqlPagedListModelBuilder;
40 import org.riotfamily.website.generic.model.hibernate.RiotUserResolver;
41 import org.riotfamily.website.generic.model.hibernate.SplitDateParameterResolver;
42 import org.riotfamily.website.generic.model.hibernate.StringToPrimitiveResolver;
43 import org.springframework.beans.factory.xml.BeanDefinitionDecorator;
44
45 /**
46  * NamespaceHandler that handles the <code>generic</code> namspace as
47  * defined in <code>generic.xsd</code> which can be found in the same package.
48  */

49 public class GenericNamespaceHandler extends GenericNamespaceHandlerSupport {
50
51     public void init() {
52         register("controller", GenericController.class).addReference("model-builder");
53         register("view", GenericViewController.class);
54
55         BeanDefinitionDecorator setModelBuilder = new NestedPropertyDecorator("modelBuilder");
56         register("hql", HqlModelBuilder.class, setModelBuilder).addTranslation("time-to-live", "ttlPeriod");
57         register("hql-list", HqlListModelBuilder.class, setModelBuilder).addTranslation("time-to-live", "ttlPeriod");
58         register("hql-paged-list", HqlPagedListModelBuilder.class, setModelBuilder).addTranslation("time-to-live", "ttlPeriod");
59         registerSpringBeanDefinitionParser("model-builder", setModelBuilder);
60
61         BeanDefinitionDecorator addParameterResolver = new NestedListDecorator("parameterResolvers");
62         register("attribute", DefaultParameterResolver.class, addParameterResolver);
63         register("current-date", CurrentDateResolver.class, addParameterResolver);
64         register("current-locale", CurrentLocaleResolver.class, addParameterResolver);
65         register("current-language", CurrentLanguageResolver.class, addParameterResolver);
66         register("riot-user", RiotUserResolver.class, addParameterResolver);
67         register("string-to-primitive", StringToPrimitiveResolver.class, addParameterResolver);
68         register("split-date", SplitDateParameterResolver.class, addParameterResolver);
69         registerSpringBeanDefinitionParser("custom-resolver", addParameterResolver);
70     }
71
72 }
73
Popular Tags