Skip to content

Commit

Permalink
Merge pull request #115 from adrienlauer/seed-runnable
Browse files Browse the repository at this point in the history
Add core SeedRunner and its SPI (retrofitted to CLI runner)
  • Loading branch information
adrienlauer committed Sep 6, 2015
2 parents 79d8d3e + c684bcd commit cba6dd9
Show file tree
Hide file tree
Showing 59 changed files with 149 additions and 57 deletions.
2 changes: 1 addition & 1 deletion bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>seed-bom</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion cache-support/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<parent>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>seed-cache-support</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion cli-support/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed-cli-support</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>seed-cli-support-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.seedstack.seed.core.api.Application;
import org.seedstack.seed.core.api.SeedException;
import org.seedstack.seed.core.internal.CorePlugin;
import org.seedstack.seed.core.spi.SeedRunnable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -48,10 +49,12 @@
* @author epo.jemba@ext.mpsa.com
* @author adrien.lauer@mpsa.com
*/
public final class SeedRunner {
public class SeedRunner implements SeedRunnable {
private static final Logger LOGGER = LoggerFactory.getLogger(SeedRunner.class);

private SeedRunner() {
@Override
public int run(String[] args) throws Exception {
return execute(args);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.seedstack.seed.cli.SeedRunner
2 changes: 1 addition & 1 deletion cli-support/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>seed-cli-support</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion cli-support/test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed-cli-support</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>seed-cli-support-test</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion core-support/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed-core-support</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>seed-core-support-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Copyright (c) 2013-2015 by The SeedStack authors. All rights reserved.
*
* This file is part of SeedStack, An enterprise-oriented full development stack.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.seedstack.seed.core;

import com.google.common.collect.Lists;
import org.seedstack.seed.core.api.CoreErrorCode;
import org.seedstack.seed.core.api.SeedException;
import org.seedstack.seed.core.internal.CorePlugin;
import org.seedstack.seed.core.spi.SeedRunnable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.ServiceLoader;

public class SeedRunner {
private static final Logger LOGGER = LoggerFactory.getLogger(SeedRunner.class);

public static void main(String[] args) {
List<SeedRunnable> entryPointServices = Lists.newArrayList(ServiceLoader.load(SeedRunnable.class));
int returnCode = 0;

if (entryPointServices.size() < 1) {
throw SeedException.createNew(CoreErrorCode.MISSING_SEED_ENTRY_POINT);
} else if (entryPointServices.size() > 1) {
throw SeedException.createNew(CoreErrorCode.MULTIPLE_SEED_ENTRY_POINTS);
}

try {
returnCode = entryPointServices.get(0).run(args);
} catch (SeedException e) {
handleException(e);
e.printStackTrace(System.err);
} catch (Exception e) {
handleException(e);
SeedException.wrap(e, CoreErrorCode.UNEXPECTED_EXCEPTION).printStackTrace(System.err);
}

// no java.lang.Error handling is done

System.exit(returnCode);
}

private static void handleException(Exception e) {
LOGGER.error("An exception occurred during CLI application startup, collecting diagnostic information");
CorePlugin.getDiagnosticManager().dumpDiagnosticReport(e);
}
}
2 changes: 1 addition & 1 deletion core-support/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>seed-core-support</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion core-support/specs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed-core-support</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>seed-core-support-specs</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ public enum CoreErrorCode implements ErrorCode {
UNABLE_TO_LOAD_SEED_BOOTSTRAP,
UNEXPECTED_EXCEPTION,
UNABLE_TO_CREATE_DIAGNOSTIC_COLLECTOR,
MISSING_SEED_ENTRY_POINT,
MULTIPLE_SEED_ENTRY_POINTS,
RETROW_EXCEPTION_AFTER_DIAGNOSTIC_FAILURE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Copyright (c) 2013-2015 by The SeedStack authors. All rights reserved.
*
* This file is part of SeedStack, An enterprise-oriented full development stack.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.seedstack.seed.core.spi;

/**
* This interface defines a Seed executable entry point. It must be declared as a {@link java.util.ServiceLoader} service
* in META-INF/services to be detected.
*
* @author adrien.lauer@gmail.com
*/
public interface SeedRunnable {
/**
* The entry-point method that is executed upon startup.
*
* @param args the arguments.
* @return the return code.
*/
int run(String[] args) throws Exception;
}
2 changes: 1 addition & 1 deletion crypto-support/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<parent>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>seed-crypto-support</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion doc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>seed-doc</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion el-support/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<parent>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>seed-el-support</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion integrationtest-support/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed-integrationtest-support</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>seed-integrationtest-support-core</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion integrationtest-support/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>seed-integrationtest-support</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion integrationtest-support/web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed-integrationtest-support</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>seed-integrationtest-support-web</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion jms-support/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed-jms-support</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>seed-jms-support-core</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion jms-support/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>seed-jms-support</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion jms-support/specs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed-jms-support</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>seed-jms-support-specs</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion mail-support/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed-mail-support</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>seed-mail-support-core</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion mail-support/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>seed-mail-support</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion mail-support/test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed-mail-support</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>seed-mail-support-test</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion metrics-support/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<parent>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>seed-metrics-support</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion persistence-support/elasticsearch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed-persistence-support</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>seed-persistence-support-elasticsearch</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion persistence-support/inmemory/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed-persistence-support</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>seed-persistence-support-inmemory</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion persistence-support/jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed-persistence-support</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>seed-persistence-support-jdbc</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion persistence-support/jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed-persistence-support</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>seed-persistence-support-jpa</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion persistence-support/mongodb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<parent>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed-persistence-support</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>seed-persistence-support-mongodb</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion persistence-support/neo4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<parent>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed-persistence-support</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>seed-persistence-support-neo4j</artifactId>
Expand Down
9 changes: 7 additions & 2 deletions persistence-support/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,23 @@
file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->
<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">
<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>

<parent>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>seed-persistence-support</artifactId>
<packaging>pom</packaging>

<properties>
<it.excluded-categories>org.seedstack.seed.it.internal.categories.NotSelfContained</it.excluded-categories>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion persistence-support/redis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<parent>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed-persistence-support</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>seed-persistence-support-redis</artifactId>
Expand Down

0 comments on commit cba6dd9

Please sign in to comment.