use of org.keycloak.testsuite.utils.undertow.UndertowWarClassLoader in project keycloak by keycloak.
the class KeycloakOnUndertow method deploy.
@Override
public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException {
if (isRemoteMode()) {
log.infof("Skipped deployment of '%s' as we are in remote mode!", archive.getName());
return new ProtocolMetaData();
}
DeploymentInfo di = getDeplotymentInfoFromArchive(archive);
ClassLoader parentCl = Thread.currentThread().getContextClassLoader();
UndertowWarClassLoader classLoader = new UndertowWarClassLoader(parentCl, archive);
Thread.currentThread().setContextClassLoader(classLoader);
try {
undertow.deploy(di);
} finally {
Thread.currentThread().setContextClassLoader(parentCl);
}
deployedArchivesToContextPath.put(archive.getName(), di.getContextPath());
return new ProtocolMetaData().addContext(createHttpContextForDeploymentInfo(di));
}
use of org.keycloak.testsuite.utils.undertow.UndertowWarClassLoader in project keycloak by keycloak.
the class UndertowAppServer method deploy.
@Override
public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException {
log.info("Deploying archive " + archive.getName());
// Remove jsps
// My Intellij and Terminal stores tmp directory in this property
String ioTMPDir = System.getProperty("java.io.tmpdir", "");
if (!ioTMPDir.isEmpty()) {
ioTMPDir = ioTMPDir.endsWith("/") ? ioTMPDir : ioTMPDir + "/";
File tmpUndertowJSPDirectory = new File(ioTMPDir + "org/apache/jsp");
if (tmpUndertowJSPDirectory.exists()) {
try {
FileUtils.deleteDirectory(tmpUndertowJSPDirectory);
} catch (IOException e) {
e.printStackTrace();
}
}
}
DeploymentInfo di;
if (archive instanceof UndertowWebArchive) {
di = ((UndertowWebArchive) archive).getDeploymentInfo();
} else if (archive instanceof WebArchive) {
WebArchive webArchive = (WebArchive) archive;
Optional<Node> applicationClassNode = archive.getContent(archivePath -> archivePath.get().startsWith("/WEB-INF/classes/") && archivePath.get().endsWith("Application.class")).values().stream().findFirst();
if (isJaxrsApp(webArchive)) {
di = new UndertowDeployerHelper().getDeploymentInfo(configuration, webArchive, undertow.undertowDeployment(discoverPathAnnotatedClasses(webArchive)));
} else if (applicationClassNode.isPresent()) {
String applicationPath = applicationClassNode.get().getPath().get();
ResteasyDeployment deployment = new ResteasyDeployment();
deployment.setApplicationClass(extractClassName(applicationPath));
di = new UndertowDeployerHelper().getDeploymentInfo(configuration, (WebArchive) archive, undertow.undertowDeployment(deployment));
} else {
di = new UndertowDeployerHelper().getDeploymentInfo(configuration, webArchive);
}
} else {
throw new IllegalArgumentException("UndertowContainer only supports UndertowWebArchive or WebArchive.");
}
if ("ROOT.war".equals(archive.getName())) {
di.setContextPath("/");
}
ClassLoader parentCl = Thread.currentThread().getContextClassLoader();
UndertowWarClassLoader classLoader = new UndertowWarClassLoader(parentCl, archive);
Thread.currentThread().setContextClassLoader(classLoader);
try {
undertow.deploy(di);
} finally {
Thread.currentThread().setContextClassLoader(parentCl);
}
deployedArchivesToContextPath.put(archive.getName(), di.getContextPath());
return new ProtocolMetaData().addContext(createHttpContextForDeploymentInfo(di));
}
Aggregations