|
|||||||||||||||||||
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 | 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 | private final String _serviceName; | |
39 | ||
40 | private IEngineService _delegate; | |
41 | ||
42 | 156 | public EngineServiceOuterProxy(String serviceName) |
43 | { | |
44 | 156 | Defense.notNull(serviceName, "serviceName"); |
45 | ||
46 | 156 | _serviceName = serviceName; |
47 | } | |
48 | ||
49 | 274 | void installDelegate(IEngineService delegate) |
50 | { | |
51 | 274 | _delegate = delegate; |
52 | } | |
53 | ||
54 | 4 | IEngineService getDelegate() |
55 | { | |
56 | 4 | return _delegate; |
57 | } | |
58 | ||
59 | 190 | public ILink getLink(boolean post, Object parameter) |
60 | { | |
61 | 190 | return _delegate.getLink(post, parameter); |
62 | } | |
63 | ||
64 | 130 | public void service(IRequestCycle cycle) throws IOException |
65 | { | |
66 | 130 | _delegate.service(cycle); |
67 | } | |
68 | ||
69 | 247 | public String getName() |
70 | { | |
71 | 247 | return _serviceName; |
72 | } | |
73 | ||
74 | 1 | public String toString() |
75 | { | |
76 | 1 | return ImplMessages.engineServiceOuterProxyToString(_serviceName); |
77 | } | |
78 | ||
79 | } |
|