@Test public void run() { try (final SeContainer container = SeContainerInitializer.newInstance() .addProperty("httpPort", new Meecrowave.Builder().randomHttpPort().getHttpPort()) .disableDiscovery() .addBeanClasses(Configured.class) .initialize()) { final Client client = ClientBuilder.newClient(); assertNotNull(container.select(Meecrowave.class).get()); assertEquals("configured", client .target(String.format("http: .request(TEXT_PLAIN_TYPE) .get(String.class)); } }
@Override public SeContainerInitializer addProperty(final String s, final Object o) { if (Configuration.class.isInstance(o)) { builder = Configuration.class.cast(o); return this; } final String setter = "set" + Character.toUpperCase(s.charAt(0)) + s.substring(1); final Class<? extends Configuration> builderClass = builder.getClass(); final Optional<Method> setterOpt = Stream.of(Configuration.class.getMethods()) .filter(m -> m.getName().equals(setter) && m.getParameterCount() == 1) .findFirst(); if (!setterOpt.isPresent()) { super.addProperty(s, o); return this; } try { builderClass.getMethod(setter, o.getClass()).invoke(builder, o); } catch (final NoSuchMethodException nsme) { if (Integer.class.isInstance(o)) { try { builderClass.getMethod(setter, int.class).invoke(builder, o); } catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { throw new IllegalArgumentException(nsme); } } else if (Long.class.isInstance(o)) { try { builderClass.getMethod(setter, long.class).invoke(builder, o); } catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { throw new IllegalArgumentException(nsme); } } else if (Boolean.class.isInstance(o)) { try { builderClass.getMethod(setter, boolean.class).invoke(builder, o); } catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { throw new IllegalArgumentException(nsme); } } else { throw new IllegalArgumentException(nsme); } } catch (final IllegalAccessException | InvocationTargetException ex) { throw new IllegalArgumentException(ex); } return this; }
MeecrowaveSeContainerInitializer extends OWBInitializer { @Override public SeContainerInitializer addProperty(final String s, final Object o) { if (Configuration.class.isInstance(o)) { builder = Configuration.class.cast(o); return this; } final String setter = "set" + Character.toUpperCase(s.charAt(0)) + s.substring(1); final Class<? extends Configuration> builderClass = builder.getClass(); final Optional<Method> setterOpt = Stream.of(Configuration.class.getMethods()) .filter(m -> m.getName().equals(setter) && m.getParameterCount() == 1) .findFirst(); if (!setterOpt.isPresent()) { super.addProperty(s, o); return this; } try { builderClass.getMethod(setter, o.getClass()).invoke(builder, o); } catch (final NoSuchMethodException nsme) { if (Integer.class.isInstance(o)) { try { builderClass.getMethod(setter, int.class).invoke(builder, o); } catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { throw new IllegalArgumentException(nsme); } } else if (Long.class.isInstance(o)) { try { builderClass.getMethod(setter, long.class).invoke(builder, o); } catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { throw new IllegalArgumentException(nsme); } } else if (Boolean.class.isInstance(o)) { try { builderClass.getMethod(setter, boolean.class).invoke(builder, o); } catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { throw new IllegalArgumentException(nsme); } } else { throw new IllegalArgumentException(nsme); } } catch (final IllegalAccessException | InvocationTargetException ex) { throw new IllegalArgumentException(ex); } return this; } }
MeecrowaveSeContainerInitializer extends OWBInitializer { @Override public SeContainerInitializer addProperty(final String s, final Object o) { if (Configuration.class.isInstance(o)) { builder = Configuration.class.cast(o); return this; } final String setter = "set" + Character.toUpperCase(s.charAt(0)) + s.substring(1); final Class<? extends Configuration> builderClass = builder.getClass(); final Optional<Method> setterOpt = Stream.of(Configuration.class.getMethods()) .filter(m -> m.getName().equals(setter) && m.getParameterCount() == 1) .findFirst(); if (!setterOpt.isPresent()) { super.addProperty(s, o); return this; } try { builderClass.getMethod(setter, o.getClass()).invoke(builder, o); } catch (final NoSuchMethodException nsme) { if (Integer.class.isInstance(o)) { try { builderClass.getMethod(setter, int.class).invoke(builder, o); } catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { throw new IllegalArgumentException(nsme); } } else if (Long.class.isInstance(o)) { try { builderClass.getMethod(setter, long.class).invoke(builder, o); } catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { throw new IllegalArgumentException(nsme); } } else if (Boolean.class.isInstance(o)) { try { builderClass.getMethod(setter, boolean.class).invoke(builder, o); } catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { throw new IllegalArgumentException(nsme); } } else { throw new IllegalArgumentException(nsme); } } catch (final IllegalAccessException | InvocationTargetException ex) { throw new IllegalArgumentException(ex); } return this; }  }
MeecrowaveSeContainerInitializer extends OWBInitializer { @Override public SeContainerInitializer addProperty(final String s, final Object o) { if (Configuration.class.isInstance(o)) { builder = Configuration.class.cast(o); return this; } final String setter = "set" + Character.toUpperCase(s.charAt(0)) + s.substring(1); final Class<? extends Configuration> builderClass = builder.getClass(); final Optional<Method> setterOpt = Stream.of(Configuration.class.getMethods()) .filter(m -> m.getName().equals(setter) && m.getParameterCount() == 1) .findFirst(); if (!setterOpt.isPresent()) { super.addProperty(s, o); return this; } try { builderClass.getMethod(setter, o.getClass()).invoke(builder, o); } catch (final NoSuchMethodException nsme) { if (Integer.class.isInstance(o)) { try { builderClass.getMethod(setter, int.class).invoke(builder, o); } catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { throw new IllegalArgumentException(nsme); } } else if (Long.class.isInstance(o)) { try { builderClass.getMethod(setter, long.class).invoke(builder, o); } catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { throw new IllegalArgumentException(nsme); } } else if (Boolean.class.isInstance(o)) { try { builderClass.getMethod(setter, boolean.class).invoke(builder, o); } catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { throw new IllegalArgumentException(nsme); } } else { throw new IllegalArgumentException(nsme); } } catch (final IllegalAccessException | InvocationTargetException ex) { throw new IllegalArgumentException(ex); } return this; }  @Override SeContainerInitializer addProperty(final String s, final Object o); }
MeecrowaveSeContainerInitializer extends OWBInitializer { @Override public SeContainerInitializer addProperty(final String s, final Object o) { if (Configuration.class.isInstance(o)) { builder = Configuration.class.cast(o); return this; } final String setter = "set" + Character.toUpperCase(s.charAt(0)) + s.substring(1); final Class<? extends Configuration> builderClass = builder.getClass(); final Optional<Method> setterOpt = Stream.of(Configuration.class.getMethods()) .filter(m -> m.getName().equals(setter) && m.getParameterCount() == 1) .findFirst(); if (!setterOpt.isPresent()) { super.addProperty(s, o); return this; } try { builderClass.getMethod(setter, o.getClass()).invoke(builder, o); } catch (final NoSuchMethodException nsme) { if (Integer.class.isInstance(o)) { try { builderClass.getMethod(setter, int.class).invoke(builder, o); } catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { throw new IllegalArgumentException(nsme); } } else if (Long.class.isInstance(o)) { try { builderClass.getMethod(setter, long.class).invoke(builder, o); } catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { throw new IllegalArgumentException(nsme); } } else if (Boolean.class.isInstance(o)) { try { builderClass.getMethod(setter, boolean.class).invoke(builder, o); } catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { throw new IllegalArgumentException(nsme); } } else { throw new IllegalArgumentException(nsme); } } catch (final IllegalAccessException | InvocationTargetException ex) { throw new IllegalArgumentException(ex); } return this; }  @Override SeContainerInitializer addProperty(final String s, final Object o);  }