View Javadoc
1   package com.atlassian.plugin.hostcontainer;
2   
3   /**
4    * Simple host container that instantiates classes directly.
5    *
6    * @since 2.2.0
7    */
8   public class DefaultHostContainer implements HostContainer {
9       /**
10       * Creates the object by instantiating the default constructor
11       *
12       * @param moduleClass The class to create
13       * @return The instance
14       * @throws IllegalArgumentException If the constructor couldn't be called successfully
15       */
16      public <T> T create(Class<T> moduleClass) throws IllegalArgumentException {
17          try {
18              return moduleClass.newInstance();
19          } catch (InstantiationException e) {
20              throw new IllegalArgumentException("Unable to instantiate constructor", e);
21          } catch (IllegalAccessException e) {
22              throw new IllegalArgumentException("Unable to access constructor", e);
23          }
24      }
25  }