01: /*
02: * $Id: IProxyTargetLocator.java 458351 2005-12-23 23:00:29Z ivaynberg $
03: * $Revision: 458351 $
04: * $Date: 2005-12-24 00:00:29 +0100 (Sat, 24 Dec 2005) $
05: *
06: * ==============================================================================
07: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
08: * use this file except in compliance with the License. You may obtain a copy of
09: * the License at
10: *
11: * http://www.apache.org/licenses/LICENSE-2.0
12: *
13: * Unless required by applicable law or agreed to in writing, software
14: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16: * License for the specific language governing permissions and limitations under
17: * the License.
18: */
19: package wicket.proxy;
20:
21: import java.io.Serializable;
22:
23: /**
24: * Represents a service locator for lazy init proxies. When the first method
25: * invocation occurs on the lazy init proxy this locator will be used to
26: * retrieve the proxy target object that will receive the method invocation.
27: * <p>
28: * Generally implementations should be small when serialized because the main
29: * purpose of lazy init proxies is to be stored in session when the wicket pages
30: * are serialized, and when deserialized to be able to lookup the dependency
31: * again. The smaller the implementation of IProxyTargetLocator the less the
32: * drain on session size.
33: * <p>
34: * A small implementation may use a static lookup to retrieve the target object.
35: * <p>
36: * Example:
37: *
38: * <pre>
39: * class UserServiceLocator implements IProxyTargetLocator
40: * {
41: * Object locateProxyObject()
42: * {
43: * MyApplication app = (MyApplication) Application.get();
44: * return app.getUserService();
45: * }
46: * }
47: * </pre>
48: *
49: * @see LazyInitProxyFactory#createProxy(Class, IProxyTargetLocator)
50: *
51: * @author Igor Vaynberg (ivaynberg)
52: *
53: */
54: public interface IProxyTargetLocator extends Serializable {
55: /**
56: * Returns the object that will be used as target object for a lazy init
57: * proxy.
58: *
59: * @return retrieved object
60: */
61: Object locateProxyTarget();
62: }
|