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