use of org.glassfish.api.deployment.archive.ReadableArchive in project Payara by payara.
the class Archivist method copyInto.
/**
* Copy this archivist to a new abstract archive
*
* @param target the new archive to use to copy our contents into
* @throws java.io.IOException
*/
public void copyInto(WritableArchive target) throws IOException {
ReadableArchive source = archiveFactory.openArchive(new File(path));
copyInto(source, target);
}
use of org.glassfish.api.deployment.archive.ReadableArchive in project Payara by payara.
the class Archivist method write.
/**
* saves the archive
*
* @param outPath the file to use
*/
public void write(String outPath) throws IOException {
ReadableArchive in = archiveFactory.openArchive(new File(path));
write(in, outPath);
in.close();
}
use of org.glassfish.api.deployment.archive.ReadableArchive in project Payara by payara.
the class WarPersistenceArchivist method open.
@Override
public Object open(Archivist main, ReadableArchive warArchive, RootDeploymentDescriptor descriptor) throws IOException, SAXParseException {
final String CLASSES_DIR = "WEB-INF/classes/";
if (deplLogger.isLoggable(Level.FINE)) {
deplLogger.logp(Level.FINE, "WarPersistenceArchivist", "readPersistenceDeploymentDescriptors", "archive = {0}", warArchive.getURI());
}
Map<String, ReadableArchive> probablePersitenceArchives = new HashMap<>();
try {
SubArchivePURootScanner warLibScanner = new SubArchivePURootScanner() {
@Override
String getPathOfSubArchiveToScan() {
return "WEB-INF/lib";
}
};
probablePersitenceArchives = getProbablePersistenceRoots(warArchive, warLibScanner);
final String pathOfPersistenceXMLInsideClassesDir = CLASSES_DIR + DescriptorConstants.PERSISTENCE_DD_ENTRY;
InputStream is = warArchive.getEntry(pathOfPersistenceXMLInsideClassesDir);
if (is != null) {
is.close();
probablePersitenceArchives.put(CLASSES_DIR, warArchive.getSubArchive(CLASSES_DIR));
}
for (Map.Entry<String, ReadableArchive> pathToArchiveEntry : probablePersitenceArchives.entrySet()) {
readPersistenceDeploymentDescriptor(main, pathToArchiveEntry.getValue(), pathToArchiveEntry.getKey(), descriptor);
}
} finally {
for (Archive probablePersitenceArchive : probablePersitenceArchives.values()) {
probablePersitenceArchive.close();
}
}
return null;
}
use of org.glassfish.api.deployment.archive.ReadableArchive in project Payara by payara.
the class OpenAPISupplier method filterLibTypes.
private Set<Type> filterLibTypes(OpenApiConfiguration config, Types hk2Types, ReadableArchive archive) {
Set<Type> types = new HashSet<>();
if (config != null && config.getScanLib()) {
Enumeration<String> subArchiveItr = archive.entries();
while (subArchiveItr.hasMoreElements()) {
String subArchiveName = subArchiveItr.nextElement();
if (subArchiveName.startsWith("WEB-INF/lib/") && subArchiveName.endsWith(".jar")) {
try {
ReadableArchive subArchive = archive.getSubArchive(subArchiveName);
types.addAll(Collections.list(subArchive.entries()).stream().filter(clazz -> clazz.endsWith(".class")).map(clazz -> clazz.replace("/", ".").replace(".class", "")).map(clazz -> hk2Types.getBy(clazz)).filter(Objects::nonNull).collect(toSet()));
} catch (IOException ex) {
throw new IllegalStateException(ex);
}
}
}
}
return types;
}
use of org.glassfish.api.deployment.archive.ReadableArchive in project Payara by payara.
the class ConnectorsUtil method getApplicationName.
public static String getApplicationName(DeploymentContext context) {
String applicationName = null;
ReadableArchive parentArchive = context.getSource().getParentArchive();
if (parentArchive != null) {
applicationName = parentArchive.getName();
} else {
applicationName = context.getSource().getName();
}
return applicationName;
}
Aggregations