private ModuleItem<?> getSingleInput(final Module module, final Class<?> type) { if (moduleService == null || convertService == null) return null; // Check the actual class first ModuleItem<?> item = moduleService.getSingleInput(module, type); if (item == null || !item.isAutoFill()) { // No match, so check look for classes that can be converted from the specified type final Collection<Class<?>> compatibleClasses = convertService.getCompatibleOutputClasses(type); item = moduleService.getSingleInput(module, compatibleClasses); } if (item == null || !item.isAutoFill()) return null; return item; }
/** * Helper method to look up the name of singleton module inputs of a given * type. * * @param module Module to check for single input * @param type Type of single input to look for * @return If the given module has exactly one input of the specified type, * return that input's name. Otherwise null; */ protected String getSingleInput(final Module module, final Class<?> type) { if (moduleService == null) return null; final ModuleItem<?> item = moduleService.getSingleInput(module, type); if (item == null || !item.isAutoFill()) return null; return item.getName(); }
/** * Helper method to look up the name of singleton module inputs of a given * type. * * @param module Module to check for single input * @param type Type of single input to look for * @return If the given module has exactly one input of the specified type, * return that input's name. Otherwise null; */ protected String getSingleInput(final Module module, final Class<?> type) { if (moduleService == null) return null; final ModuleItem<?> item = moduleService.getSingleInput(module, type); if (item == null || !item.isAutoFill()) return null; return item.getName(); }
private ModuleItem<?> getSingleItem(final Module module, final Collection<Class<?>> types, final Iterable<ModuleItem<?>> items) { ModuleItem<?> result = null; for (final ModuleItem<?> item : items) { final String name = item.getName(); final boolean resolved = module.isInputResolved(name); if (resolved) continue; // skip resolved inputs if (!item.isAutoFill()) continue; // skip unfillable inputs final Class<?> itemType = item.getType(); for (final Class<?> type : types) { if (type.isAssignableFrom(itemType)) { if (result != null) return null; // multiple matching module items result = item; // This module item matches, so no need to check more classes. break; } } } return result; }
private ModuleItem<?> getSingleItem(final Module module, final Collection<Class<?>> types, final Iterable<ModuleItem<?>> items) { ModuleItem<?> result = null; for (final ModuleItem<?> item : items) { final String name = item.getName(); final boolean resolved = module.isInputResolved(name); if (resolved) continue; // skip resolved inputs if (!item.isAutoFill()) continue; // skip unfillable inputs final Class<?> itemType = item.getType(); for (final Class<?> type : types) { if (type.isAssignableFrom(itemType)) { if (result != null) return null; // multiple matching module items result = item; // This module item matches, so no need to check more classes. break; } } } return result; }
@Override public void process(final Module module) { if (logService == null || moduleService == null) return; final ModuleItem<?> loggerInput = moduleService.getSingleInput(module, Logger.class); if (loggerInput == null || !loggerInput.isAutoFill()) return; String loggerName = loggerInput.getLabel(); if(loggerName == null || loggerName.isEmpty()) loggerName = module.getDelegateObject().getClass().getSimpleName(); Logger logger = logService.subLogger(loggerName); final String name = loggerInput.getName(); module.setInput(name, logger); module.resolveInput(name); }
@Override public void process(final Module module) { if (logService == null || moduleService == null) return; final ModuleItem<?> loggerInput = moduleService.getSingleInput(module, Logger.class); if (loggerInput == null || !loggerInput.isAutoFill()) return; String loggerName = loggerInput.getLabel(); if(loggerName == null || loggerName.isEmpty()) loggerName = module.getDelegateObject().getClass().getSimpleName(); Logger logger = logService.subLogger(loggerName); final String name = loggerInput.getName(); module.setInput(name, logger); module.resolveInput(name); }
@Override public void process(final Module module) { for (final ModuleItem<?> input : module.getInfo().inputs()) { if (!input.isAutoFill()) continue; // cannot auto-fill this input final Class<?> type = input.getType(); if (Gateway.class.isAssignableFrom(type)) { // input is a gateway @SuppressWarnings("unchecked") final ModuleItem<? extends Gateway> gatewayInput = (ModuleItem<? extends Gateway>) input; setGatewayValue(getContext(), module, gatewayInput); } } }
@Override public void process(final Module module) { for (final ModuleItem<?> input : module.getInfo().inputs()) { if (!input.isAutoFill()) continue; // cannot auto-fill this input final Class<?> type = input.getType(); if (Gateway.class.isAssignableFrom(type)) { // input is a gateway @SuppressWarnings("unchecked") final ModuleItem<? extends Gateway> gatewayInput = (ModuleItem<? extends Gateway>) input; setGatewayValue(getContext(), module, gatewayInput); } } }
@Override public void process(final Module module) { if (uiService == null) return; // no UI service available final UserInterface ui = uiService.getDefaultUI(); if (ui == null) return; // no default UI for (final ModuleItem<?> input : module.getInfo().inputs()) { if (!input.isAutoFill()) continue; // cannot auto-fill this input final Class<?> type = input.getType(); if (type.isAssignableFrom(ui.getClass())) { // input is a compatible UI final String name = input.getName(); module.setInput(name, ui); module.resolveInput(name); } } }
@Override public void process(final Module module) { if (uiService == null) return; // no UI service available final UserInterface ui = uiService.getDefaultUI(); if (ui == null) return; // no default UI for (final ModuleItem<?> input : module.getInfo().inputs()) { if (!input.isAutoFill()) continue; // cannot auto-fill this input final Class<?> type = input.getType(); if (type.isAssignableFrom(ui.getClass())) { // input is a compatible UI final String name = input.getName(); module.setInput(name, ui); module.resolveInput(name); } } }
@Override public void process(final Module module) { for (final ModuleItem<?> input : module.getInfo().inputs()) { if (!input.isAutoFill()) continue; // cannot auto-fill this input final Class<?> type = input.getType(); if (Service.class.isAssignableFrom(type)) { // input is a service @SuppressWarnings("unchecked") final ModuleItem<? extends Service> serviceInput = (ModuleItem<? extends Service>) input; setServiceValue(getContext(), module, serviceInput); } if (type.isAssignableFrom(getContext().getClass())) { // input is a compatible context final String name = input.getName(); module.setInput(name, getContext()); module.resolveInput(name); } } }
@Override public void process(final Module module) { for (final ModuleItem<?> input : module.getInfo().inputs()) { if (!input.isAutoFill()) continue; // cannot auto-fill this input final Class<?> type = input.getType(); if (Service.class.isAssignableFrom(type)) { // input is a service @SuppressWarnings("unchecked") final ModuleItem<? extends Service> serviceInput = (ModuleItem<? extends Service>) input; setServiceValue(getContext(), module, serviceInput); } if (type.isAssignableFrom(getContext().getClass())) { // input is a compatible context final String name = input.getName(); module.setInput(name, getContext()); module.resolveInput(name); } } }
@Override public void process(final Module module) { if (displayService == null || moduleService == null) return; final ModuleItem<?> displayInput = moduleService.getSingleInput(module, Display.class); if (displayInput == null || !displayInput.isAutoFill()) return; @SuppressWarnings("unchecked") final Class<? extends Display<?>> displayType = (Class<? extends Display<?>>) displayInput.getType(); final Display<?> activeDisplay = displayService.getActiveDisplay(displayType); if (activeDisplay == null) return; final String name = displayInput.getName(); module.setInput(name, activeDisplay); module.resolveInput(name); }
@Override public void process(final Module module) { if (displayService == null || moduleService == null) return; final ModuleItem<?> displayInput = moduleService.getSingleInput(module, Display.class); if (displayInput == null || !displayInput.isAutoFill()) return; @SuppressWarnings("unchecked") final Class<? extends Display<?>> displayType = (Class<? extends Display<?>>) displayInput.getType(); final Display<?> activeDisplay = displayService.getActiveDisplay(displayType); if (activeDisplay == null) return; final String name = displayInput.getName(); module.setInput(name, activeDisplay); module.resolveInput(name); }