Skip to content

Commit

Permalink
Merge pull request #3 from CJSCommonPlatform/spike-shrinkwrap-war
Browse files Browse the repository at this point in the history
Add replay event stream tool
  • Loading branch information
allanmckenzie committed Nov 3, 2016
2 parents 0f5c02e + 3532a5c commit d465a98
Show file tree
Hide file tree
Showing 16 changed files with 308 additions and 679 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,4 @@ Thumbs.db
/components/command/command-handler/conf/login.config
/components/command/command-handler/conf/openejb.xml
/components/command/command-handler/conf/users.properties
/framework-tools-replay/*.war
7 changes: 6 additions & 1 deletion CHANGELOG.md
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
22 changes: 0 additions & 22 deletions external/pom.xml

This file was deleted.

11 changes: 0 additions & 11 deletions external/src/main/java/uk/gov/justice/external/ExBean.java

This file was deleted.

6 changes: 0 additions & 6 deletions external/src/main/resources/META-INF/beans.xml

This file was deleted.

70 changes: 55 additions & 15 deletions framework-tools-replay/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?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"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<parent>
Expand All @@ -9,12 +9,15 @@
<version>1.0.0-SNAPSHOT</version>
</parent>

<groupId>uk.gov.justice</groupId>
<artifactId>framework-tools-replay</artifactId>
<packaging>jar</packaging>

<modelVersion>4.0.0</modelVersion>

<properties>
<framework.version>0.33.0</framework.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
Expand All @@ -27,28 +30,60 @@
</dependencies>
</dependencyManagement>


<dependencies>
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>datasources</artifactId>
</dependency>
<dependency>
<groupId>uk.gov.justice</groupId>
<artifactId>framework-tools-swarm</artifactId>
<version>${project.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.187</version>
<groupId>uk.gov.justice.services</groupId>
<artifactId>core</artifactId>
<version>${framework.version}</version>
</dependency>
<dependency>
<groupId>uk.gov.justice</groupId>
<artifactId>external</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
<groupId>uk.gov.justice.services</groupId>
<artifactId>event-repository-jdbc</artifactId>
<version>${framework.version}</version>
<exclusions>
<exclusion>
<groupId>uk.gov.justice.services</groupId>
<artifactId>persistance-jdbc</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>datasources</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>jpa</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>jaxrs</artifactId>
<exclusions>
<exclusion>
<artifactId>jboss-logging</artifactId>
<groupId>org.jboss.logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>messaging</artifactId>
<exclusions>
<exclusion>
<groupId>org.wildfly.swarm</groupId>
<artifactId>jgroups</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand All @@ -61,6 +96,11 @@
<artifactId>hamcrest-library</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

Expand Down

This file was deleted.

This file was deleted.

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);
}
}
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 --------------");
}

}
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>
Loading

0 comments on commit d465a98

Please sign in to comment.