KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > services > impl > ComponentTemplateLoaderImpl


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

15 package org.apache.tapestry.services.impl;
16
17 import org.apache.commons.logging.Log;
18 import org.apache.tapestry.IRender;
19 import org.apache.tapestry.IRequestCycle;
20 import org.apache.tapestry.ITemplateComponent;
21 import org.apache.tapestry.binding.BindingSource;
22 import org.apache.tapestry.engine.IPageLoader;
23 import org.apache.tapestry.parse.ComponentTemplate;
24 import org.apache.tapestry.services.ComponentTemplateLoader;
25 import org.apache.tapestry.services.TemplateSource;
26
27 /**
28  * Utility service, <code>tapestry.page.ComponentTemplateLoader</code>, which will process the
29  * component's {@link org.apache.tapestry.parse.ComponentTemplate template}, which involves working
30  * through the nested structure of the template and hooking the various static template blocks and
31  * components together using {@link org.apache.tapestry.IComponent#addBody(IRender)}and
32  * {@link org.apache.tapestry.ITemplateComponent#addOuter(IRender)}.
33  * <p>
34  * Because this service must be reentrant, it acts as a factory for a
35  * {@link org.apache.tapestry.services.impl.ComponentTemplateLoaderLogic}that is created (and
36  * discarded) for each component whose template is loaded.
37  *
38  * @author Howard Lewis Ship
39  * @since 3.0
40  */

41
42 public class ComponentTemplateLoaderImpl implements ComponentTemplateLoader
43 {
44     private Log _log;
45
46     private IPageLoader _pageLoader;
47
48     private TemplateSource _templateSource;
49
50     /** @since 4.0 */
51
52     private BindingSource _bindingSource;
53
54     public void loadTemplate(IRequestCycle requestCycle, ITemplateComponent loadComponent)
55     {
56         ComponentTemplate template = _templateSource.getTemplate(requestCycle, loadComponent);
57
58         ComponentTemplateLoaderLogic logic = new ComponentTemplateLoaderLogic(_log, _pageLoader,
59                 _bindingSource);
60
61         logic.loadTemplate(requestCycle, loadComponent, template);
62     }
63
64     /** @since 4.0 */
65
66     public void setPageLoader(IPageLoader pageLoader)
67     {
68         _pageLoader = pageLoader;
69     }
70
71     /** @since 4.0 */
72
73     public void setLog(Log log)
74     {
75         _log = log;
76     }
77
78     /**
79      * @since 4.0
80      */

81
82     public void setTemplateSource(TemplateSource templateSource)
83     {
84         _templateSource = templateSource;
85     }
86
87     /**
88      * @since 4.0
89      */

90
91     public void setBindingSource(BindingSource bindingSource)
92     {
93         _bindingSource = bindingSource;
94     }
95 }
Popular Tags