-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from CJSCommonPlatform/spike-shrinkwrap-war
Add replay event stream tool
- Loading branch information
Showing
16 changed files
with
308 additions
and
679 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 |
---|---|---|
@@ -1,4 +1,9 @@ | ||
# Change Log | ||
All notable changes to this project will be documented in this file, which follows the guidelines | ||
on [Keep a CHANGELOG](http://keepachangelog.com/). This project adheres to | ||
[Semantic Versioning](http://semver.org/). | ||
[Semantic Versioning](http://semver.org/). | ||
|
||
## [Unreleased] | ||
|
||
### Added | ||
- Replay Event Stream tool |
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
external/src/main/java/uk/gov/justice/external/ExBean.java
This file was deleted.
Oops, something went wrong.
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
43 changes: 0 additions & 43 deletions
43
framework-tools-replay/src/main/java/uk/gov/justice/framework/tools/example/Replay.java
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
framework-tools-replay/src/main/java/uk/gov/justice/framework/tools/example/StartupBean.java
This file was deleted.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
framework-tools-replay/src/main/java/uk/gov/justice/framework/tools/replay/Replay.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,50 @@ | ||
package uk.gov.justice.framework.tools.replay; | ||
|
||
import static org.jboss.shrinkwrap.api.ShrinkWrap.create; | ||
import static org.jboss.shrinkwrap.api.ShrinkWrap.createFromZipFile; | ||
import static org.wildfly.swarm.Swarm.artifact; | ||
|
||
import uk.gov.justice.framework.tools.swarm.command.SwarmCommand; | ||
|
||
import java.nio.file.Path; | ||
|
||
import com.beust.jcommander.Parameter; | ||
import com.beust.jcommander.Parameters; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.jboss.shrinkwrap.impl.base.filter.ExcludeRegExpPaths; | ||
import org.wildfly.swarm.Swarm; | ||
import org.wildfly.swarm.undertow.WARArchive; | ||
|
||
|
||
@Parameters(separators = "=", commandDescription = "Replay Event Stream Command") | ||
public class Replay extends SwarmCommand { | ||
|
||
private static final String GENERATED_CLASS_PACKAGE_EXPRESSION = "(.*?)uk.gov.justice.api(.*?)"; | ||
|
||
@Parameter(names = "-l", description = "external library") | ||
private Path library; | ||
|
||
public void run(final String[] args) { | ||
try { | ||
new Swarm(firedArgs()) | ||
.start() | ||
.deploy(buildDeploymentArtifact()); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
private WARArchive buildDeploymentArtifact() throws Exception { | ||
final WebArchive webArchive = createFromZipFile(WebArchive.class, library.toFile()); | ||
|
||
final WebArchive excludeGeneratedApiClasses = create(WebArchive.class, "ExcludeGeneratedApiClasses") | ||
.merge(webArchive, new ExcludeRegExpPaths(GENERATED_CLASS_PACKAGE_EXPRESSION)); | ||
|
||
return create(WARArchive.class, "replay-tool.war") | ||
.addAsLibraries(artifact("org.glassfish:javax.json")) | ||
.addAsLibraries(artifact("uk.gov.justice.services:event-repository-jdbc")) | ||
.addAsLibraries(artifact("uk.gov.justice.services:event-repository-core")) | ||
.merge(excludeGeneratedApiClasses) | ||
.addClass(StartReplay.class); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
framework-tools-replay/src/main/java/uk/gov/justice/framework/tools/replay/StartReplay.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,38 @@ | ||
package uk.gov.justice.framework.tools.replay; | ||
|
||
import uk.gov.justice.services.core.annotation.Component; | ||
import uk.gov.justice.services.core.annotation.ServiceComponentLocation; | ||
import uk.gov.justice.services.core.dispatcher.Dispatcher; | ||
import uk.gov.justice.services.core.dispatcher.DispatcherCache; | ||
import uk.gov.justice.services.eventsourcing.repository.jdbc.JdbcEventRepository; | ||
|
||
import javax.annotation.PostConstruct; | ||
import javax.ejb.Singleton; | ||
import javax.ejb.Startup; | ||
import javax.inject.Inject; | ||
|
||
@Singleton | ||
@Startup | ||
public class StartReplay { | ||
|
||
@Inject | ||
DispatcherCache dispatcherCache; | ||
|
||
@Inject | ||
JdbcEventRepository jdbcEventRepository; | ||
|
||
@PostConstruct | ||
public void initialise() { | ||
System.out.println("-------------- Replay Event Streams --------------"); | ||
|
||
final Dispatcher dispatcher = dispatcherCache.dispatcherFor(Component.EVENT_LISTENER, ServiceComponentLocation.LOCAL); | ||
|
||
jdbcEventRepository.getAll() | ||
.peek(System.out::println) | ||
.forEach(dispatcher::dispatch); | ||
|
||
System.out.println("-------------- Replay of Event Streams Complete --------------"); | ||
System.out.println("-------------- Press Ctrl+C to exit --------------"); | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
framework-tools-replay/src/main/resources/modules/org/postgresql/main/module.xml
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,16 @@ | ||
<?xml version="1.0" ?> | ||
<!-- | ||
~ Copyright 2015 Red Hat, Inc. and/or its affiliates. | ||
~ | ||
~ Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
--> | ||
<module xmlns="urn:jboss:module:1.3" name="org.postgresql"> | ||
|
||
<resources> | ||
<artifact name="org.postgresql:postgresql:9.4.1208"/> | ||
</resources> | ||
<dependencies> | ||
<module name="javax.api"/> | ||
<module name="javax.transaction.api"/> | ||
</dependencies> | ||
</module> |
Oops, something went wrong.