// Copyright 2004 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package gravity;

/**
 * @author Harish Krishnaswamy
 * @version $Id: ComponentStrategy.java,v 1.2 2004-06-14 04:15:21 harishkswamy Exp $
 */
public interface ComponentStrategy
{
    /**
     * This method will return an instance (concrete or hollow) of the component. The component
     * instance indentity is implementation dependent.
     * <p>
     * Only the following is true of the returned component instance:
     * <li>The returned component instance will be of the registered component type.
     * <li>Method invocations on the returned component instance will be completed successfully
     * provided an implementation was registered prior to the method invocation.
     * <p>
     * The advantage of using this method is that an instance of the component may be obtained even
     * prior to registering an implementation for the component.
     */
    Object getComponentInstance(ProxyableComponent component);

    /**
     * This method will return a concrete instance of this component. The component instance
     * indentity is implementation dependent. This method will throw a runtime exception if invoked
     * prior to registering an implementation for the component.
     * 
     * @throws WrapperException
     *         Wraps the actual exception thrown while obtaining the concrete component instance.
     */
    Object getConcreteComponentInstance(ProxyableComponent component);

    /**
     * This method will accept a component instance and return it to its cache.
     */
    void collectComponentInstance(Object compInst);
    
    /**
     * @return true If this state is a dispatching state, false otherwise. 
     */
    boolean isDispatching();
}
@@ -630,911 +630,770 @@
 %0A * 
-@author Harish Krishnaswamy%0A * @version $Id: ComponentStrategy.java,v 1.2 2004-06-14 04:15:21 harishkswamy Exp $%0A */%0Apublic interface ComponentStrategy%0A%7B%0A    /**%0A     * This method will return an instance (concrete or hollow) of the component. The component%0A     * instance indentity is implementation dependent.%0A     * %3Cp%3E%0A     * Only the following is true of the returned component instance:%0A     * %3Cli%3EThe returned component instance will be of the registered component type.%0A     * %3Cli%3EMethod invocations
+The strategy decides the identity and the life of concrete component instances returned by%0A * %7B@link gravity.Component%7D.%0A * %3Cp%3E%0A * There are two kinds of strategies: dispatching and lazy loading. All calls on a component will%0A * get dispatched to its strategy if the strategy is of dispatching kind. The strategy in turn%0A * determines the component instance that needs to be used for the calls. If the strategy is of lazy%0A * loading kind,
  on
+ly
  the 
-returned component instance will be completed successfully%0A     * provided an implementation was registered prior to the method invocation.%0A     * %3Cp%3E%0A     * The advantage of using this method is that an instance of the component may be obtained even%0A     * prior to registering an implementation for the component.%0A     */%0A    Object getComponentInstance(ProxyableComponent component);%0A
+very first call on the component gets dispatched to the strategy; all%0A * subsequent calls will reuse the same component instance returned the first time.%0A * %0A * @author Harish Krishnaswamy%0A * @version $Id: ComponentStrategy.java,v 1.3 2004-09-02 03:58:27 harishkswamy Exp $%0A */%0Apublic interface ComponentStrategy%0A%7B
 %0A   
@@ -1710,16 +1710,20 @@
         
+    
 Wraps th
@@ -1778,32 +1778,51 @@
 ncrete component
+%0A     *            
  instance.%0A     
@@ -1844,16 +1844,8 @@
 etCo
-ncreteCo
 mpon
@@ -1860,13 +1860,14 @@
 nce(
-Proxy
+Realiz
 able
@@ -2037,20 +2037,16 @@
 pInst);%0A
-    
 %0A    /**
@@ -2080,16 +2080,20 @@
 s st
+r
 ate
+gy
  is 
-a
+in
  dis
@@ -2124,17 +2124,16 @@
 herwise.
- 
 %0A     */

Drop getComponentInstance and rename getConcreteComponentInstance to getComponentInstance.