Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ComponentTemplateLoaderImpl |
|
| 1.0;1 |
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 | 0 | 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 | 0 | ComponentTemplate template = _templateSource.getTemplate(requestCycle, loadComponent); |
57 | ||
58 | 0 | ComponentTemplateLoaderLogic logic = new ComponentTemplateLoaderLogic(_log, _pageLoader, _bindingSource); |
59 | ||
60 | 0 | logic.loadTemplate(requestCycle, loadComponent, template); |
61 | 0 | } |
62 | ||
63 | /** @since 4.0 */ | |
64 | ||
65 | public void setPageLoader(IPageLoader pageLoader) | |
66 | { | |
67 | 0 | _pageLoader = pageLoader; |
68 | 0 | } |
69 | ||
70 | /** @since 4.0 */ | |
71 | ||
72 | public void setLog(Log log) | |
73 | { | |
74 | 0 | _log = log; |
75 | 0 | } |
76 | ||
77 | /** | |
78 | * @since 4.0 | |
79 | */ | |
80 | ||
81 | public void setTemplateSource(TemplateSource templateSource) | |
82 | { | |
83 | 0 | _templateSource = templateSource; |
84 | 0 | } |
85 | ||
86 | /** | |
87 | * @since 4.0 | |
88 | */ | |
89 | ||
90 | public void setBindingSource(BindingSource bindingSource) | |
91 | { | |
92 | 0 | _bindingSource = bindingSource; |
93 | 0 | } |
94 | } |