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      /**
11       * Creates the object by instantiating the default constructor
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      {
18          try
19          {
20              return moduleClass.newInstance();
21          }
22          catch (InstantiationException e)
23          {
24              throw new IllegalArgumentException("Unable to instantiate constructor", e);
25          }
26          catch (IllegalAccessException e)
27          {
28              throw new IllegalArgumentException("Unable to access constructor", e);
29          }
30      }
31  }