Vert.x Skeleton

Skeleton for a Vert.x service project

License

License

GroupId

GroupId

com.github.malkomich
ArtifactId

ArtifactId

vertx-skeleton
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

Vert.x Skeleton
Skeleton for a Vert.x service project
Project URL

Project URL

https://github.com/malkomich/vertx-skeleton
Source Code Management

Source Code Management

https://github.com/malkomich/vertx-skeleton

Download vertx-skeleton

How to add to project

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

Dependencies

compile (10)

Group / Artifact Type Version
io.vertx : vertx-core jar
io.vertx : vertx-config jar
io.vertx : vertx-health-check jar 3.5.4
io.vertx : vertx-service-proxy jar
io.vertx : vertx-codegen jar
io.vertx : vertx-web jar
io.vertx : vertx-web-client jar
com.google.inject : guice jar 4.1.0
commons-logging : commons-logging jar 1.1.1
ch.qos.logback : logback-classic jar 1.2.3

Project Modules

There are no modules declared in this project.

Vertx Skeleton

Build Status

Overview

Skeleton infrastructure classes for Vert.x projects.

Requisites

  • Java 8+
  • Maven 3+

Install

Gradle

	dependencies {
	    compile 'com.github.malkomich:vertx-skeleton:1.0.2'
	}

Maven

	<dependency>
	    <groupId>com.github.malkomich</groupId>
	    <artifactId>vertx-skeleton</artifactId>
	    <version>1.0.2</version>
	</dependency>

Usage

CONFIG MODULE:
public class CustomConfigModule extends ConfigModule {

    public CustomConfigModule(final Vertx vertx, final JsonObject config) {
        super(vertx, config);
    }

    @Override
    protected void configure() {
        bind(ThirdPartyService.class).toInstance(thirdPartyService());
    }

    private ThirdPartyService thirdPartyService() {
        return new ThirdPartyService();
    }
}
SERVICE:
@ProxyGen
public interface CustomService extends VertxService {

    @Fluent
    @Override
    CustomService execute(final JsonObject json, final Handler<AsyncResult<Void>> handler);

    @ProxyClose
    @Override
    void close();
}

public class CustomServiceImpl implements CustomService {

    private ThirdPartyService thirdPartyService;
    
    public CustomServiceImpl(final ThirdPartyService thirdPartyService) {
        this.thirdPartyService = thirdPartyService;
    }


    @Override
    public CustomService execute(final JsonObject json,
                                 final Handler<AsyncResult<Void>> handler) {
        handler.handle(Future.succeededFuture()); // TODO: Implement your custom service logic
        return this;
    }

    @Override
    public void close() {
        eventService.close(onClosed ->
            System.out.println("Service was closed"));
    }
}
VERTICLE:
public class CustomVerticle extends ServiceVerticle<CustomService> {

    public static final String ADDRESS = "customAddress";

    @Inject
    private ThirdPartyService thirdPartyService;

    @Override
    protected CustomService initializeService() {
        return new CustomServiceImpl(thirdPartyService);
    }

    @Override
    protected String eventBusAddress() {
        return ADDRESS;
    }
}
LAUNCHER:
public class ServiceLauncher {

    private static final String ENDPOINT_PATH = "/your-endpoint-path";

    public static void main(final String[] args) {
        new ServiceLauncher().launch();
    }

    private void launch() {
        VerticleLauncher.builder()
            .configModules(CustomConfigModule.class)
            .verticles(CustomVerticle.class) // Take care of verticles order (in case of dependency)
            .withPublicEndpoint(ENDPOINT_PATH, CustomVerticle.ADDRESS, CustomService.class)
            .execute();
    }
}

License

Apache License

Versions

Version
1.0.1
1.0.0