View Javadoc

1   package com.atlassian.pageobjects.inject;
2   
3   import com.atlassian.annotations.ExperimentalApi;
4   
5   import javax.annotation.Nonnull;
6   
7   /**
8    * Simple interface for framework components capable of injection of components as described by JSR-330.
9    *
10   * @since 2.1
11   */
12  @ExperimentalApi
13  public interface InjectionContext
14  {
15  
16      /**
17       * Get an instance of given <tt>type</tt> from context.
18       *
19       * @param type type of the requested instance
20       * @param <T> type param
21       * @return an instance of requested type. An exception may be raised if the context is unable to instantiate
22       * given <tt>type</tt>.
23       * @throws IllegalArgumentException if instantiating given class according to JSR-330 rules was impossible
24       */
25      @Nonnull
26      <T> T getInstance(@Nonnull Class<T> type);
27  
28      /**
29       * Execute injection of static fields on given <tt>targetClass</tt>.
30       *
31       * @param targetClass class to inject into
32       */
33      public void injectStatic(@Nonnull Class<?> targetClass);
34  
35  
36      /**
37       * Execute injection of fields on given <tt>targetInstance</tt>
38       *
39       * @param targetInstance instance to inject into
40       */
41      public void injectMembers(@Nonnull Object targetInstance);
42  }