001/** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.isis.core.metamodel.runtimecontext; 018 019import java.util.List; 020 021import org.apache.isis.applib.services.exceprecog.ExceptionRecognizer; 022import org.apache.isis.applib.services.publish.PublishingService; 023import org.apache.isis.core.commons.components.Injectable; 024 025public interface ServicesInjector extends Injectable { 026 027 /** 028 * All registered services, as an immutable {@link List}. 029 * 030 * <p> 031 * Does not include the {@link #getContainer() container}. 032 */ 033 List<Object> getRegisteredServices(); 034 035 /** 036 * Provided by the <tt>ServicesInjectorDefault</tt> when used by framework. 037 * 038 * <p> 039 * Called in multiple places from metamodel and facets. 040 */ 041 void injectServicesInto(final Object domainObject); 042 043 /** 044 * As per {@link #injectServicesInto(Object)}, but for all objects in the 045 * list. 046 */ 047 void injectServicesInto(List<Object> objects); 048 049 /** 050 * Returns the first registered domain service implementing the requested type. 051 * 052 * <p> 053 * Typically there will only ever be one domain service implementing a given type, 054 * (eg {@link PublishingService}), but for some services there can be more than one 055 * (eg {@link ExceptionRecognizer}). 056 * 057 * @see #lookupServices(Class) 058 */ 059 <T> T lookupService(Class<T> serviceClass); 060 061 /** 062 * Returns all domain services implementing the requested type, in the order 063 * that they were registered in <tt>isis.properties</tt>. 064 * 065 * <p> 066 * Typically there will only ever be one domain service implementing a given type, 067 * (eg {@link PublishingService}), but for some services there can be more than one 068 * (eg {@link ExceptionRecognizer}). 069 * 070 * @see #lookupService(Class) 071 */ 072 <T> List<T> lookupServices(Class<T> serviceClass); 073}