|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ComponentTemplateLoaderImpl.java | - | 100% | 100% | 100% |
|
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.IRequestCycle; | |
19 | import org.apache.tapestry.ITemplateComponent; | |
20 | import org.apache.tapestry.binding.BindingSource; | |
21 | import org.apache.tapestry.engine.IPageLoader; | |
22 | import org.apache.tapestry.parse.ComponentTemplate; | |
23 | import org.apache.tapestry.services.ComponentTemplateLoader; | |
24 | import org.apache.tapestry.services.TemplateSource; | |
25 | ||
26 | /** | |
27 | * Utility service, <code>tapestry.page.ComponentTemplateLoader</code>, which will process the | |
28 | * component's {@link org.apache.tapestry.parse.ComponentTemplate template}, which involves working | |
29 | * through the nested structure of the template and hooking the various static template blocks and | |
30 | * components together using {@link org.apache.tapestry.IComponent#addBody(IRender)}and | |
31 | * {@link org.apache.tapestry.ITemplateComponent#addOuter(IRender)}. | |
32 | * <p> | |
33 | * Because this service must be reentrant, it acts as a factory for a | |
34 | * {@link org.apache.tapestry.services.impl.ComponentTemplateLoaderLogic}that is created (and | |
35 | * discarded) for each component whose template is loaded. | |
36 | * | |
37 | * @author Howard Lewis Ship | |
38 | * @since 3.0 | |
39 | */ | |
40 | ||
41 | public class ComponentTemplateLoaderImpl implements ComponentTemplateLoader | |
42 | { | |
43 | private Log _log; | |
44 | ||
45 | private IPageLoader _pageLoader; | |
46 | ||
47 | private TemplateSource _templateSource; | |
48 | ||
49 | /** @since 4.0 */ | |
50 | ||
51 | private BindingSource _bindingSource; | |
52 | ||
53 | 213 | public void loadTemplate(IRequestCycle requestCycle, ITemplateComponent loadComponent) |
54 | { | |
55 | 213 | ComponentTemplate template = _templateSource.getTemplate(requestCycle, loadComponent); |
56 | ||
57 | 213 | ComponentTemplateLoaderLogic logic = new ComponentTemplateLoaderLogic(_log, _pageLoader, |
58 | _bindingSource); | |
59 | ||
60 | 213 | logic.loadTemplate(requestCycle, loadComponent, template); |
61 | } | |
62 | ||
63 | /** @since 4.0 */ | |
64 | ||
65 | 41 | public void setPageLoader(IPageLoader pageLoader) |
66 | { | |
67 | 41 | _pageLoader = pageLoader; |
68 | } | |
69 | ||
70 | /** @since 4.0 */ | |
71 | ||
72 | 41 | public void setLog(Log log) |
73 | { | |
74 | 41 | _log = log; |
75 | } | |
76 | ||
77 | /** | |
78 | * @since 4.0 | |
79 | */ | |
80 | ||
81 | 41 | public void setTemplateSource(TemplateSource templateSource) |
82 | { | |
83 | 41 | _templateSource = templateSource; |
84 | } | |
85 | ||
86 | /** | |
87 | * @since 4.0 | |
88 | */ | |
89 | ||
90 | 41 | public void setBindingSource(BindingSource bindingSource) |
91 | { | |
92 | 41 | _bindingSource = bindingSource; |
93 | } | |
94 | } |
|