private static void addRestApplicationIfPossible(final WebModule webModule, final Class<? extends Application> app) { if (!isInstantiable(app)) { return; } if (app.getConstructors().length == 0) { webModule.getRestApplications().add(app.getName()); } else { for (final Constructor<?> ctr : app.getConstructors()) { if (ctr.getParameterTypes().length == 0) { webModule.getRestApplications().add(app.getName()); break; } } } }
private static void addRestApplicationIfPossible(final WebModule webModule, final Class<? extends Application> app) { if (!isInstantiable(app)) { return; } if (app.getConstructors().length == 0) { webModule.getRestApplications().add(app.getName()); } else { for (final Constructor<?> ctr : app.getConstructors()) { if (ctr.getParameterTypes().length == 0) { webModule.getRestApplications().add(app.getName()); break; } } } }
public void setDefaultMapping(@Observes final BeforeAppInfoBuilderEvent event) { final AppModule module = event.getAppModule(); if (module == null) { return; } final List<WebModule> webModules = module.getWebModules(); final String ignore = SystemInstance.get().getProperty(DEFAULT_RS_APPLICATION_IGNORE.replace("com.tomi", ""), System.getProperty(DEFAULT_RS_APPLICATION_IGNORE, module.getProperties().getProperty(DEFAULT_RS_APPLICATION_IGNORE))); final String mapping = System.getProperty(DEFAULT_RS_APPLICATION_MAPPING, "/api/*"); if (!Boolean.parseBoolean(ignore) && !webModules.isEmpty() /*for tests mainly*/ && !isOAuth2(module)) { for (final WebModule webModule : webModules) { final WebApp webApp = webModule.getWebApp(); if (webApp == null) continue; // can't happen if (!webModule.getRestApplications().isEmpty()) continue; // already a REST application if ("tomitribe-monitor-internal".equals(webModule.getModuleId())) continue; // monitoring internal webapp if ("tomitribe-monitor-internal".equals(webApp.getId())) continue; // monitor process LOGGER.info(WadlxCodes.APPLICATION_CONFIGURER, "No REST application defined for application: {0}. Automatically adding a default JAX RS mapping for it on {1}/{2}. " + "Add a class annotated with @javax.ws.rs.ApplicationPath to the application to specify this mapping manually.", webModule.getModuleId(), webModule.getContextRoot(), mapping.replaceAll("^/+", "")); // strip off leading / characters webApp .addServlet(InternalApplication.class.getName(), null, SystemInstance.get().getProperty( DEFAULT_RS_APPLICATION_IGNORE.replace("com.tomi", ""), mapping)); } } }
classes.addAll(web.getEjbRestServices()); for (final String app : web.getRestApplications()) { final Class<?> clazz; try {
classes.addAll(web.getEjbRestServices()); for (final String app : web.getRestApplications()) { final Class<?> clazz; try {
webModule.getRestApplications().clear(); webModule.getRestApplications().add(webXmlApplication); final Collection<String> restApp = webModule.getRestApplications(); if (restApp.isEmpty()) { addRestClassesToScannedClasses(webModule, classes, classLoader); for (final ParamValue pv : servlet.getInitParam()) { if ("javax.ws.rs.core.Application".equals(pv.getParamName()) || "javax.ws.rs.Application".equals(pv.getParamName())) { webModule.getRestApplications().add(pv.getParamValue()); done = true; break; webModule.getRestApplications().add(ProvidedJAXRSApplication.class.getName()); for (final ServletMapping mapping : webApp.getServletMapping()) { if (servletName.equals(mapping.getServletName())) { webModule.getRestApplications().clear(); webModule.getRestApplications().add(param.getParamValue()); break;
webModule.getRestApplications().clear(); webModule.getRestApplications().add(webXmlApplication); final Collection<String> restApp = webModule.getRestApplications(); if (restApp.isEmpty()) { addRestClassesToScannedClasses(webModule, classes, classLoader); if ("javax.ws.rs.core.Application".equals(servletName)) { servlet.setServletName(ProvidedJAXRSApplication.class.getName()); webModule.getRestApplications().add(ProvidedJAXRSApplication.class.getName()); for (final ServletMapping mapping : webApp.getServletMapping()) { if (servletName.equals(mapping.getServletName())) { webModule.getRestApplications().clear(); webModule.getRestApplications().add(param.getParamValue()); break;
webAppInfo.validationInfo = ValidatorBuilder.getInfo(webModule.getValidationConfig()); webAppInfo.uniqueId = webModule.getUniqueId(); webAppInfo.restApplications.addAll(webModule.getRestApplications()); webAppInfo.restClass.addAll(webModule.getRestClasses()); webAppInfo.ejbWebServices.addAll(webModule.getEjbWebServices());
webAppInfo.validationInfo = ValidatorBuilder.getInfo(webModule.getValidationConfig()); webAppInfo.uniqueId = webModule.getUniqueId(); webAppInfo.restApplications.addAll(webModule.getRestApplications()); webAppInfo.restClass.addAll(webModule.getRestClasses()); webAppInfo.ejbWebServices.addAll(webModule.getEjbWebServices());