/*
 * Copyright 2011-2015 B2i Healthcare Pte Ltd, http://b2i.sg
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.b2international.snowowl.core;

import com.google.inject.Provider;

/**
 * @since 4.5
 */
public interface ServiceProvider {

	/**
	 * Returns the given service or throws an exception if none found in the current {@link ApplicationContext}.
	 * 
	 * @param type
	 * @return the currently registered service implementation for the given service interface, never <code>null</code>
	 */
	<T> T service(Class<T> type);

	/**
	 * Returns a {@link Provider} to provide the given type when needed by using {@link #service(Class)}, so the returned {@link Provider} will never
	 * return <code>null</code> instances, instead it throws exception, which may indicate application bootstrapping/initialization problems.
	 * 
	 * @param type
	 * @return
	 */
	<T> Provider<T> provider(Class<T> type);

}

@@ -664,16 +664,72 @@
 .core;%0A%0A
+import com.b2international.snowowl.core.events.Request;%0A
 import c
@@ -1476,10 +1476,594 @@
 type);%0A%0A
+%09/**%0A%09 * Empty %7B@link ServiceProvider%7D implementation that throws %7B@link UnsupportedOperationException%7Ds when trying to provide services. Useful when%0A%09 * testing %7B@link Request%7D implementations.%0A%09 * %0A%09 * @since 5.4%0A%09 */%0A%09ServiceProvider EMPTY = new ServiceProvider() %7B%0A%09%09@Override%0A%09%09public %3CT%3E T service(Class%3CT%3E type) %7B%0A%09%09%09throw new UnsupportedOperationException(%22Empty service provider can't provide services%22);%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public %3CT%3E Provider%3CT%3E provider(Class%3CT%3E type) %7B%0A%09%09%09throw new UnsupportedOperationException(%22Empty service provider can't provide services%22);%0A%09%09%7D%0A%09%7D;%0A%0A
 %7D%0A

add empty ServiceProvider implementation