@Override public ServiceDescriptor init(ServiceContext context) throws Exception { valueTypes.addAll(ValueType.DEFAULT); for (ValueType<?> valueType : Tools.loadService(ValueType.class, context.getClassLoader())) { valueTypes.add(valueType); } return descriptor = new ControllersDescriptor(context.getClassLoader(), context.getConfig()); }
@Override public ServiceDescriptor init(ServiceContext context) throws Exception { valueTypes.addAll(ValueType.DEFAULT); for (ValueType<?> valueType : Tools.loadService(ValueType.class, context.getClassLoader())) { valueTypes.add(valueType); } return descriptor = new ControllersDescriptor(context.getClassLoader(), context.getConfig()); }
@Test public void testLoadService() { Iterable<ServiceA> iterableServiceA = Tools.loadService(ServiceA.class, getClass().getClassLoader()); assertFalse("ServiceA shouldn't have a known service impl", iterableServiceA.iterator().hasNext()); List<Class<? extends ServiceB>> serviceBImpls = new ArrayList<Class<? extends ServiceB>>(); serviceBImpls.add(ServiceBImpl1.class); serviceBImpls.add(ServiceBImpl2.class); serviceBImpls.add(ServiceBImpl3.class); Iterable<ServiceB> iterableServiceB = Tools.loadService(ServiceB.class, getClass().getClassLoader()); int count = 0; for (ServiceB serviceB : iterableServiceB) { assertNotNull("Returned Service is null", serviceB); serviceBImpls.remove(serviceB.getClass()); count++; } assertEquals("Returned services missed service of type: " + serviceBImpls, 0, serviceBImpls.size()); assertEquals("Services count is different than expected", 3, count); }
@Test public void testLoadService() { Iterable<ServiceA> iterableServiceA = Tools.loadService(ServiceA.class, getClass().getClassLoader()); assertFalse("ServiceA shouldn't have a known service impl", iterableServiceA.iterator().hasNext()); List<Class<? extends ServiceB>> serviceBImpls = new ArrayList<Class<? extends ServiceB>>(); serviceBImpls.add(ServiceBImpl1.class); serviceBImpls.add(ServiceBImpl2.class); serviceBImpls.add(ServiceBImpl3.class); Iterable<ServiceB> iterableServiceB = Tools.loadService(ServiceB.class, getClass().getClassLoader()); int count = 0; for (ServiceB serviceB : iterableServiceB) { assertNotNull("Returned Service is null", serviceB); serviceBImpls.remove(serviceB.getClass()); count++; } assertEquals("Returned services missed service of type: " + serviceBImpls, 0, serviceBImpls.size()); assertEquals("Services count is different than expected", 3, count); }
for (EntityUnmarshaller reader : Tools.loadService(EntityUnmarshaller.class, request.controllerPlugin.getApplication().getClassLoader())) { try { if (reader.accept(mediaType)) {
for (EntityUnmarshaller reader : Tools.loadService(EntityUnmarshaller.class, request.controllerPlugin.getApplication().getClassLoader())) { try { if (reader.accept(mediaType)) {
for (EntityMarshaller writer : Tools.loadService(EntityMarshaller.class, request.controllerPlugin.getApplication().getClassLoader())) { for (String s : mimeType.value()) { Streamable streamable = writer.marshall(s, context.getHandler().getMethod(), ret);
for (EntityMarshaller writer : Tools.loadService(EntityMarshaller.class, request.controllerPlugin.getApplication().getClassLoader())) { for (String s : mimeType.value()) { Streamable streamable = writer.marshall(s, context.getHandler().getMethod(), ret);