|
|||||||||||||||||||
30 day Evaluation License registered to hlship@comcast.net Your 30 day evaluation period has expired. Please visit http://www.cenqua.com to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
HomeService.java | 50% | 83.3% | 85.7% | 81% |
|
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.engine; | |
16 | ||
17 | import java.io.IOException; | |
18 | import java.util.HashMap; | |
19 | import java.util.Map; | |
20 | ||
21 | import org.apache.tapestry.IRequestCycle; | |
22 | import org.apache.tapestry.Tapestry; | |
23 | import org.apache.tapestry.services.LinkFactory; | |
24 | import org.apache.tapestry.services.ResponseRenderer; | |
25 | import org.apache.tapestry.services.ServiceConstants; | |
26 | ||
27 | /** | |
28 | * An implementation of the home service that renders the Home page. This is the most likely | |
29 | * candidate for overriding ... for example, to select the page to render based on known information | |
30 | * about the user (stored as a cookie). | |
31 | * | |
32 | * @author Howard Lewis Ship | |
33 | * @since 1.0.9 | |
34 | */ | |
35 | ||
36 | public class HomeService implements IEngineService | |
37 | { | |
38 | /** @since 4.0 */ | |
39 | private ResponseRenderer _responseRenderer; | |
40 | ||
41 | /** @since 4.0 */ | |
42 | ||
43 | private LinkFactory _linkFactory; | |
44 | ||
45 | /** @since 4.0 */ | |
46 | ||
47 | private String _pageName; | |
48 | ||
49 | 6 | public ILink getLink(IRequestCycle cycle, Object parameter) |
50 | { | |
51 | 6 | if (parameter != null) |
52 | 0 | throw new IllegalArgumentException(EngineMessages.serviceNoParameter(this)); |
53 | ||
54 | 6 | Map parameters = new HashMap(); |
55 | ||
56 | 6 | parameters.put(ServiceConstants.SERVICE, Tapestry.HOME_SERVICE); |
57 | ||
58 | 6 | return _linkFactory.constructLink(cycle, parameters, true); |
59 | } | |
60 | ||
61 | 22 | public void service(IRequestCycle cycle) throws IOException |
62 | { | |
63 | 22 | cycle.activate(_pageName); |
64 | ||
65 | 21 | _responseRenderer.renderResponse(cycle); |
66 | } | |
67 | ||
68 | 20 | public String getName() |
69 | { | |
70 | 20 | return Tapestry.HOME_SERVICE; |
71 | } | |
72 | ||
73 | /** @since 4.0 */ | |
74 | 20 | public void setResponseRenderer(ResponseRenderer responseRenderer) |
75 | { | |
76 | 20 | _responseRenderer = responseRenderer; |
77 | } | |
78 | ||
79 | /** @since 4.0 */ | |
80 | 20 | public void setLinkFactory(LinkFactory linkFactory) |
81 | { | |
82 | 20 | _linkFactory = linkFactory; |
83 | } | |
84 | ||
85 | /** @since 4.0 */ | |
86 | 20 | public void setPageName(String pageName) |
87 | { | |
88 | 20 | _pageName = pageName; |
89 | } | |
90 | ||
91 | /** @since 4.0 */ | |
92 | 0 | public String getPageName() |
93 | { | |
94 | 0 | return _pageName; |
95 | } | |
96 | } |
|