コード例 #1
1
 public Container buildContainer(String containerClass) {
   notNull(
       containerClass,
       "Container type " + Arrays.deepToString(Server.values()) + " or container class");
   Class<Container> clazz = null;
   for (Server container : Server.values()) {
     if (container.name().equalsIgnoreCase(containerClass)) {
       clazz = loadServerClass(container.serverClass());
       break;
     }
   }
   if (clazz == null) clazz = loadServerClass(containerClass);
   try {
     return clazz
         .getConstructor(ContainerConfiguration.class)
         .newInstance(ContainerConfiguration.from(this));
   } catch (InvocationTargetException e) {
     if (e.getTargetException() instanceof RuntimeException)
       throw (RuntimeException) e.getTargetException();
     else throw new RuntimeException(e.getTargetException().getMessage(), e.getTargetException());
   } catch (Exception e) {
     throw new IllegalArgumentException(
         "Cannot instanciate class ["
             + clazz
             + "]. Ensure there is a public constructor having a parameter of type "
             + ContainerConfiguration.class.getName(),
         e);
   }
 }
コード例 #2
0
 public Container buildContainer(Server type) {
   return buildContainer(type.serverClass());
 }