public void terminate() { synchronized (mutex) { if (processManager != null) { processManager.terminate(); } } }
public boolean isReadyForCommands() { synchronized (mutex) { if (processManager != null) { // BUSY_EXECUTION needed in case of recursive commands, such as // if executing a script // TERMINATED added in case of additional commands following a // quit or exit in a script - ROO-2270 final ProcessManagerStatus processManagerStatus = processManager.getProcessManagerStatus(); return processManagerStatus == ProcessManagerStatus.AVAILABLE || processManagerStatus == ProcessManagerStatus.BUSY_EXECUTING || processManagerStatus == ProcessManagerStatus.TERMINATED; } } return false; }
public Object execute(final ParseResult parseResult) throws RuntimeException { Validate.notNull(parseResult, "Parse result required"); synchronized (mutex) { Validate.isTrue(isReadyForCommands(), "ProcessManagerHostedExecutionStrategy not yet ready for commands"); return processManager.execute(new CommandCallback<Object>() { public Object callback() { try { return parseResult.getMethod().invoke(parseResult.getInstance(), parseResult.getArguments()); } catch (Exception e) { throw new RuntimeException(ObjectUtils.defaultIfNull(ExceptionUtils.getRootCause(e), e)); } } }); } }
protected boolean checkTemplates(String location, String templateName) { // Check if provided template exists and has .ftl extension return fileManager.exists(location.concat("/").concat(templateName).concat(".ftl")); }
/** * Writes the given Maven POM to disk * * @param pom the POM to write (required) */ private void writePomFile(final Document pom, String folder) { MutableFile pomFile; if (folder != null) { LogicalPath rootPath = LogicalPath.getInstance(Path.ROOT, ""); pomFile = fileManager.createFile(pathResolver.getIdentifier(rootPath, folder + "/" + POM_XML)); } else { LogicalPath rootPath = LogicalPath.getInstance(Path.ROOT, ""); pomFile = fileManager.createFile(pathResolver.getIdentifier(rootPath, POM_XML)); } XmlUtils.writeXml(pomFile.getOutputStream(), pom); }
@Override public String getTargetNameSpaceFromWsdlFile(String wsdlPath) { // Check if provided wsdl file exists if (getFileManager().exists(wsdlPath)) { // Obtain document final Document document = XmlUtils.readXml(getFileManager().getInputStream(wsdlPath)); // Return targetNamespace return document.getDocumentElement().getAttribute("targetNamespace"); } return null; }
@Override public void createProjectSettingsFile() { getFileManager().createFile(getProjectSettingsLocation()); }
/** * Deletes the given ITD, either now or later. * * @param metadataIdentificationString the ITD's metadata ID * @param itdFilename the ITD's filename * @param reason the reason for deletion; ignored if now is * <code>false</code> * @param now whether to delete the ITD immediately; <code>false</code> * schedules it for later deletion; this is preferable when it's * possible that the ITD might need to be re-created in the * meantime (e.g. because some ancestor metadata has changed to * that effect), otherwise there will be spurious console * messages about the ITD being deleted and created */ private void deleteItd(final String metadataIdentificationString, final String itdFilename, final String reason, final boolean now) { if (now) { getFileManager().delete(itdFilename, reason); } else { getFileManager().createOrUpdateTextFileIfRequired(itdFilename, "", false); } getItdDiscoveryService().removeItdTypeDetails(metadataIdentificationString); // TODO do we need to notify downstream dependencies that this ITD has // gone away? }
@Override public void writeDoc(Document document, String viewPath) { // Write doc on disk if (document != null && StringUtils.isNotBlank(viewPath)) { getFileManager().createOrUpdateTextFileIfRequired(viewPath, document.html(), false); } }
@CliAvailabilityIndicator(PROCESS_MANAGER_DEBUG_COMMAND) public boolean isProcessManagerDebugAvailable() { return getShell().isDevelopmentMode() && getProcessManager().isDevelopmentMode(); }
private int getItdCount(final String itdUniquenessFilenameSuffix) { return fileManager.findMatchingAntPath( pathResolver.getFocusedRoot(Path.SRC_MAIN_JAVA) + ANT_MATCH_DIRECTORY_PATTERN + "*_Roo_" + itdUniquenessFilenameSuffix + ".aj").size(); }
@CliAvailabilityIndicator(REFERENCE_GUIDE_COMMAND) public boolean isReferenceGuideAvailable() { return getShell().isDevelopmentMode() && getProcessManager().isDevelopmentMode(); }
@CliCommand(value = PROJECT_SCAN_SPEED_COMMAND, help = "Changes the time inteval between file system scans.") public String scanningSpeed(@CliOption(key = {"", "ms"}, mandatory = true, help = "The number of milliseconds between each scan") final long minimumDelayBetweenScan) { if (processManager == null) { processManager = getProcessManager(); } Validate.notNull(processManager, "ProcessManager is required"); processManager.setMinimumDelayBetweenScan(minimumDelayBetweenScan); return scanningInfo(); }
/** * This method check if the provided viewPath file exists * * @param viewName * @return true if exists the provided view path */ protected boolean existsFile(String viewPath) { return getFileManager().exists(viewPath); }
private void setUpLog4jConfiguration() { final String log4jConfigFile = getPathResolver().getFocusedIdentifier(Path.SRC_MAIN_RESOURCES, "log4j.properties"); final InputStream templateInputStream = FileUtils.getInputStream(getClass(), "log4j.properties-template"); OutputStream outputStream = null; try { outputStream = getFileManager().createFile(log4jConfigFile).getOutputStream(); IOUtils.copy(templateInputStream, outputStream); } catch (final IOException e) { LOGGER.warning("Unable to install log4j logging configuration"); } finally { IOUtils.closeQuietly(templateInputStream); IOUtils.closeQuietly(outputStream); } }
@Override public boolean existsSpringConfigFile(String moduleName) { return fileManager.exists(getSpringConfigLocation(moduleName)); }
@Override public boolean existsSpringConfigFile(String moduleName, String profile) { return fileManager.exists(getSpringConfigLocation(moduleName, profile)); }
@Override public boolean existsProjectSettingsFile() { return getFileManager().exists(getProjectSettingsLocation()); }
public MetadataItem get(final String metadataId) { Validate.isTrue(ProjectMetadata.isValid(metadataId), "Unexpected metadata request '%s' for this provider", metadataId); // Just rebuild on demand. We always do this as we expect // MetadataService to cache on our behalf final Pom pom = pomManagementService.getPomFromModuleName(ProjectMetadata.getModuleName(metadataId)); // Read the file, if it is available if (pom == null || !fileManager.exists(pom.getPath())) { return null; } return new ProjectMetadata(pom); }