This repository has been archived by the owner on Nov 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start copying spring angular-universal.
- Loading branch information
bbortt
committed
Aug 5, 2018
1 parent
7574203
commit fe5b14a
Showing
9 changed files
with
598 additions
and
502 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
77 changes: 0 additions & 77 deletions
77
...-server/src/main/java/ch/tbmelabs/tv/core/authorizationserver/web/ssr/V8RenderEngine.java
This file was deleted.
Oops, something went wrong.
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,7 @@ | ||
# TBME TV | Angular Universal J2V8 Renderer | ||
|
||
(Java-)Server-Side renderer for angular universal applications. | ||
|
||
## Hat-Tip and Acknowledgement | ||
|
||
This project is heavily based on [swaechter](https://github.com/swaechter)'s original [implementation](https://github.com/swaechter/angularj-universal). |
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,85 @@ | ||
<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> | ||
<groupId>ch.tbmelabs.tv.shared</groupId> | ||
<artifactId>angular-universal-j2v8-renderer</artifactId> | ||
|
||
<parent> | ||
<groupId>ch.tbmelabs.tv</groupId> | ||
<artifactId>shared</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<properties> | ||
<!-- Plugin configuration --> | ||
<com.eclipsesource.j2v8.version>4.6.0</com.eclipsesource.j2v8.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok --> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<profiles> | ||
<profile> | ||
<id>eclipsesource-j2v8-linux</id> | ||
|
||
<activation> | ||
<os> | ||
<family>unix</family> | ||
</os> | ||
</activation> | ||
|
||
<dependencies> | ||
<!-- https://mvnrepository.com/artifact/com.eclipsesource.j2v8/j2v8_linux_x86_64 --> | ||
<dependency> | ||
<groupId>com.eclipsesource.j2v8</groupId> | ||
<artifactId>j2v8_linux_x86_64</artifactId> | ||
<version>${com.eclipsesource.j2v8.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</profile> | ||
|
||
<profile> | ||
<id>eclipsesource-j2v8-windows</id> | ||
|
||
<activation> | ||
<os> | ||
<family>windows</family> | ||
</os> | ||
</activation> | ||
|
||
<dependencies> | ||
<!-- https://mvnrepository.com/artifact/com.eclipsesource.j2v8/j2v8_win32_x86_64 --> | ||
<dependency> | ||
<groupId>com.eclipsesource.j2v8</groupId> | ||
<artifactId>j2v8_win32_x86_64</artifactId> | ||
<version>${com.eclipsesource.j2v8.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</profile> | ||
|
||
<profile> | ||
<id>eclipsesource-j2v8-mac</id> | ||
|
||
<activation> | ||
<os> | ||
<family>mac</family> | ||
</os> | ||
</activation> | ||
|
||
<dependencies> | ||
<!-- https://mvnrepository.com/artifact/com.eclipsesource.j2v8/j2v8_macosx_x86_64 --> | ||
<dependency> | ||
<groupId>com.eclipsesource.j2v8</groupId> | ||
<artifactId>j2v8_macosx_x86_64</artifactId> | ||
<version>${com.eclipsesource.j2v8.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</profile> | ||
</profiles> | ||
</project> |
85 changes: 85 additions & 0 deletions
85
...8-renderer/src/main/java/ch/tbmelabs/tv/shared/angularuniversalj2v8renderer/Renderer.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,85 @@ | ||
package ch.tbmelabs.tv.shared.angularuniversalj2v8renderer; | ||
|
||
import java.io.File; | ||
import java.util.ArrayList; | ||
import java.util.Date; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.concurrent.BlockingQueue; | ||
import java.util.concurrent.Future; | ||
import java.util.concurrent.LinkedBlockingDeque; | ||
|
||
import ch.tbmelabs.tv.shared.angularuniversalj2v8renderer.configuration.RenderEngineConfiguration; | ||
import ch.tbmelabs.tv.shared.angularuniversalj2v8renderer.engine.RenderEngine; | ||
|
||
/** | ||
* Original source: | ||
* https://github.com/swaechter/angularj-universal/blob/master/angularj-universal-renderer/src/main/java/ch/swaechter/angularjuniversal/renderer/Renderer.java | ||
*/ | ||
public class Renderer { | ||
private final List<RenderEngine> renderEngines; | ||
private final RenderEngineConfiguration renderEngineConfiguration; | ||
private Date startdate; | ||
|
||
public Renderer(RenderEngineConfiguration renderEngineConfiguration) { | ||
this.renderEngines = new ArrayList<>(); | ||
this.renderEngineConfiguration = renderEngineConfiguration; | ||
} | ||
|
||
public synchronized void startRenderer() { | ||
if (renderEngines.size() != 0) { | ||
return; | ||
} | ||
|
||
startdate = new Date(); | ||
|
||
for (int i = 0; i < renderEngineConfiguration.getEngines(); i++) { | ||
RenderEngine renderengine = renderenginefactory.createRenderEngine(); | ||
renderEngines.add(renderengine); | ||
|
||
Thread thread = new Thread(() -> { | ||
renderengine.startWorking(renderrequests, renderconfiguration); | ||
}); | ||
thread.start(); | ||
} | ||
|
||
if (renderEngineConfiguration.getLiveReload()) { | ||
Thread thread = new Thread(() -> { | ||
while (isRendererRunning()) { | ||
File file = renderEngineConfiguration.getServerBundleFile(); | ||
if (startdate.before(new Date(file.lastModified()))) { | ||
stopRenderer(); | ||
startRenderer(); | ||
} | ||
} | ||
}); | ||
thread.start(); | ||
} | ||
} | ||
|
||
public synchronized void stopRenderer() { | ||
if (renderEngines.size() == 0) { | ||
return; | ||
} | ||
|
||
for (int i = 0; i < renderEngineConfiguration.getEngines(); i++) { | ||
renderrequests.add(Optional.empty()); | ||
} | ||
|
||
while (renderrequests.size() != 0) { | ||
// Wait for an empty request queue | ||
} | ||
|
||
renderEngines.clear(); | ||
} | ||
|
||
public synchronized boolean isRendererRunning() { | ||
return renderEngines.size() != 0; | ||
} | ||
|
||
public Future<String> addRenderRequest(String uri) { | ||
RenderRequest renderrequest = new RenderRequest(uri); | ||
renderrequests.add(Optional.of(renderrequest)); | ||
return renderrequest.getFuture(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...elabs/tv/shared/angularuniversalj2v8renderer/configuration/RenderEngineConfiguration.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,23 @@ | ||
package ch.tbmelabs.tv.shared.angularuniversalj2v8renderer.configuration; | ||
|
||
import java.io.File; | ||
import java.nio.charset.Charset; | ||
import java.util.List; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
|
||
/** | ||
* Original source: | ||
* https://github.com/swaechter/angularj-universal/blob/master/angularj-universal-renderer/src/main/java/ch/swaechter/angularjuniversal/renderer/configuration/RenderConfiguration.java | ||
*/ | ||
@Data | ||
@AllArgsConstructor | ||
public class RenderEngineConfiguration { | ||
private final String templateContent; | ||
private final File serverBundleFile; | ||
private final int engines; | ||
private final boolean livereload; | ||
private final Charset charset; | ||
private final List<String> routes; | ||
} |
11 changes: 11 additions & 0 deletions
11
...src/main/java/ch/tbmelabs/tv/shared/angularuniversalj2v8renderer/engine/RenderEngine.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,11 @@ | ||
package ch.tbmelabs.tv.shared.angularuniversalj2v8renderer.engine; | ||
|
||
import java.net.URI; | ||
|
||
/** | ||
* Original source: | ||
* https://github.com/swaechter/angularj-universal/blob/master/angularj-universal-renderer/src/main/java/ch/swaechter/angularjuniversal/renderer/engine/RenderEngine.java | ||
*/ | ||
public interface RenderEngine { | ||
String renderPage(URI uri); | ||
} |
19 changes: 19 additions & 0 deletions
19
.../ch/tbmelabs/tv/shared/angularuniversalj2v8renderer/engine/impl/NodeRenderEngineImpl.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 ch.tbmelabs.tv.shared.angularuniversalj2v8renderer.engine.impl; | ||
|
||
import java.net.URI; | ||
|
||
import ch.tbmelabs.tv.shared.angularuniversalj2v8renderer.engine.RenderEngine; | ||
|
||
/** | ||
* Original source: | ||
* https://github.com/swaechter/angularj-universal/blob/master/angularj-universal-renderer-v8/src/main/java/ch/swaechter/angularjuniversal/v8renderer/V8RenderEngine.java | ||
*/ | ||
public class NodeRenderEngineImpl implements RenderEngine { | ||
|
||
@Override | ||
public String renderPage(URI uri) { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
} |
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