KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Inner proxy that actually resolves the engine service using the
26  * {@link org.apache.tapestry.services.impl.EngineServiceSource}, then replaces itself in the outer
27  * proxy.
28  *
29  * @author Howard M. Lewis Ship
30  * @since 4.0
31  * @see org.apache.tapestry.services.impl.EngineServiceOuterProxy
32  */

33 public class EngineServiceInnerProxy implements IEngineService
34 {
35     private final String JavaDoc _serviceName;
36
37     private final EngineServiceOuterProxy _outerProxy;
38
39     private final EngineServiceSource _source;
40
41     public EngineServiceInnerProxy(String JavaDoc serviceName, EngineServiceOuterProxy outerProxy,
42             EngineServiceSource source)
43     {
44         Defense.notNull(serviceName, "serviceName");
45         Defense.notNull(outerProxy, "outerProxy");
46         Defense.notNull(source, "source");
47
48         _serviceName = serviceName;
49         _outerProxy = outerProxy;
50         _source = source;
51     }
52
53     public String JavaDoc toString()
54     {
55         return ImplMessages.engineServiceInnerProxyToString(_serviceName);
56     }
57
58     private IEngineService resolve()
59     {
60         IEngineService service = _source.resolveEngineService(_serviceName);
61
62         _outerProxy.installDelegate(service);
63
64         return service;
65     }
66
67     public synchronized ILink getLink(IRequestCycle cycle, Object JavaDoc parameter)
68     {
69         return resolve().getLink(cycle, parameter);
70     }
71
72     public synchronized void service(IRequestCycle cycle) throws IOException JavaDoc
73     {
74         resolve().service(cycle);
75     }
76
77     public String JavaDoc getName()
78     {
79         return _serviceName;
80     }
81
82 }
Popular Tags