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