-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial support for legacy war deployments
- Loading branch information
1 parent
c81e38b
commit 76f9126
Showing
15 changed files
with
400 additions
and
10 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
core/deployment/src/main/java/org/jboss/shamrock/deployment/ArchiveContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
core/deployment/src/main/java/org/jboss/shamrock/deployment/ArchiveContextBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.jboss.shamrock.deployment; | ||
|
||
import java.nio.file.Path; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class ArchiveContextBuilder { | ||
|
||
private List<Path> additionalApplicationArchives = new ArrayList<>(); | ||
|
||
public ArchiveContextBuilder addAdditionalApplicationArchive(Path path) { | ||
additionalApplicationArchives.add(path); | ||
return this; | ||
} | ||
|
||
List<Path> getAdditionalApplicationArchives() { | ||
return additionalApplicationArchives; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
core/deployment/src/main/java/org/jboss/shamrock/deployment/ArchiveContextImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.jboss.shamrock</groupId> | ||
<artifactId>shamrock-legacy</artifactId> | ||
<version>1.0.0.Alpha1-SNAPSHOT</version> | ||
<relativePath>../</relativePath> | ||
</parent> | ||
|
||
<artifactId>shamrock-legacy-launcher</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.jboss.shamrock</groupId> | ||
<artifactId>shamrock-core-deployment</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.shamrock</groupId> | ||
<artifactId>shamrock-legacy-runner</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.shamrock</groupId> | ||
<artifactId>shamrock-undertow-deployment</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.shamrock</groupId> | ||
<artifactId>shamrock-arc-deployment</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.shamrock</groupId> | ||
<artifactId>shamrock-transactions-deployment</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.shamrock</groupId> | ||
<artifactId>shamrock-jaxrs-deployment</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.shamrock</groupId> | ||
<artifactId>shamrock-rest-client-deployment</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.shamrock</groupId> | ||
<artifactId>shamrock-health-deployment</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.shamrock</groupId> | ||
<artifactId>shamrock-jpa-deployment</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.shamrock</groupId> | ||
<artifactId>shamrock-metrics-deployment</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.shamrock</groupId> | ||
<artifactId>shamrock-openapi-deployment</artifactId> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<finalName>shamrock-legacy</finalName> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<mainClass>org.jboss.shamrock.legacy.launcher.Main</mainClass> | ||
</manifest> | ||
</archive> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-dependency-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<phase>install</phase> | ||
<goals> | ||
<goal>copy-dependencies</goal> | ||
</goals> | ||
<configuration> | ||
<outputDirectory>${project.build.directory}/lib</outputDirectory> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
60 changes: 60 additions & 0 deletions
60
legacy/launcher/src/main/java/org/jboss/shamrock/legacy/launcher/Main.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package org.jboss.shamrock.legacy.launcher; | ||
|
||
import java.io.File; | ||
import java.lang.reflect.Method; | ||
import java.net.URL; | ||
import java.net.URLClassLoader; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* For some reason when using class-path entries something seems broken in java service loaders, as getResources() | ||
* will only every return a single resource from the app class loader. | ||
* <p> | ||
* To get around this the legacy integration is broken up into a launcher and the runner, with this launcher | ||
* just setting up class loading. | ||
* <p> | ||
* This has the advatange than anything added to he lib dir will automatically be added to the class path. | ||
*/ | ||
public class Main { | ||
|
||
public static void main(String... args) { | ||
String classFileName = Main.class.getName().replace(".", "/") + ".class"; | ||
URL location = Main.class.getClassLoader().getResource(classFileName); | ||
File libDir; | ||
if (location.getProtocol().equals("jar")) { | ||
String loc = location.getPath().substring(5, location.getPath().lastIndexOf('!')); | ||
File file = new File(loc); | ||
libDir = new File(file.getParentFile(), "lib"); | ||
} else if (location.getProtocol().equals("file")) { | ||
|
||
String loc = location.getPath().substring(0, location.getPath().length() - classFileName.length()); | ||
File file = new File(loc); | ||
libDir = new File(file.getParentFile(), "lib"); | ||
} else { | ||
throw new RuntimeException("Unable to determine lib dir location from URL: " + location); | ||
} | ||
if (!libDir.isDirectory()) { | ||
throw new RuntimeException("Could not find lib dir " + libDir); | ||
} | ||
try { | ||
List<URL> urls = new ArrayList<>(); | ||
for (File i : libDir.listFiles()) { | ||
urls.add(i.toURL()); | ||
} | ||
ClassLoader old = Thread.currentThread().getContextClassLoader(); | ||
URLClassLoader ucl = new URLClassLoader(urls.toArray(new URL[urls.size()])); | ||
try { | ||
Thread.currentThread().setContextClassLoader(ucl); | ||
Class<?> main = ucl.loadClass("org.jboss.shamrock.legacy.Main"); | ||
Method run = main.getDeclaredMethod("main", String[].class); | ||
run.invoke(null, (Object) args); | ||
} finally { | ||
Thread.currentThread().setContextClassLoader(old); | ||
} | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>shamrock-parent</artifactId> | ||
<groupId>org.jboss.shamrock</groupId> | ||
<version>1.0.0.Alpha1-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>shamrock-legacy</artifactId> | ||
<packaging>pom</packaging> | ||
<modules> | ||
<module>launcher</module> | ||
<module>runner</module> | ||
</modules> | ||
|
||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.jboss.shamrock</groupId> | ||
<artifactId>shamrock-legacy</artifactId> | ||
<version>1.0.0.Alpha1-SNAPSHOT</version> | ||
<relativePath>../</relativePath> | ||
</parent> | ||
|
||
<artifactId>shamrock-legacy-runner</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.jboss.shamrock</groupId> | ||
<artifactId>shamrock-core-deployment</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
Oops, something went wrong.