use of org.glassfish.api.deployment.archive.ReadableArchive in project Payara by payara.
the class FileArchiveTest method createAndPopulateSubarchive.
private ReadableArchive createAndPopulateSubarchive(final WritableArchive parent, final String subarchiveName, final Set<String> entryNames) throws Exception {
final WritableArchive result = parent.createSubArchive(subarchiveName);
for (String entryName : entryNames) {
result.putNextEntry(entryName);
result.closeEntry();
}
result.close();
final ReadableArchive readableParent = archiveFactory.openArchive(parent.getURI());
return readableParent.getSubArchive(subarchiveName);
}
use of org.glassfish.api.deployment.archive.ReadableArchive in project Payara by payara.
the class InputJarArchiveTest method testNestedNonDirEntryNames.
@Test
public void testNestedNonDirEntryNames() {
try {
System.out.println("nested non-directory entry names in InputJarArchive");
final ReadableArchive arch = getArchiveForTest();
ReadableArchive subArchive = arch.getSubArchive(NESTED_JAR_ENTRY_NAME);
final Set<String> returnedNames = new HashSet<String>(setFromEnumeration(subArchive.entries()));
assertEquals("Returned nested non-directories do not match expected", testSubArchiveNonDirEntryNames(), returnedNames);
retireArchive(arch);
} catch (IOException ex) {
ex.printStackTrace(System.out);
fail("Error during test");
}
}
use of org.glassfish.api.deployment.archive.ReadableArchive in project Payara by payara.
the class DeploymentUtils method getManifestLibraries.
/**
* Returns the URLs of libraries referenced in the manifest
* @param archive
* @param manifest
* @return
*/
private static List<URL> getManifestLibraries(ReadableArchive archive, Manifest manifest) {
String appRootPath = null;
ReadableArchive parentArchive = archive.getParentArchive();
if (parentArchive != null) {
appRootPath = (new File(parentArchive.getURI())).getPath();
} else {
try {
appRootPath = (new File(archive.getURI().getPath())).getParent();
} catch (Exception e) {
// ignore, this is the jar inside jar case
}
}
// add libraries referenced through manifest
return ASClassLoaderUtil.getManifestClassPathAsURLs(manifest, appRootPath);
}
use of org.glassfish.api.deployment.archive.ReadableArchive in project Payara by payara.
the class ApplicationLifecycle method getExternalLibraries.
private List<ReadableArchive> getExternalLibraries(ReadableArchive source, Boolean skipScanExternalLibProp) throws IOException {
List<ReadableArchive> externalLibArchives = new ArrayList<>();
if (skipScanExternalLibProp) {
// return an empty list here
return Collections.emptyList();
}
List<URI> externalLibs = DeploymentUtils.getExternalLibraries(source);
for (URI externalLib : externalLibs) {
externalLibArchives.add(archiveFactory.openArchive(new File(externalLib.getPath())));
}
return externalLibArchives;
}
use of org.glassfish.api.deployment.archive.ReadableArchive in project Payara by payara.
the class ApplicationLifecycle method enable.
@Override
public ExtendedDeploymentContext enable(String target, Application app, ApplicationRef appRef, ActionReport report, Logger logger) throws Exception {
ReadableArchive archive = null;
try {
DeployCommandParameters commandParams = app.getDeployParameters(appRef);
// if the application is already loaded, do not load again
ApplicationInfo appInfo = appRegistry.get(commandParams.name);
if (appInfo != null && appInfo.isLoaded()) {
return null;
}
commandParams.origin = DeployCommandParameters.Origin.load;
commandParams.command = DeployCommandParameters.Command.enable;
commandParams.target = target;
commandParams.enabled = Boolean.TRUE;
Properties contextProps = app.getDeployProperties();
Map<String, Properties> modulePropsMap = app.getModulePropertiesMap();
ApplicationConfigInfo savedAppConfig = new ApplicationConfigInfo(app);
URI uri = new URI(app.getLocation());
File file = new File(uri);
if (!file.exists()) {
throw new Exception(localStrings.getLocalString("fnf", "File not found {0}", file.getAbsolutePath()));
}
archive = archiveFactory.openArchive(file);
final ExtendedDeploymentContext deploymentContext = getBuilder(logger, commandParams, report).source(archive).build();
Properties appProps = deploymentContext.getAppProps();
appProps.putAll(contextProps);
savedAppConfig.store(appProps);
if (modulePropsMap != null) {
deploymentContext.setModulePropsMap(modulePropsMap);
}
deploy(getSniffersFromApp(app), deploymentContext);
return deploymentContext;
} finally {
try {
if (archive != null) {
archive.close();
}
} catch (IOException ioe) {
// ignore
}
}
}
Aggregations