KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > services > impl > EngineServiceOuterProxy


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