View Javadoc

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