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 public static final String PRIMITIVE = "primitive";
028 public static final String SINGLETON = "singleton";
029 public static final String THREADED = "threaded";
030 public static final String POOLED = "pooled";
031
032
033 /**
034 * Invoked by the service extension point to obtain the service implementation. The model may
035 * return the actual service implementation or some form of proxy.
036 * <p>
037 * This method is only invoked <em>once</em>; the returned value is used from that point on
038 * (in all threads, by all callers). Most models return a proxy that takes care of realizing the
039 * service (actually creating the service, configuring it, and wrapping it with interceptors)
040 * only when needed.
041 */
042
043 public Object getService();
044
045 /**
046 * Forces the core service implementation (and any interceptors) to be fully instantiated
047 * immediately, rather than waiting for the first service method invocation. This is used when a
048 * service needs to be "eagerly loaded" rather than "lazy loaded".
049 */
050 public void instantiateService();
051 }