|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
EngineServiceOuterProxy.java | - | 100% | 100% | 100% |
|
1 | // Copyright 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 java.io.IOException; | |
18 | ||
19 | import org.apache.hivemind.util.Defense; | |
20 | import org.apache.tapestry.IRequestCycle; | |
21 | import org.apache.tapestry.engine.IEngineService; | |
22 | import org.apache.tapestry.engine.ILink; | |
23 | ||
24 | /** | |
25 | * Outer proxy for engine services. The inner proxy resolves the engine service name to a engine | |
26 | * service implementation and installed it into the outer proxy as a delegate. Although HiveMind | |
27 | * does provide a similar system of inner and outer delegates, Tapestry's engine-service: | |
28 | * {@link org.apache.tapestry.services.impl.EngineServiceObjectProvider} object provider can | |
29 | * cause exceptions (recurive service build) when attempting to link two services together. This | |
30 | * extra layer of proxying resolves that issue. | |
31 | * | |
32 | * @author Howard M. Lewis Ship | |
33 | * @since 4.0 | |
34 | */ | |
35 | public class EngineServiceOuterProxy implements IEngineService | |
36 | { | |
37 | private final String _serviceName; | |
38 | ||
39 | private IEngineService _delegate; | |
40 | ||
41 | 165 | public EngineServiceOuterProxy(String serviceName) |
42 | { | |
43 | 165 | Defense.notNull(serviceName, "serviceName"); |
44 | ||
45 | 165 | _serviceName = serviceName; |
46 | } | |
47 | ||
48 | 292 | void installDelegate(IEngineService delegate) |
49 | { | |
50 | 292 | _delegate = delegate; |
51 | } | |
52 | ||
53 | 3 | IEngineService getDelegate() |
54 | { | |
55 | 3 | return _delegate; |
56 | } | |
57 | ||
58 | 217 | public ILink getLink(IRequestCycle cycle, boolean post, Object parameter) |
59 | { | |
60 | 217 | return _delegate.getLink(cycle, false, parameter); |
61 | } | |
62 | ||
63 | 140 | public void service(IRequestCycle cycle) throws IOException |
64 | { | |
65 | 140 | _delegate.service(cycle); |
66 | } | |
67 | ||
68 | 267 | public String getName() |
69 | { | |
70 | 267 | return _serviceName; |
71 | } | |
72 | ||
73 | 1 | public String toString() |
74 | { | |
75 | 1 | return ImplMessages.engineServiceOuterProxyToString(_serviceName); |
76 | } | |
77 | ||
78 | } |
|