1 package com.atlassian.pageobjects.inject;
2
3 import com.atlassian.annotations.ExperimentalApi;
4
5 /**
6 * <p/>
7 * 'Builder'-style API for configuring {@link com.atlassian.pageobjects.inject.ConfigurableInjectionContext}s.
8 *
9 * <p/>
10 * The modifications to configuration done via calling the 'add'-style methods are committed by calling
11 *
12 * @since 1.2
13 */
14 @ExperimentalApi
15 public interface InjectionConfiguration
16 {
17
18 /**
19 * Add mapping from interface to a concrete implementation.
20 *
21 * @param interfaceType specifies the interface
22 * @param implementationType specifies the implementation of <tt>interfaceType</tt>
23 * @param <I> type parameter of the interface
24 * @return this configuration module
25 */
26 public <I> InjectionConfiguration addImplementation(Class<I> interfaceType, Class<? extends I> implementationType);
27
28
29 /**
30 * Add mapping from a type to a singleton instance of this type that shall be used for injection in given context.
31 *
32 * @param type component type
33 * @param instance implementing singleton instance
34 * @param <C> type component of the component
35 * @param <I> type parameter of the implementing instance
36 * @return this configuration module
37 */
38 public <C,I extends C> InjectionConfiguration addSingleton(Class<I> type, I instance);
39
40 // we might want to extend it in the future to cover scopes et al.
41
42
43 /**
44 * <p/>
45 * Finish the configuration and retrieve the resulting injection context instance.
46 *
47 * <p/>
48 * The resulting instance might be the same instance that this configuration object was originally retrieved from,
49 * or a new instance with updated configuration - depending on the mutability of the injection context
50 * implementation.
51 *
52 * @return the resulting injection context
53 */
54 public ConfigurableInjectionContext finish();
55 }