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.impl;
016
017 import java.util.List;
018
019 import org.apache.hivemind.definition.ImplementationConstructor;
020 import org.apache.hivemind.definition.ImplementationDefinition;
021 import org.apache.hivemind.events.RegistryShutdownListener;
022 import org.apache.hivemind.internal.ServicePoint;
023
024 /**
025 * "Private" interface used by a {@link org.apache.hivemind.internal.ServiceModel}s to access non-
026 * information about a {@link org.apache.hivemind.internal.ServicePoint}, such as its instance
027 * builder and interceptors.
028 *
029 * @author Howard Lewis Ship
030 */
031 public interface ConstructableServicePoint extends ServicePoint
032 {
033 /**
034 * Returns the constructor that can create the core service implementation. Returns the service
035 * constructor, if defined, or the default service constructor. The default service constructor
036 * comes from the <service-point> itself; other modules can override this default using an
037 * <implementation> element.
038 */
039 ImplementationConstructor getServiceConstructor();
040
041 ImplementationDefinition getImplementationDefinition();
042
043 /**
044 * Returns a list of {@link org.apache.hivemind.definition.InterceptorConstructor}s,
045 * ordered according to their dependencies. May return null or an empty list.
046 * <p>
047 * Note that the order is tricky! To keep any error messages while ordering the interceptors
048 * understandable, they are ordered according into runtime execution order. Example: If we want
049 * a logging interceptor to operate before a security-check interceptor, we'll write the
050 * following in the descriptor:
051 *
052 * <pre>
053 * <interceptor service-id="hivemind.LoggingInterceptor" before="*"/>
054 * <interceptor service-id="somepackage.SecurityInterceptor"/>
055 * </pre>
056 *
057 * The <code>before</code> value for the first interceptor contribution will be assigned to
058 * the contribution's
059 * {@link org.apache.hivemind.definition.InterceptorConstructor#getFollowingNames() followingNames}
060 * property, because all other interceptors (including the security interceptor) should have
061 * their behavior follow the logging interceptor.
062 * <p>
063 * To get this behavior, the logging interceptor will delegate to the security interceptor, and
064 * the security interceptor will delegate to the core service implementation.
065 * <p>
066 * The trick is that interceptors are applied in reverse order: we start with core service
067 * implementation, wrap it with the security interceptor, then wrap that with the logging
068 * interceptor ... but that's an issue that applies when building the interceptor stack around
069 * the core service implementation.
070 */
071 List getOrderedInterceptorContributions();
072
073 /**
074 * Invoked by the ServiceModel when constuction information (the builder and interceptors) is no
075 * longer needed.
076 */
077 void clearConstructorInformation();
078
079 /**
080 * Adds a shutdown listener; HiveMind uses two coordinators; the first is the
081 * hivemind.ShutdownCoordinator service, which is the coordinator used for service
082 * implementations. The second coordinator is used by the HiveMind infrastructure directly; this
083 * method adds a listener to that coordinator. Why two? It's about order of operations during
084 * registry shutdown; the hivemind.ShutdownCoordinator service's listeners are all invoked
085 * first, the the internal coordinator, to shutdown proxies and the like. This allows services
086 * to communicate during shutdown.
087 *
088 * @param listener
089 * the listener to be added to the infrastructure's shutdown coordinator
090 * @since 1.1.1
091 */
092
093 void addRegistryShutdownListener(RegistryShutdownListener listener);
094 }