001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.wicket.proxy;
018
019import org.apache.wicket.util.io.IClusterable;
020
021/**
022 * Represents a service locator for lazy init proxies. When the first method invocation occurs on
023 * the lazy init proxy this locator will be used to retrieve the proxy target object that will
024 * receive the method invocation.
025 * <p>
026 * Generally implementations should be small when serialized because the main purpose of lazy init
027 * proxies is to be stored in session when the wicket pages are serialized, and when deserialized to
028 * be able to lookup the dependency again. The smaller the implementation of IProxyTargetLocator the
029 * less the drain on session size.
030 * <p>
031 * A small implementation may use a static lookup to retrieve the target object.
032 * <p>
033 * Example:
034 * 
035 * <pre>
036 * class UserServiceLocator implements IProxyTargetLocator
037 * {
038 *      Object locateProxyObject()
039 *      {
040 *              MyApplication app = (MyApplication)Application.get();
041 *              return app.getUserService();
042 *      }
043 * }
044 * </pre>
045 * 
046 * @see LazyInitProxyFactory#createProxy(Class, IProxyTargetLocator)
047 * 
048 * @author Igor Vaynberg (ivaynberg)
049 * 
050 */
051public interface IProxyTargetLocator extends IClusterable
052{
053        /**
054         * Returns the object that will be used as target object for a lazy init proxy.
055         * 
056         * @return retrieved object
057         */
058        <T> T locateProxyTarget();
059}