com.fitbur.mockito.plugins.InstantiatorProvider Maven / Gradle / Ivy
/*
* Copyright (c) 2007 Mockito contributors
* This program is made available under the terms of the MIT License.
*/
package com.fitbur.mockito.plugins;
import com.fitbur.mockito.internal.creation.instance.Instantiator;
import com.fitbur.mockito.mock.MockCreationSettings;
/**
*
* Mockito will invoke this interface in order to fetch an instance instantiator provider.
*
*
*
* By default, an internal byte-buddy/asm/objenesis based implementation is used.
*
*
* Using the extension point
*
*
* The plugin mechanism of mockito works in a similar way as the
* {@link java.util.ServiceLoader}, however instead of looking in the META-INF
* directory, Mockito will look in mockito-extensions
directory.
* The reason for that is that Android SDK strips jar from the META-INF
* directory when creating an APK.
*
*
*
* - The implementation itself, for example
*
org.awesome.mockito.AwesomeInstantiatorProvider
that implements the
* InstantiatorProvider
.
* - A file "
mockito-extensions/com.fitbur.mockito.plugins.InstantiatorProvider
".
* The content of this file is exactly a one line with the qualified
* name: org.awesome.mockito.AwesomeInstantiatorProvider
.
*
*
*
* Note that if several mockito-extensions/com.fitbur.mockito.plugins.InstantiatorProvider
* files exists in the classpath, Mockito will only use the first returned by the standard
* {@link ClassLoader#getResource} mechanism.
*
* So just create a custom implementation of {@link InstantiatorProvider} and place the
* qualified name in the following file
* mockito-extensions/com.fitbur.mockito.plugins.InstantiatorProvider
.
*
*
* @since 21.10.15
*/
public interface InstantiatorProvider {
/**
* Returns an instantiator, used to create new class instances.
*/
Instantiator getInstantiator(MockCreationSettings> settings);
}