Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:Evolveum/midpoint
- Loading branch information
Showing
7 changed files
with
249 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright (c) 2010-2017 Evolveum | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<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>tools</artifactId> | ||
<groupId>com.evolveum.midpoint</groupId> | ||
<version>3.7-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>midpoint-war-layout</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-loader</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-loader-tools</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
67 changes: 67 additions & 0 deletions
67
...oint-war-layout/src/main/java/com/evolveum/midpoint/tools/layout/MidPointWarLauncher.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,67 @@ | ||
/* | ||
* Copyright (c) 2010-2017 Evolveum | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.evolveum.midpoint.tools.layout; | ||
|
||
import org.springframework.boot.loader.WarLauncher; | ||
import org.springframework.boot.loader.archive.Archive; | ||
import org.springframework.boot.loader.archive.JarFileArchive; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
|
||
/** | ||
* Created by Viliam Repan (lazyman). | ||
*/ | ||
public class MidPointWarLauncher extends WarLauncher { | ||
|
||
public MidPointWarLauncher() { | ||
} | ||
|
||
public MidPointWarLauncher(Archive archive) { | ||
super(archive); | ||
} | ||
|
||
public static void main(String[] args) throws Exception { | ||
new MidPointWarLauncher().launch(args); | ||
} | ||
|
||
@Override | ||
protected List<Archive> getClassPathArchives() throws Exception { | ||
List<Archive> archives = super.getClassPathArchives(); | ||
|
||
File midPointHomeLib = getMidPointHomeLib(); | ||
if (midPointHomeLib == null || !midPointHomeLib.exists() || !midPointHomeLib.isDirectory()) { | ||
return archives; | ||
} | ||
|
||
File[] files = midPointHomeLib.listFiles(file -> file.getName().toLowerCase().endsWith(".jar")); | ||
if (files == null) { | ||
return archives; | ||
} | ||
|
||
for (File file : files) { | ||
archives.add(new JarFileArchive(file)); | ||
} | ||
|
||
return archives; | ||
} | ||
|
||
private File getMidPointHomeLib() { | ||
String midPointHome = System.getProperty("midpoint.home"); | ||
return new File(midPointHome, "lib"); | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
...dpoint-war-layout/src/main/java/com/evolveum/midpoint/tools/layout/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,81 @@ | ||
/* | ||
* Copyright (c) 2010-2017 Evolveum | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.evolveum.midpoint.tools.layout; | ||
|
||
import org.springframework.boot.loader.tools.CustomLoaderLayout; | ||
import org.springframework.boot.loader.tools.JarWriter; | ||
import org.springframework.boot.loader.tools.Layouts; | ||
import org.springframework.boot.loader.tools.LoaderClassesWriter; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.security.CodeSource; | ||
import java.security.ProtectionDomain; | ||
import java.util.jar.JarFile; | ||
|
||
/** | ||
* Created by Viliam Repan (lazyman). | ||
*/ | ||
public class MidPointWarLayout extends Layouts.War implements CustomLoaderLayout { | ||
|
||
private String name; | ||
|
||
public MidPointWarLayout(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public void writeLoadedClasses(LoaderClassesWriter writer) throws IOException { | ||
JarWriter jarWriter = (JarWriter) writer; | ||
writer.writeLoaderClasses(); | ||
|
||
JarFile self = createSelf(); | ||
jarWriter.writeEntries(self); | ||
} | ||
|
||
@Override | ||
public String getLauncherClassName() { | ||
return MidPointWarLauncher.class.getName(); | ||
} | ||
|
||
private final JarFile createSelf() throws IOException { | ||
try { | ||
ProtectionDomain protectionDomain = getClass().getProtectionDomain(); | ||
CodeSource codeSource = protectionDomain.getCodeSource(); | ||
URI location = (codeSource == null ? null : codeSource.getLocation().toURI()); | ||
String path = (location == null ? null : location.getSchemeSpecificPart()); | ||
|
||
if (path == null) { | ||
throw new IllegalStateException("Unable to determine code source archive"); | ||
} | ||
|
||
File root = new File(path); | ||
if (!root.exists()) { | ||
throw new IllegalStateException("Unable to determine code source archive from " + root); | ||
} | ||
|
||
return new JarFile(root); | ||
} catch (Exception e) { | ||
throw new IOException("Could not find self jar", e); | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...war-layout/src/main/java/com/evolveum/midpoint/tools/layout/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (c) 2010-2017 Evolveum | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.evolveum.midpoint.tools.layout; | ||
|
||
import org.springframework.boot.loader.tools.Layout; | ||
import org.springframework.boot.loader.tools.LayoutFactory; | ||
|
||
import java.io.File; | ||
|
||
/** | ||
* Created by Viliam Repan (lazyman). | ||
*/ | ||
public class MidPointWarLayoutFactory implements LayoutFactory { | ||
|
||
private static final String NAME = "midpoint-war"; | ||
|
||
private String name; | ||
|
||
public MidPointWarLayoutFactory() { | ||
this(NAME); | ||
} | ||
|
||
public MidPointWarLayoutFactory(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public Layout getLayout(File source) { | ||
return new MidPointWarLayout(name); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
tools/midpoint-war-layout/src/main/resources/META-INF/spring.factories
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 @@ | ||
org.springframework.boot.loader.tools.LayoutFactory=com.evolveum.midpoint.tools.layout.MidPointWarLayoutFactory |
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