Skip to content
This repository has been archived by the owner on May 26, 2020. It is now read-only.

Fix weld errors when running from a jar #5

Merged
merged 1 commit into from
Jul 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ on [Keep a CHANGELOG](http://keepachangelog.com/). This project adheres to

## [Unreleased]

## [1.0.0] 2019-07-12
## [1.0.0] 2019-07-16
### Added
- Initial release of the catchup-shuttering-manager CLI tool, supporting invocation of the event sourcing frameworks SHUTTER, UNSHUTTER, CATCHUP, REBUILD operations.
- New command '--list' which lists the commands available on your Wildfly instance.
- Authentication to a remote Wildfly instance with commands '--username' and '--password'
### Changed
- Application now run in a Weld container to allow for dependency injection
- Application runs in a Weld container to allow for dependency injection



37 changes: 10 additions & 27 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,9 @@
<cpp.repo.name>framework-jmx-command-client</cpp.repo.name>

<framework-api.version>4.0.1</framework-api.version>
<framework.version>6.0.0-RC4</framework.version>
<event-store.version>2.0.0-RC5</event-store.version>
<framework-generators.version>2.0.0-RC4</framework-generators.version>
<framework.version>6.0.0-RC7</framework.version>
<event-store.version>2.0.0-RC7</event-store.version>
<maven-common-bom.version>2.4.0</maven-common-bom.version>

<commons.cli.version>1.2</commons.cli.version>
<wildfly.version>10.0.0.Final</wildfly.version>
</properties>

<scm>
Expand All @@ -49,27 +45,18 @@

<dependency>
<groupId>uk.gov.justice.services</groupId>
<artifactId>jmx-command-client</artifactId>
<artifactId>jmx-api</artifactId>
<version>${framework.version}</version>
</dependency>
<dependency>
<groupId>uk.gov.justice.services</groupId>
<artifactId>framework-management</artifactId>
<artifactId>jmx-command-client</artifactId>
<version>${framework.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
<dependency>
<groupId>uk.gov.justice.event-store</groupId>
<artifactId>event-store-management</artifactId>
<version>${event-store.version}</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
Expand All @@ -82,11 +69,6 @@
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se</artifactId>
</dependency>
<dependency>
<groupId>uk.gov.justice.event-store</groupId>
<artifactId>event-buffer-core</artifactId>
<version>${event-store.version}</version>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-client-all</artifactId>
Expand All @@ -105,6 +87,11 @@
<artifactId>hamcrest-library</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>


</dependencies>
Expand All @@ -128,13 +115,10 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<!-- get all project dependencies -->
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<finalName>${project.name}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<!-- MainClass in mainfest make a executable jar -->
<appendAssemblyId>true</appendAssemblyId>
<archive>
<manifest>
<mainClass>
Expand All @@ -147,7 +131,6 @@
<executions>
<execution>
<id>make-assembly</id>
<!-- bind to the packaging phase -->
<phase>package</phase>
<goals>
<goal>single</goal>
Expand Down
9 changes: 9 additions & 0 deletions runSystemCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

FRAMEWORK_JMX_COMMAND_CLIENT_VERSION=1.1.0-SNAPSHOT

#fail script on error
set -e
echo "Running Framework System Command Client $1 $2 $3 $4 $5"
echo
java -jar target/framework-jmx-command-client-${FRAMEWORK_JMX_COMMAND_CLIENT_VERSION}-jar-with-dependencies.jar $1 $2 $3 $4 $5
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import uk.gov.justice.framework.command.client.io.CommandPrinter;
import uk.gov.justice.framework.command.client.io.ToConsolePrinter;
import uk.gov.justice.framework.command.client.jmx.SystemCommandInvoker;
import uk.gov.justice.services.jmx.command.SystemCommand;
import uk.gov.justice.services.jmx.api.command.SystemCommand;
import uk.gov.justice.services.jmx.system.command.client.connection.JmxParameters;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package uk.gov.justice.framework.command.client;

import uk.gov.justice.services.jmx.command.SystemCommand;
import uk.gov.justice.services.jmx.api.command.SystemCommand;

import java.util.List;
import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package uk.gov.justice.framework.command.client;

import uk.gov.justice.framework.command.client.cdi.producers.OptionsFactory;
import uk.gov.justice.framework.command.client.jmx.ListCommandsInvoker;
import uk.gov.justice.framework.command.client.startup.CommandLineArgumentParser;
import uk.gov.justice.services.jmx.command.SystemCommand;
import uk.gov.justice.services.jmx.api.command.SystemCommand;
import uk.gov.justice.services.jmx.system.command.client.connection.JmxParameters;

import java.util.List;
Expand All @@ -12,7 +13,6 @@

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;

public class MainApplication {

Expand All @@ -26,7 +26,7 @@ public class MainApplication {
private ListCommandsInvoker listCommandsInvoker;

@Inject
private Options options;
private OptionsFactory optionsFactory;

@Inject
private HelpFormatter formatter;
Expand All @@ -48,7 +48,7 @@ public void run(final String[] args) {
systemCommandsOptional.ifPresent(systemCommands -> commandExecutor.executeCommand(commandLine, jmxParameters, systemCommands));

} else {
formatter.printHelp("java -jar catchup-shuttering-manager.jar", options);
formatter.printHelp("java -jar catchup-shuttering-manager.jar", optionsFactory.createOptions());
}
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

import org.apache.commons.cli.Options;

public class OptionsProducer {
public class OptionsFactory {

@Produces
public Options options() {
public Options createOptions() {
final Options options = new Options();

options.addOption("c", "command", true, "Framework command to execute. Run with --list for a list of all commands");
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package uk.gov.justice.framework.command.client.io;

import uk.gov.justice.services.jmx.command.SystemCommand;
import uk.gov.justice.services.jmx.api.command.SystemCommand;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import static java.util.Optional.of;

import uk.gov.justice.framework.command.client.io.ToConsolePrinter;
import uk.gov.justice.services.jmx.command.SystemCommand;
import uk.gov.justice.services.jmx.command.SystemCommanderMBean;
import uk.gov.justice.services.jmx.api.command.SystemCommand;
import uk.gov.justice.services.jmx.api.mbean.SystemCommanderMBean;
import uk.gov.justice.services.jmx.system.command.client.SystemCommanderClient;
import uk.gov.justice.services.jmx.system.command.client.SystemCommanderClientFactory;
import uk.gov.justice.services.jmx.system.command.client.connection.JmxAuthenticationException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package uk.gov.justice.framework.command.client.jmx;

import uk.gov.justice.framework.command.client.io.ToConsolePrinter;
import uk.gov.justice.services.jmx.command.SystemCommand;
import uk.gov.justice.services.jmx.command.SystemCommanderMBean;
import uk.gov.justice.services.jmx.api.command.SystemCommand;
import uk.gov.justice.services.jmx.api.mbean.SystemCommanderMBean;
import uk.gov.justice.services.jmx.system.command.client.SystemCommanderClient;
import uk.gov.justice.services.jmx.system.command.client.SystemCommanderClientFactory;
import uk.gov.justice.services.jmx.system.command.client.connection.JmxAuthenticationException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
import static java.util.Optional.of;

import uk.gov.justice.framework.command.client.CommandLineException;
import uk.gov.justice.framework.command.client.cdi.producers.OptionsFactory;
import uk.gov.justice.framework.command.client.io.ToConsolePrinter;

import java.util.Optional;

import javax.inject.Inject;

import org.apache.commons.cli.BasicParser;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;

public class CommandLineArgumentParser {
Expand All @@ -23,15 +23,15 @@ public class CommandLineArgumentParser {
private ToConsolePrinter toConsolePrinter;

@Inject
private Options options;
private OptionsFactory optionsFactory;

@Inject
private CommandLineParser commandLineParser;
private BasicParser basicParser;

public Optional<CommandLine> parse(final String[] args) {

try {
final CommandLine commandLine = commandLineParser.parse(options, args);
final CommandLine commandLine = basicParser.parse(optionsFactory.createOptions(), args);

if (commandLine.hasOption("command") || commandLine.hasOption("list")) {
return of(commandLine);
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/META-INF/beans.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
version="1.1" bean-discovery-mode="all">
</beans>
<scan>
<exclude name="org.jboss.weld.**"/>
</scan>
</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,26 @@
import static java.util.Arrays.asList;
import static java.util.Optional.empty;
import static java.util.Optional.of;

import org.apache.commons.cli.CommandLine;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;

import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*;

import uk.gov.justice.framework.command.client.io.CommandPrinter;
import uk.gov.justice.framework.command.client.io.ToConsolePrinter;
import uk.gov.justice.framework.command.client.jmx.SystemCommandInvoker;
import uk.gov.justice.services.jmx.command.SystemCommand;
import uk.gov.justice.services.jmx.api.command.SystemCommand;
import uk.gov.justice.services.jmx.system.command.client.connection.JmxParameters;

import java.util.List;

import org.apache.commons.cli.CommandLine;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;


@RunWith(MockitoJUnitRunner.class)
public class CommandExecutorTest {
Expand Down
Loading