private void setLastRunDate(Date date) { SimpleDateFormat sdf = new SimpleDateFormat(ANALYTICS_DATE_MASK); configuration.setProperty(ANALYTICS_LAST_RUN, sdf.format(date)); }
@Override public void setProperty(final String key, final Object value) { getDelegate().setProperty(key, value); }
@DefaultCommand public void setEnabled(@Option(name = "enabled", required = true) Boolean enabled) { configuration.setProperty(ANALYTICS_ENABLED, enabled); getAnalyticsTracker().setEnabled(enabled); }
@Override public void visit(JavaResource javaResource) { if (!found) { try { if (javaResource.getJavaSource().getAnnotation("javax.ws.rs.ApplicationPath") != null) { configuration .setProperty(REST_APPLICATIONCLASS_PACKAGE, javaResource.getJavaSource().getPackage()); configuration.setProperty(REST_APPLICATIONCLASS_NAME, javaResource.getJavaSource().getName()); configuration.setProperty(RestFacet.ROOTPATH, javaResource.getJavaSource().getAnnotation("javax.ws.rs.ApplicationPath") .getStringValue()); found = true; } } catch (FileNotFoundException e) { throw new RuntimeException(e); } } } });
public void onStartup(@Observes PostStartup startup) { Boolean enabled = configuration.getBoolean(ANALYTICS_ENABLED, null); if (enabled == null) { if (Boolean.getBoolean("forge.analytics.no_prompt")) { enabled = Boolean.FALSE; } else { enabled = shell .promptBoolean( "Will you allow the Forge team to receive anonymous usage statistics for this instance of JBoss Forge?", false); } configuration.setProperty(ANALYTICS_ENABLED, enabled); } setEnabled(enabled); if (enabled && isAllowedToRun()) { sendInfoToAnalytics(); } }
@SetupCommand public void setup(@Option(name = "activatorType", defaultValue = "WEB_XML") RestActivatorType activatorType, final PipeOut out) { if (!project.hasFacet(RestFacet.class)) { configuration.setProperty(RestFacet.ACTIVATOR_CHOICE, activatorType.toString()); request.fire(new InstallFacets(RestFacet.class)); } if (project.hasFacet(RestFacet.class)) { ShellMessages.success(out, "Rest Web Services (JAX-RS) is installed."); } }
projectConfiguration.setProperty(RestFacet.ROOTPATH, rootpath); PromptType.JAVA_PACKAGE, project.getFacet(MetadataFacet.class).getTopLevelPackage() + ".rest"); String restApplication = prompt.prompt("How do you want to name the Application class?", "RestApplication"); projectConfiguration.setProperty(RestApplicationFacet.REST_APPLICATIONCLASS_PACKAGE, pkg); projectConfiguration.setProperty(RestApplicationFacet.REST_APPLICATIONCLASS_NAME, restApplication); request.fire(new InstallFacets(RestApplicationFacet.class));
@Override public void setApplicationPath(final String path) { getProjectConfiguration().setProperty(RestFacet.ROOTPATH, path); ServletFacet servlet = project.getFacet(ServletFacet.class); WebAppDescriptorImpl web = (WebAppDescriptorImpl) servlet.getConfig(); Node node = web.getRootNode(); Node servletClass = node.getSingle("servlet-mapping/servlet-name=" + JAXRS_SERVLET); if (servletClass != null) { servletClass.getParent().getOrCreate("url-pattern").text(path); } servlet.saveConfig(web); }
@Override public void setApplicationPath(String path) { getProjectConfiguration().setProperty(RestFacet.ROOTPATH, path); if (classPackage == null || className == null) { reportConfigurationError(className); } JavaSourceFacet javaSourceFacet = project.getFacet(JavaSourceFacet.class); try { String classname = classPackage + "." + this.className; JavaResource javaResource = javaSourceFacet.getJavaResource(classname); if (!javaResource.exists()) { reportConfigurationError(classname); } javaResource.getJavaSource().getAnnotation("javax.ws.rs.ApplicationPath").setStringValue(path); } catch (FileNotFoundException e) { reportConfigurationError(className); } }