/** * Registers resources and providers provided by the Application. The * methods adds new providers and resources and DOES NOT removes the already * registered. * * @param application - application to register * @param servletContext - current servlet context * @param requestProcessorAttribute - attribute on which the request * processor is stored. It's useful, when there are multiple rest * servlets in the system and each one has a request processor. */ public static void registerApplication(Application application, ServletContext servletContext, String requestProcessorAttribute) { RequestProcessor requestProcessor = RequestProcessor.getRequestProcessor(servletContext, requestProcessorAttribute); requestProcessor.getConfiguration().addApplication(application, false); }
private void registerDefaultApplication() { try { String loadWinkApplicationsProperty = configuration.getProperties().getProperty(PROPERTY_LOAD_WINK_APPLICATIONS, Boolean.toString(true)); logger.trace("{} property is set to: {}", //$NON-NLS-1$ PROPERTY_LOAD_WINK_APPLICATIONS, loadWinkApplicationsProperty); final Set<Class<?>> classes = new ServletApplicationFileLoader(Boolean.parseBoolean(loadWinkApplicationsProperty)) .getClasses(); RegistrationUtils.InnerApplication application = new RegistrationUtils.InnerApplication(classes); application.setPriority(WinkApplication.SYSTEM_PRIORITY); configuration.addApplication(application, true); } catch (FileNotFoundException e) { throw new WebApplicationException(e); } }
private void registerRootResources() { Properties properties = configuration.getProperties(); String registerRootResource = properties.getProperty(PROPERTY_ROOT_RESOURCE, PROPERTY_ROOT_RESOURCE_DEFAULT); logger.trace("{} property is set to: {}", PROPERTY_ROOT_RESOURCE, registerRootResource); //$NON-NLS-1$ if (registerRootResource.equals(PROPERTY_ROOT_RESOURCE_ATOM)) { RegistrationUtils.InnerApplication application = new RegistrationUtils.InnerApplication(RootResource.class); application.setPriority(WinkApplication.SYSTEM_PRIORITY); configuration.addApplication(application, true); } else if (registerRootResource.equals(PROPERTY_ROOT_RESOURCE_NONE)) { // do nothing } else { String css = properties.getProperty(PROPERTY_ROOT_RESOURCE_CSS); logger.trace("{} property is set to: {}", PROPERTY_ROOT_RESOURCE_CSS, css); //$NON-NLS-1$ HtmlServiceDocumentResource instance = new HtmlServiceDocumentResource(); if (css != null) { instance.setServiceDocumentCssPath(css); } RegistrationUtils.InnerApplication application = new RegistrationUtils.InnerApplication(instance); application.setPriority(WinkApplication.SYSTEM_PRIORITY); configuration.addApplication(application, true); } }
logger.trace("Setting application to " + app.toString()); deploymentConfiguration.addApplication(app, false);