1 // Copyright 2004, 2005 The Apache Software Foundation 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package org.apache.hivemind.impl; 16 17 import java.util.List; 18 19 import org.apache.hivemind.definition.ImplementationConstructor; 20 import org.apache.hivemind.definition.ImplementationDefinition; 21 import org.apache.hivemind.events.RegistryShutdownListener; 22 import org.apache.hivemind.internal.ServicePoint; 23 24 /** 25 * "Private" interface used by a {@link org.apache.hivemind.internal.ServiceModel}s to access non- 26 * information about a {@link org.apache.hivemind.internal.ServicePoint}, such as its instance 27 * builder and interceptors. 28 * 29 * @author Howard Lewis Ship 30 */ 31 public interface ConstructableServicePoint extends ServicePoint 32 { 33 /** 34 * Returns the constructor that can create the core service implementation. Returns the service 35 * constructor, if defined, or the default service constructor. The default service constructor 36 * comes from the <service-point> itself; other modules can override this default using an 37 * <implementation> element. 38 */ 39 ImplementationConstructor getServiceConstructor(); 40 41 ImplementationDefinition getImplementationDefinition(); 42 43 /** 44 * Returns a list of {@link org.apache.hivemind.definition.InterceptorConstructor}s, 45 * ordered according to their dependencies. May return null or an empty list. 46 * <p> 47 * Note that the order is tricky! To keep any error messages while ordering the interceptors 48 * understandable, they are ordered according into runtime execution order. Example: If we want 49 * a logging interceptor to operate before a security-check interceptor, we'll write the 50 * following in the descriptor: 51 * 52 * <pre> 53 * <interceptor service-id="hivemind.LoggingInterceptor" before="*"/> 54 * <interceptor service-id="somepackage.SecurityInterceptor"/> 55 * </pre> 56 * 57 * The <code>before</code> value for the first interceptor contribution will be assigned to 58 * the contribution's 59 * {@link org.apache.hivemind.definition.InterceptorConstructor#getFollowingNames() followingNames} 60 * property, because all other interceptors (including the security interceptor) should have 61 * their behavior follow the logging interceptor. 62 * <p> 63 * To get this behavior, the logging interceptor will delegate to the security interceptor, and 64 * the security interceptor will delegate to the core service implementation. 65 * <p> 66 * The trick is that interceptors are applied in reverse order: we start with core service 67 * implementation, wrap it with the security interceptor, then wrap that with the logging 68 * interceptor ... but that's an issue that applies when building the interceptor stack around 69 * the core service implementation. 70 */ 71 List getOrderedInterceptorContributions(); 72 73 /** 74 * Invoked by the ServiceModel when constuction information (the builder and interceptors) is no 75 * longer needed. 76 */ 77 void clearConstructorInformation(); 78 79 /** 80 * Adds a shutdown listener; HiveMind uses two coordinators; the first is the 81 * hivemind.ShutdownCoordinator service, which is the coordinator used for service 82 * implementations. The second coordinator is used by the HiveMind infrastructure directly; this 83 * method adds a listener to that coordinator. Why two? It's about order of operations during 84 * registry shutdown; the hivemind.ShutdownCoordinator service's listeners are all invoked 85 * first, the the internal coordinator, to shutdown proxies and the like. This allows services 86 * to communicate during shutdown. 87 * 88 * @param listener 89 * the listener to be added to the infrastructure's shutdown coordinator 90 * @since 1.1.1 91 */ 92 93 void addRegistryShutdownListener(RegistryShutdownListener listener); 94 }