001    // Copyright 2004, 2005 The Apache Software Foundation
002    //
003    // Licensed under the Apache License, Version 2.0 (the "License");
004    // you may not use this file except in compliance with the License.
005    // You may obtain a copy of the License at
006    //
007    //     http://www.apache.org/licenses/LICENSE-2.0
008    //
009    // Unless required by applicable law or agreed to in writing, software
010    // distributed under the License is distributed on an "AS IS" BASIS,
011    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012    // See the License for the specific language governing permissions and
013    // limitations under the License.
014    
015    package org.apache.hivemind.internal;
016    
017    /**
018     * A service model is associated with a {@link org.apache.hivemind.internal.ServicePoint} to supply
019     * rules for the lifecycle of the service. This concerns when the service is first created and
020     * whether it is pooled, etc. Each service extension point will have a unique instance of
021     * ServiceModel.
022     * 
023     * @author Howard Lewis Ship
024     */
025    public interface ServiceModel
026    {
027        /**
028         * Invoked by the service extension point to obtain the service implementation. The model may
029         * return the actual service implementation or some form of proxy.
030         * <p>
031         * This method is only invoked <em>once</em>; the returned value is used from that point on
032         * (in all threads, by all callers). Most models return a proxy that takes care of realizing the
033         * service (actually creating the service, configuring it, and wrapping it with interceptors)
034         * only when needed.
035         */
036    
037        public Object getService();
038    
039        /**
040         * Forces the core service implementation (and any interceptors) to be fully instantiated
041         * immediately, rather than waiting for the first service method invocation. This is used when a
042         * service needs to be "eagerly loaded" rather than "lazy loaded".
043         */
044        public void instantiateService();
045    }