001/*- 002 * #%L 003 * HAPI FHIR - Core Library 004 * %% 005 * Copyright (C) 2014 - 2024 Smile CDR, Inc. 006 * %% 007 * Licensed under the Apache License, Version 2.0 (the "License"); 008 * you may not use this file except in compliance with the License. 009 * You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 * #L% 019 */ 020package ca.uhn.fhir.interceptor.api; 021 022import jakarta.annotation.Nullable; 023 024import java.util.Collection; 025import java.util.List; 026import java.util.function.Predicate; 027 028public interface IBaseInterceptorService<POINTCUT extends IPointcut> extends IBaseInterceptorBroadcaster<POINTCUT> { 029 030 /** 031 * Register an interceptor. This method has no effect if the given interceptor is already registered. 032 * 033 * @param theInterceptor The interceptor to register 034 * @return Returns <code>true</code> if at least one valid hook method was found on this interceptor 035 */ 036 boolean registerInterceptor(Object theInterceptor); 037 038 /** 039 * Unregister an interceptor. This method has no effect if the given interceptor is not already registered. 040 * 041 * @param theInterceptor The interceptor to unregister 042 * @return Returns <code>true</code> if the interceptor was found and removed 043 */ 044 boolean unregisterInterceptor(Object theInterceptor); 045 046 /** 047 * Returns all currently registered interceptors (excluding any thread local interceptors). 048 */ 049 List<Object> getAllRegisteredInterceptors(); 050 051 /** 052 * Unregisters all registered interceptors. 053 */ 054 void unregisterAllInterceptors(); 055 056 void unregisterInterceptors(@Nullable Collection<?> theInterceptors); 057 058 void registerInterceptors(@Nullable Collection<?> theInterceptors); 059 060 /** 061 * Unregisters all interceptors that are indicated by the given callback function returning <code>true</code> 062 */ 063 void unregisterInterceptorsIf(Predicate<Object> theShouldUnregisterFunction); 064 065 /** 066 * Unregisters all anonymous interceptors (i.e. all interceptors registered with <code>registerAnonymousInterceptor</code>) 067 */ 068 void unregisterAllAnonymousInterceptors(); 069}