Search in sources :

Example 6 with ControllerMVCResponseService

use of org.springframework.roo.addon.web.mvc.controller.addon.responses.ControllerMVCResponseService in project spring-roo by spring-projects.

the class WebFinderCommands method getInstalledControllerMVCResponseTypes.

/**
 * This method gets all implementations of ControllerMVCResponseService interface to be able
 * to locate all installed ControllerMVCResponseService
 *
 * @return Map with responseTypes identifier and the ControllerMVCResponseService implementation
 */
public Map<String, ControllerMVCResponseService> getInstalledControllerMVCResponseTypes() {
    if (responseTypes.isEmpty()) {
        try {
            ServiceReference<?>[] references = this.context.getAllServiceReferences(ControllerMVCResponseService.class.getName(), null);
            for (ServiceReference<?> ref : references) {
                ControllerMVCResponseService responseTypeService = (ControllerMVCResponseService) this.context.getService(ref);
                boolean isInstalled = false;
                for (Pom module : getProjectOperations().getPoms()) {
                    if (responseTypeService.isInstalledInModule(module.getModuleName())) {
                        isInstalled = true;
                        break;
                    }
                }
                if (isInstalled) {
                    responseTypes.put(responseTypeService.getResponseType(), responseTypeService);
                }
            }
            return responseTypes;
        } catch (InvalidSyntaxException e) {
            LOGGER.warning("Cannot load ControllerMVCResponseService on ControllerCommands.");
            return null;
        }
    } else {
        return responseTypes;
    }
}
Also used : ControllerMVCResponseService(org.springframework.roo.addon.web.mvc.controller.addon.responses.ControllerMVCResponseService) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) ServiceReference(org.osgi.framework.ServiceReference) Pom(org.springframework.roo.project.maven.Pom)

Example 7 with ControllerMVCResponseService

use of org.springframework.roo.addon.web.mvc.controller.addon.responses.ControllerMVCResponseService in project spring-roo by spring-projects.

the class I18nOperationsImpl method getControllerMVCResponseTypes.

/**
 * This method gets all implementations of ControllerMVCResponseService
 * interface to be able to locate all ControllerMVCResponseService. Uses
 * param installed to obtain only the installed or not installed response
 * types.
 *
 * @param installed
 *            indicates if returned responseType should be installed or not.
 *
 * @return Map with responseTypes identifier and the
 *         ControllerMVCResponseService implementation
 */
private List<ControllerMVCResponseService> getControllerMVCResponseTypes(boolean installed) {
    List<ControllerMVCResponseService> responseTypes = new ArrayList<ControllerMVCResponseService>();
    try {
        ServiceReference<?>[] references = this.context.getAllServiceReferences(ControllerMVCResponseService.class.getName(), null);
        for (ServiceReference<?> ref : references) {
            ControllerMVCResponseService responseTypeService = (ControllerMVCResponseService) this.context.getService(ref);
            boolean isAbleToInstall = false;
            for (Pom module : getProjectOperations().getPoms()) {
                if (responseTypeService.isInstalledInModule(module.getModuleName()) == installed) {
                    isAbleToInstall = true;
                    break;
                }
            }
            if (isAbleToInstall) {
                responseTypes.add(responseTypeService);
            }
        }
        return responseTypes;
    } catch (InvalidSyntaxException e) {
        LOGGER.warning("Cannot load ControllerMVCResponseService on I18nOperationsImpl.");
        return null;
    }
}
Also used : ControllerMVCResponseService(org.springframework.roo.addon.web.mvc.controller.addon.responses.ControllerMVCResponseService) ArrayList(java.util.ArrayList) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) ServiceReference(org.osgi.framework.ServiceReference) Pom(org.springframework.roo.project.maven.Pom)

Aggregations

ControllerMVCResponseService (org.springframework.roo.addon.web.mvc.controller.addon.responses.ControllerMVCResponseService)7 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)5 ServiceReference (org.osgi.framework.ServiceReference)5 Pom (org.springframework.roo.project.maven.Pom)5 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)1 CliCommand (org.springframework.roo.shell.CliCommand)1