ClassUtil { public static List<Object> generateSingletons(String[] resourceIntfs, InboundHandler handler) throws Exception { List<Object> instances = new ArrayList<Object>(); for (String resourceIntf : resourceIntfs) { if (LOGGER.isTraceEnabled()) { LOGGER.trace("Generating instance for " + resourceIntf); } Class<?> clazz = Classes.forName(resourceIntf); Boolean multiParams = false; for (Method method : clazz.getMethods()) { if (method.getParameterTypes().length > 1) { multiParams = true; break; } } if (multiParams) { RestEasyLogger.ROOT_LOGGER.defaultRESTEasyMessageComposerDoesnTHandleMultipleInputParameters(clazz.getName()); } Object instance = RESTEasyProxy.newInstance(handler, clazz); instances.add(instance); } return instances; } private  ClassUtil(); static List<Object> generateSingletons(String[] resourceIntfs, InboundHandler handler);  }
@Test public void generateClassInstances() throws Exception { String[] intfs = {"org.switchyard.component.resteasy.util.support.WarehouseResource"}; Object instance = ClassUtil.generateSingletons(intfs, this).get(0); Method method = instance.getClass().getMethod("getItem", Integer.class); Item response = (Item)method.invoke(instance, 1); Item apple = new Item(1, "Apple"); Assert.assertTrue(response.equals(apple)); method = instance.getClass().getMethod("addItem", Item.class); Item orange = new Item(2, "Orange"); Assert.assertEquals("[2:Orange]", method.invoke(instance, orange)); method = instance.getClass().getMethod("updateItem", Item.class); Item grape = new Item(2, "Grape"); Assert.assertEquals("[2:Grape]", method.invoke(instance, grape)); method = instance.getClass().getMethod("removeItem", Integer.class); method = instance.getClass().getMethod("getItemCount"); Assert.assertEquals(0, method.invoke(instance)); method = instance.getClass().getMethod("testVoid"); method.invoke(instance); }