private void retrieveResourcesXMLFromArchive(Map<String, String> fileNames, ReadableArchive archive, String actualArchiveName) { if(ResourceUtil.hasResourcesXML(archive, locator)){ String archivePath = archive.getURI().getPath(); String fileName ; if(DeploymentUtils.isArchiveOfType(archive, DOLUtils.warType(), locator)){ fileName = archivePath + RESOURCES_XML_WEB_INF; }else{ fileName = archivePath + RESOURCES_XML_META_INF; } if(_logger.isLoggable(Level.FINEST)){ _logger.finest("GlassFish-Resources Deployer - fileName : " + fileName + " - parent : " + archive.getName()); } fileNames.put(actualArchiveName, fileName); } }
private boolean isDASTarget(DeploymentContext context, DeployCommandParameters params) { if (DeploymentUtils.isDASTarget(params.target)) { return true; } else if (DeploymentUtils.isDomainTarget(params.target)) { List<String> targets = context.getTransientAppMetaData(DeploymentProperties.PREVIOUS_TARGETS, List.class); if (targets == null) { targets = domain.getAllReferencedTargetsForApplication( params.name); } if (targets.size() == 1 && DeploymentUtils.isDASTarget(targets.get(0))) { return true; } } return false; } }
/** * Sets the archive name using the archive-name element defined * in sun-application.xml * @param archiveName archiveName to calculate default EE6 app-name */ public void setArchiveName(String archiveName) { this.archiveName = archiveName; if (appName == null && archiveName != null) { appName = DeploymentUtils.getDefaultEEName(archiveName); } }
/** * Returns true if the passed file or directory is recognized by this * instance. * * @param location the file or directory to explore * @param loader class loader for this application * @return true if this sniffer handles this application type */ public boolean handles(ReadableArchive location, ClassLoader loader) { return (DeploymentUtils.isWebArchive(location) || DeploymentUtils.isEAR(location) || isJar(location)); }
private void retrieveResourcesXMLFromArchive(Map<String, String> fileNames, ReadableArchive archive, String actualArchiveName) { if(DeploymentUtils.hasResourcesXML(archive)){ String archivePath = archive.getURI().getPath(); String fileName ; if(DeploymentUtils.isWebArchive(archive)){ fileName = archivePath + RESOURCES_XML_WEB_INF; }else{ fileName = archivePath + RESOURCES_XML_META_INF; } if(_logger.isLoggable(Level.FINEST)){ _logger.finest("GlassFish-Resources Deployer - fileName : " + fileName + " - parent : " + archive.getName()); } fileNames.put(actualArchiveName, fileName); } }
ActionReport.MessagePart part = report.getTopMessagePart(); part.addProperty(DeploymentProperties.NAME, name); final FileArchive arch = DeploymentUtils.openAsFileArchive(reposDir, archiveFactory); arch.delete(); if (!DeploymentUtils.isDomainTarget(target) && enabled) { report.failure(logger, e.getMessage()); return; File source = new File(archive.getURI().getSchemeSpecificPart()); boolean isDirectoryDeployed = true; if (!source.isDirectory()) { String appLocation = DeploymentUtils.relativizeWithinDomainIfPossible( deploymentContext.getSource().getURI()); DeploymentUtils.downloadableArtifacts(deploymentContext); final Artifacts generatedArtifacts = DeploymentUtils.generatedArtifacts(deploymentContext); arch = DeploymentUtils.openAsFileArchive(expansionDir, archiveFactory); arch.delete(); } catch (IOException ex) {
} catch (VersioningException e) { if (env.isDas()) { report.failure(logger, e.getMessage()); } else { report.setMessage(localStrings.getLocalString("ref.not.referenced.target","Application {0} is not referenced by target {1}", name, target)); report.setActionExitCode(ActionReport.ExitCode.FAILURE); } else { if (!DeploymentUtils.isDomainTarget(target)) { ApplicationRef ref = domain.getApplicationRefInTarget(appName, target); if (ref == null) { report.setMessage(localStrings.getLocalString("ref.not.referenced.target","Application {0} is not referenced by target {1}", appName, target)); uri = new URI(application.getLocation()); } catch (URISyntaxException e) { logger.severe("Cannot determine original location for application : " + e.getMessage()); if (env.isDas() && !DeploymentUtils.isDASTarget(target)) { CommandRunner.CommandInvocation inv = commandRunner.getCommandInvocation("disable", report); if (DeploymentUtils.isDomainTarget(target)) { List<String> targets = domain.getAllReferencedTargetsForApplication(appName); final Artifacts generatedArtifacts = DeploymentUtils.generatedArtifacts(application); generatedArtifacts.record(deploymentContext); if ( (! keepreposdir) && !isDirectoryDeployed && source.exists()) {
} catch (VersioningWildcardException ex) { Application app = applications.getApplication(appName); ApplicationRef applicationRef = domain.getApplicationRefInTarget(appName, target); if ( applicationRef != null ) { savedAppConfig = new ApplicationConfigInfo(app); URI uri = new URI(app.getLocation()); file = new File(uri); String location = DeploymentUtils.relativizeWithinDomainIfPossible(new URI(app.getLocation())); appProps.setProperty(ServerTags.LOCATION, location); appProps.setProperty(Application.APP_LOCATION_PROP_NAME, DeploymentUtils.relativizeWithinDomainIfPossible(new URI(appLocation))); String planLocation = appProps.getProperty(Application.DEPLOYMENT_PLAN_LOCATION_PROP_NAME); if (planLocation != null) { appProps.setProperty(Application.DEPLOYMENT_PLAN_LOCATION_PROP_NAME, DeploymentUtils.relativizeWithinDomainIfPossible(new URI(planLocation))); if (domain.isCurrentInstanceMatchingTarget(target, appName, server.getName(), null)) { deployment.deploy(deployment.getSniffersFromApp(app), deploymentContext); } else { if (!isVersionExpression && DeploymentUtils.isDASTarget(target)) { return;
getRelativeEmbeddedModulePath(parentPath. getAbsolutePath(), nameComponent)); jarFiles.add(jarFile.toURI().toURL()); } catch (MalformedURLException e) { throw new RuntimeException(e);
private List<ReadableArchive> getExternalLibraries( DeploymentContext context) throws IOException { List<ReadableArchive> externalLibArchives = new ArrayList<ReadableArchive>(); String skipScanExternalLibProp = context.getAppProps().getProperty( DeploymentProperties.SKIP_SCAN_EXTERNAL_LIB); if (Boolean.valueOf(skipScanExternalLibProp)) { // if we skip scanning external libraries, we should just // return an empty list here return Collections.EMPTY_LIST; } List<URI> externalLibs = DeploymentUtils.getExternalLibraries(context.getSource()); for (URI externalLib : externalLibs) { externalLibArchives.add(archiveFactory.openArchive(new File(externalLib.getPath()))); } return externalLibArchives; }
public void retrieveAllResourcesXMLs(Map<String, String> fileNames, ReadableArchive archive, String actualArchiveName) throws IOException { if(DeploymentUtils.isEAR(archive)){ //Look for top-level META-INF/glassfish-resources.xml if(archive.exists(RESOURCES_XML_META_INF)){ String archivePath = archive.getURI().getPath(); String fileName = archivePath + RESOURCES_XML_META_INF; if(_logger.isLoggable(Level.FINEST)){ _logger.finest("GlassFish-Resources Deployer - fileName : " + fileName + " - parent : " + archive.getName()); } fileNames.put(actualArchiveName, fileName); } //Lok for sub-module level META-INF/glassfish-resources.xml and WEB-INF/glassfish-resources.xml Enumeration<String> entries = archive.entries(); while(entries.hasMoreElements()){ String element = entries.nextElement(); if(element.endsWith(".jar") || element.endsWith(".war") || element.endsWith(".rar") || element.endsWith("_jar") || element.endsWith("_war") || element.endsWith("_rar")){ ReadableArchive subArchive = archive.getSubArchive(element); if(subArchive != null ){ retrieveResourcesXMLFromArchive(fileNames, subArchive, subArchive.getName()); } } } }else{ //Look for standalone archive's META-INF/glassfish-resources.xml and WEB-INF/glassfish-resources.xml retrieveResourcesXMLFromArchive(fileNames, archive, actualArchiveName); } }
public void retrieveAllResourcesXMLs(Map<String, String> fileNames, ReadableArchive archive, String actualArchiveName) throws IOException { if(DeploymentUtils.isArchiveOfType(archive, DOLUtils.earType(), locator)){ //Look for top-level META-INF/glassfish-resources.xml if(archive.exists(RESOURCES_XML_META_INF)){ String archivePath = archive.getURI().getPath(); String fileName = archivePath + RESOURCES_XML_META_INF; if(_logger.isLoggable(Level.FINEST)){ _logger.finest("GlassFish-Resources Deployer - fileName : " + fileName + " - parent : " + archive.getName()); } fileNames.put(actualArchiveName, fileName); } //Lok for sub-module level META-INF/glassfish-resources.xml and WEB-INF/glassfish-resources.xml Enumeration<String> entries = archive.entries(); while(entries.hasMoreElements()){ String element = entries.nextElement(); if(element.endsWith(".jar") || element.endsWith(".war") || element.endsWith(".rar") || element.endsWith("_jar") || element.endsWith("_war") || element.endsWith("_rar")){ ReadableArchive subArchive = archive.getSubArchive(element); if(subArchive != null ){ retrieveResourcesXMLFromArchive(fileNames, subArchive, subArchive.getName()); } } } }else{ //Look for standalone archive's META-INF/glassfish-resources.xml and WEB-INF/glassfish-resources.xml retrieveResourcesXMLFromArchive(fileNames, archive, actualArchiveName); } }
public boolean hasAnnotationInArchive(ReadableArchive archive) { scanArchive(archive); if (found) { return found; } ArchiveFactory archiveFactory = null; if (Globals.getDefaultHabitat() != null) { archiveFactory = Globals.getDefaultHabitat().getComponent(ArchiveFactory.class); } if (archiveFactory != null) { List<URI> externalLibs = DeploymentUtils.getExternalLibraries(archive); for (URI externalLib : externalLibs) { try { scanArchive(archiveFactory.openArchive(new File(externalLib.getPath()))); } catch(FileNotFoundException fnfe) { logger.log(Level.WARNING, "Cannot find archive " + externalLib.getPath() + " referenced from archive " + archive.getName() + ", it will be ignored for annotation scanning"); } catch (Exception e) { logger.log(Level.WARNING, e.getMessage(), e); } } } return found; }
public static List<URI> getExternalLibraries(ReadableArchive archive) { List<URI> externalLibURIs = new ArrayList<URI>(); try { List<URL> manifestURLs = getManifestLibraries(archive); URI archiveURI = archive.getURI(); if (archive.getParentArchive() != null) { archiveURI = archive.getParentArchive().getURI(); } for (URL manifestURL : manifestURLs) { URI manifestLibURI = archiveURI.relativize(manifestURL.toURI()); if (manifestLibURI.isAbsolute()) { File externalLib = new File(manifestLibURI); if (externalLib.exists()) { externalLibURIs.add(manifestLibURI); } } } } catch (Exception e) { Logger.getAnonymousLogger().log(Level.WARNING, e.getMessage(), e); } return externalLibURIs; }
File sourceFile = new File(archive.getURI().getSchemeSpecificPart()); initial.getAppProps().put(ServerTags.DEFAULT_APP_NAME, DeploymentUtils.getDefaultEEName(sourceFile.getName())); } catch (VersioningSyntaxException e) { ActionReport report = copy.report(); report.setMessage(e.getMessage()); report.setActionExitCode(ActionReport.ExitCode.FAILURE); File expansionDir = new File(domain.getApplicationRoot(), repositoryBitName); if (!expansionDir.mkdirs()) { archive.close(); } catch(IOException e) { logger.log(Level.SEVERE, KernelLoggerInfo.errorClosingArtifact, new Object[] { archive.getURI().getSchemeSpecificPart(), e}); throw e;
if (env.isDas() && DeploymentUtils.isDomainTarget(target)) { enabledVersionsInTargets = new HashMap<String, Set<String>>(); enabledVersionsInTargets.put(appName, new HashSet<String>(domain.getAllReferencedTargetsForApplication(appName))); ClusterOperationUtil.replicateCommand("disable", FailurePolicy.Error, FailurePolicy.Warn, targets, context, paramMap, habitat); } catch (Exception e) { report.failure(logger, e.getMessage()); return; report.setActionExitCode(ActionReport.ExitCode.SUCCESS); return; report.setActionExitCode(ActionReport.ExitCode.SUCCESS); return; if (!DeploymentUtils.isDomainTarget(target)) { ApplicationRef ref = domain.getApplicationRefInTarget(appName, target); if (ref == null) { if (env.isDas()) { if (!domain.isCurrentInstanceMatchingTarget(target, appName, server.getName(), null)) { if (!isundeploy) { try {
final Logger logger = context.getLogger(); ActionReport.MessagePart part = report.getTopMessagePart(); matchedVersions = versioningService.getMatchedVersions(name, target); } catch (VersioningException e) { report.failure(logger, e.getMessage()); return; report.setMessage(localStrings.getLocalString("ref.not.referenced.target","Application {0} is not referenced by target {1}", name, target)); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return; String status = "disabled"; if (!DeploymentUtils.isDomainTarget(target)) { ApplicationRef ref = domain.getApplicationRefInTarget(appName, target); if (ref == null) { report.setMessage(localStrings.getLocalString("ref.not.referenced.target","Application {0} is not referenced by target {1}", appName, target)); if (domain.isAppEnabledInTarget(appName, target)) { status = "enabled";
boolean appRefOnly) throws TransactionFailure { final Properties appProps = context.getAppProps(); final DeployCommandParameters deployParams = context.getCommandParameters(DeployCommandParameters.class); if (t != null) { try { if (!appRefOnly) { Application app_w = context.getTransientAppMetaData( ServerTags.APPLICATION, Application.class); if (!DeploymentUtils.isDomainTarget(deployParams.target)) { targets.add(deployParams.target); } else { List<String> previousTargets = context.getTransientAppMetaData(DeploymentProperties.PREVIOUS_TARGETS, List.class); if (previousTargets == null) { previousTargets = domain.getAllReferencedTargetsForApplication(deployParams.name); if (DeploymentUtils.isDomainTarget(deployParams.target)) { String vs = previousVirtualServers.getProperty(target); if (vs != null) { deployParams.enabled = Boolean.TRUE; Server servr = domain.getServerNamed(target); if (servr != null) { Cluster cluster = domain.getClusterNamed(target); if (cluster != null) {
if (enabled || DeploymentUtils.isDomainTarget(target)) { Application app = dmn.getApplications().getApplication(appName); ConfigBeanProxy app_w = t.enroll(app); ((Application)app_w).setEnabled(String.valueOf(enabled)); if (!DeploymentUtils.isDomainTarget(target)) { targets.add(target); } else { targets = domain.getAllReferencedTargetsForApplication(appName); Server servr = dmn.getServerNamed(target); if (servr != null) {
report.setMessage(localStrings.getLocalString("lifecycle.notreg","Lifecycle module {0} not registered", name)); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return; if (!DeploymentUtils.isDomainTarget(target)) { ApplicationRef ref = domain.getApplicationRefInTarget(name, target); if (ref == null) { report.setMessage(localStrings.getLocalString("lifecycle.not.referenced.target","Lifecycle module {0} is not referenced by target {1}", name, target)); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return; if (env.isDas() && DeploymentUtils.isDomainTarget(target)) { List<String> targets = domain.getAllReferencedTargetsForApplication(name);