1 /* 2 * Copyright (c) 2007 Mockito contributors 3 * This program is made available under the terms of the MIT License. 4 */ 5 package org.mockito.plugins; 6 7 import org.mockito.internal.creation.instance.Instantiator; 8 import org.mockito.mock.MockCreationSettings; 9 10 /** 11 * @deprecated since 2.15.4 because this internal class was leaking from the public API. 12 * For more information why deprecated, see {@link org.mockito.plugins.InstantiatorProvider2} and 13 * <a href="https://github.com/mockito/mockito/issues/1303">Issue 1303</a> 14 * 15 * <p> 16 * Mockito will invoke this interface in order to fetch an instance instantiator provider. 17 * </p> 18 * 19 * <p> 20 * By default, an internal byte-buddy/asm/objenesis based implementation is used. 21 * </p> 22 * 23 * <h3>Using the extension point</h3> 24 * 25 * <p> 26 * The plugin mechanism of mockito works in a similar way as the 27 * {@link java.util.ServiceLoader}, however instead of looking in the <code>META-INF</code> 28 * directory, Mockito will look in <code>mockito-extensions</code> directory. 29 * <em>The reason for that is that Android SDK strips jar from the <code>META-INF</code> 30 * directory when creating an APK.</em> 31 * </p> 32 * 33 * <ol style="list-style-type: lower-alpha"> 34 * <li>The implementation itself, for example 35 * <code>org.awesome.mockito.AwesomeInstantiatorProvider</code> that implements the 36 * <code>InstantiatorProvider</code>.</li> 37 * <li>A file "<code>mockito-extensions/org.mockito.plugins.InstantiatorProvider</code>". 38 * The content of this file is exactly a <strong>one</strong> line with the qualified 39 * name: <code>org.awesome.mockito.AwesomeInstantiatorProvider</code>.</li> 40 * </ol></p> 41 * 42 * <p> 43 * Note that if several <code>mockito-extensions/org.mockito.plugins.InstantiatorProvider</code> 44 * files exists in the classpath, Mockito will only use the first returned by the standard 45 * {@link ClassLoader#getResource} mechanism. 46 * <p> 47 * So just create a custom implementation of {@link InstantiatorProvider} and place the 48 * qualified name in the following file 49 * <code>mockito-extensions/org.mockito.plugins.InstantiatorProvider</code>. 50 * </p> 51 * <p> 52 * This class is deprecated and was replaced by 53 * {@link org.mockito.plugins.InstantiatorProvider2}. Hence if there is both a 54 * <code>mockito-extensions/org.mockito.plugins.InstantiatorProvider</code> and 55 * <code>mockito-extensions/org.mockito.plugins.InstantiatorProvider2</code> the second one 56 * takes preference. 57 * </p> 58 * 59 * @since 2.0.31 60 */ 61 @Deprecated 62 public interface InstantiatorProvider { 63 64 /** 65 * @deprecated, see {@link InstantiatorProvider}. 66 * 67 * Returns an instantiator, used to create new class instances. 68 */ 69 @Deprecated getInstantiator(MockCreationSettings<?> settings)70 Instantiator getInstantiator(MockCreationSettings<?> settings); 71 } 72