Standalone Ignite

Library to reduce the code necessary to start and make a controlled shutdown of standalone applications

License

License

GroupId

GroupId

org.bytemechanics
ArtifactId

ArtifactId

standalone-ignite
Last Version

Last Version

2.0.7
Release Date

Release Date

Type

Type

jar
Description

Description

Standalone Ignite
Library to reduce the code necessary to start and make a controlled shutdown of standalone applications
Project URL

Project URL

https://standalone-ignite.bytemechanics.org
Project Organization

Project Organization

Byte Mechanics
Source Code Management

Source Code Management

https://github.com/bytemechanics/standalone-ignite

Download standalone-ignite

How to add to project

<!-- https://jarcasting.com/artifacts/org.bytemechanics/standalone-ignite/ -->
<dependency>
    <groupId>org.bytemechanics</groupId>
    <artifactId>standalone-ignite</artifactId>
    <version>2.0.7</version>
</dependency>
// https://jarcasting.com/artifacts/org.bytemechanics/standalone-ignite/
implementation 'org.bytemechanics:standalone-ignite:2.0.7'
// https://jarcasting.com/artifacts/org.bytemechanics/standalone-ignite/
implementation ("org.bytemechanics:standalone-ignite:2.0.7")
'org.bytemechanics:standalone-ignite:jar:2.0.7'
<dependency org="org.bytemechanics" name="standalone-ignite" rev="2.0.7">
  <artifact name="standalone-ignite" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.bytemechanics', module='standalone-ignite', version='2.0.7')
)
libraryDependencies += "org.bytemechanics" % "standalone-ignite" % "2.0.7"
[org.bytemechanics/standalone-ignite "2.0.7"]

Dependencies

test (5)

Group / Artifact Type Version
org.bytemechanics : copy-commons jar 1.5.2
org.junit.jupiter : junit-jupiter-api jar 5.5.2
org.junit.jupiter : junit-jupiter-params jar 5.5.2
org.junit.jupiter : junit-jupiter-engine jar 5.5.2
org.jmockit : jmockit jar 1.48

Project Modules

There are no modules declared in this project.

Standalone ignite

Latest version Quality Gate Coverage License

Library to reduce the code necessary to start and make a controlled shutdown of standalone applications. The scope of this library is to provide solutions for:

  • Easy parse of command line parameters
  • Easy start and stop daemons (standalone services) inside your standalone application
  • Easy detection of O.S. stop requirement to make a graceful shutdown

Motivation

Some times make something so simple as batch generates a lot of boilerplate source with this library we intend to make this startup easier and faster as well as keeping the control of all startup process.

Requirements

JDK8

Quick start

(Please read our Javadoc for further information)

  1. First of all include the Jar file in your compile and execution classpath.

Maven

	<dependency>
		<groupId>org.bytemechanics</groupId>
		<artifactId>standalone-ignite</artifactId>
		<version>X.X.X</version>
	</dependency>

Graddle

dependencies {
    compile 'org.bytemechanics:standalone-ignite:X.X.X'
}
  1. Create the standalone application main class
package mypackage;
  1. If some parameters are needed, create an enumerate with all necessary parameters
package mypackage;

import java.util.Optional;
import java.util.function.Function;
import org.bytemechanics.standalone.ignite.beans.DefaultParameterContainer;

public enum StandaloneAppTestParameter implements Parameter{

	BOOLEANVALUE(boolean.class,"boolean value"),
	INTVALUE(int.class,"int value"),
	LONGVALUE(long.class,"long value"),
	FLOATVALUE(float.class,"float value"),
	DOUBLEVALUE(double.class,"double value"),
	STRINGVALUE(String.class,"string value"),
	;
	
	private final DefaultParameterContainer container;
	
	<T extends Object> StandaloneAppTestParameter(final Class<T> _type,final String _description){
		this(_type,_description,null,null);
	}
	<T extends Object> StandaloneAppTestParameter(final Class<T> _type,final String _description,final String _default){
		this(_type,_description,_default,null);
	}
	<T extends Object> StandaloneAppTestParameter(final Class<T> _type,final String _description,final String _default,final Function<String,T> _parser){
		this.container=DefaultParameterContainer.builder()
												.name(name())
												.type(_type)
												.description(_description)
												.defaultValue(_default)
												.parser((Function<String,Object>)_parser)
											.build();
	}

	@Override
	public Class getType() {
		return this.container.getType();
	}

	@Override
	public Function<String, Object> getParser() {
		return this.container.getParser();
	}

	@Override
	public Optional<Object> getValue() {
		return this.container.getValue();
	}

	@Override
	public Parameter setValue(Object _value) {
		return this.container.setValue(_value);
	}

	@Override
	public Optional<String> getDefaultValue() {
		return this.container.getDefaultValue();
	}

	@Override
	public String getDescription() {
		return this.container.getDescription();
	}
}
  1. Into your main instantiate Standalone
  • Option 1: Using org.bytemechanics.standalone.ignite.Ignitable interface
package mypackage;

import java.util.Optional;
import java.util.function.Function;
import org.bytemechanics.standalone.ignite.Ignitable;
import org.bytemechanics.standalone.ignite.beans.DefaultParameterContainer;


public final class StandaloneApp implements Ignitable{

	@Override
	public void startup() {
		// start your application
	}

	@Override
	public void shutdown() {
		// shutdown your application (optional)
	}

	(...)

	public static final void main(final String... _args){
		Standalone.builder(StandaloneApp::new)
					.arguments(_args)
					(...)
					.parameters(StandaloneAppTestParameter.class)
					(...)
				.build();
					.ignite();
	}
}
  • Option 2: Using org.bytemechanics.standalone.ignite.IgnitableAdapter abstract class
package mypackage;

import java.util.Optional;
import java.util.function.Function;
import org.bytemechanics.standalone.ignite.IgnitableAdapter;


public final class StandaloneApp extends IgnitableAdapter{

	@Override
	public void startup() {
		// start your application
	}

	@Override
	public void shutdown() {
		// shutdown your application (optional)
	}
	(...)

	public static final void main(final String... _args){
		Standalone.builder(StandaloneApp::new)
					.arguments(_args)
					(...)
					.parameters(StandaloneAppTestParameter.class)
					(...)
				.build();
					.ignite();
	}
}
org.bytemechanics

ByteMechanics Foundation

Foundation dedicated to provide opensource libraries and resources to simplify developers life

Versions

Version
2.0.7
2.0.6
2.0.5
2.0.4
2.0.3
2.0.2
2.0.1
2.0.0
1.2.0
1.1.3
1.1.2
1.1.1
1.1.0
1.0.2
1.0.1
1.0.0