-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
midpoint-boot-layout: update/modernization, and JAR support
- Now only single Launcher class is added to WAR or JAR. - The base package of the launcher is changed to c.e.m.launcher. - This change should be compatible with Spring Boot 2.6.x as well.
- Loading branch information
Showing
10 changed files
with
164 additions
and
66 deletions.
There are no files selected for viewing
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
17 changes: 17 additions & 0 deletions
17
.../midpoint-boot-layout/src/main/java/com/evolveum/midpoint/launcher/MidPointJarLayout.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,17 @@ | ||
/* | ||
* Copyright (C) 2010-2022 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
package com.evolveum.midpoint.launcher; | ||
|
||
import org.springframework.boot.loader.tools.Layouts; | ||
|
||
public class MidPointJarLayout extends Layouts.Jar implements MidPointLayoutCommon { | ||
|
||
@Override | ||
public String getLauncherClassName() { | ||
return MidPointLauncher.class.getName(); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...nt-boot-layout/src/main/java/com/evolveum/midpoint/launcher/MidPointJarLayoutFactory.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,24 @@ | ||
/* | ||
* Copyright (C) 2010-2022 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
package com.evolveum.midpoint.launcher; | ||
|
||
import java.io.File; | ||
|
||
import org.springframework.boot.loader.tools.Layout; | ||
import org.springframework.boot.loader.tools.LayoutFactory; | ||
|
||
/** | ||
* Layout factory used in POM repackaging the application (JAR version). | ||
*/ | ||
@SuppressWarnings("unused") | ||
public class MidPointJarLayoutFactory implements LayoutFactory { | ||
|
||
@Override | ||
public Layout getLayout(File source) { | ||
return new MidPointJarLayout(); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...s/midpoint-boot-layout/src/main/java/com/evolveum/midpoint/launcher/MidPointLauncher.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,61 @@ | ||
/* | ||
* Copyright (C) 2010-2022 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
package com.evolveum.midpoint.launcher; | ||
|
||
import java.nio.file.Path; | ||
|
||
import org.springframework.boot.loader.PropertiesLauncher; | ||
|
||
/** | ||
* This is a "pre-launcher" to {@link PropertiesLauncher} which is the actual launcher. | ||
* | ||
* `PropertiesLauncher` is used because we can specify additional classpath components with it. | ||
* This launcher sets `loader.path` system property if not specified. | ||
* If `loader.path` is specified the user/system administrator is fully responsible for it. | ||
* | ||
* This also sets `midpoint.home` system property if not set using `MIDPOINT_HOME` environment | ||
* variable as the first default and then `${user.home}/midpoint`. | ||
* | ||
* Finally, this class also provides {@link #stop(String[])} method for Windows service. | ||
*/ | ||
public class MidPointLauncher { | ||
|
||
private MidPointLauncher() { | ||
throw new AssertionError("Non-instantiable launcher class"); | ||
} | ||
|
||
// Mostly duplicates with WAR launcher, but we want to keep these separate. | ||
@SuppressWarnings("DuplicatedCode") | ||
public static void main(String[] args) throws Exception { | ||
String midpointHome = System.getProperty("midpoint.home"); | ||
if (midpointHome == null) { | ||
midpointHome = System.getenv("MIDPOINT_HOME"); | ||
if (midpointHome == null) { | ||
midpointHome = Path.of(System.getProperty("user.home"), "midpoint").toString(); | ||
} | ||
} | ||
midpointHome = Path.of(midpointHome).toAbsolutePath().toString(); | ||
System.setProperty("midpoint.home", midpointHome); | ||
System.out.println("midPoint home: " + midpointHome); | ||
|
||
// if loader.path is set we will respect it, although it's unlikely | ||
if (System.getProperty("loader.path") == null) { | ||
System.setProperty("loader.path", Path.of(midpointHome, "lib").toString()); | ||
} | ||
System.out.println("Using loader path (for additional JARs): " + System.getProperty("loader.path")); | ||
|
||
PropertiesLauncher.main(args); | ||
} | ||
|
||
/** | ||
* Used as Windows service stop method. | ||
*/ | ||
@SuppressWarnings("unused") | ||
public static synchronized void stop(String[] args) { | ||
System.exit(0); | ||
} | ||
} |
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
17 changes: 17 additions & 0 deletions
17
.../midpoint-boot-layout/src/main/java/com/evolveum/midpoint/launcher/MidPointWarLayout.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,17 @@ | ||
/* | ||
* Copyright (C) 2010-2022 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
package com.evolveum.midpoint.launcher; | ||
|
||
import org.springframework.boot.loader.tools.Layouts; | ||
|
||
public class MidPointWarLayout extends Layouts.War implements MidPointLayoutCommon { | ||
|
||
@Override | ||
public String getLauncherClassName() { | ||
return MidPointWarLauncher.class.getName(); | ||
} | ||
} |
8 changes: 5 additions & 3 deletions
8
...ools/layout/MidPointWarLayoutFactory.java → ...nt/launcher/MidPointWarLayoutFactory.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