GithubHelp home page GithubHelp logo

tempbottle / spring-vertx-ext Goto Github PK

View Code? Open in Web Editor NEW

This project forked from amoahcp/spring-vertx-ext

0.0 2.0 0.0 18.02 MB

A spring vertx mod which creates spring aware verticles

License: Apache License 2.0

Java 100.00%

spring-vertx-ext's Introduction

spring-vertx-ext

A spring vertx extension which creates spring aware verticles. This extension creates for each spring aware Verticle an own spring context. Spring Verticles can deploy "normal" Verticles and vice versa.

You should use Spring-Verticles in „worker mode“ or use vertx.executeBlocking when calling blocking methods. Avoid blocking the event loop!

##Usage:## Add the spring-vertx-ext dependency to your project, in case of maven like this:

        <dependency>
            <groupId>org.jacpfx.vertx.spring</groupId>
            <artifactId>vertx-spring-ext</artifactId>
            <version>2.0.2</version>
        </dependency>

Version 2.0.2 uses Vert.X 3.2.0 and Spring 4.2.3.RELEASE

To make a Verticle spring aware you first need a (Java) Spring configuration class like this:

@Configuration
@ComponentScan
public class TestConfiguration {
…
}

xml configuration is not supported! (you can import your xml in your java configuration)

Next you create a verticle class and annotate it with @SpringVerticle.

@Component
@SpringVerticle(springConfig=TestConfiguration.class)
public class SpringVerticle extends AbstractVerticle {
    @Inject
    private SayHelloBean bean;

    @Override
    public void start() {
       ...
    }

    @Override
    public void stop() {
       ...
    }
}

deployment

In case of using a spring-verticle as the initial verticle of your project, add the prefix "java-spring" to your vertex class.

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>2.3</version>
        <executions>
            <execution>
                <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <transformers>
                            <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <manifestEntries>
                                    <Main-Class>io.vertx.core.Starter</Main-Class>
                                    <Main-Verticle>java-spring:org.jacpfx.service.SpringVerticle</Main-Verticle>
                                </manifestEntries>
                            </transformer>
                            <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                <resource>META-INF/services/io.vertx.core.spi.VerticleFactory</resource>
                            </transformer>
                        </transformers>
                        <outputFile>${project.build.directory}/${artifactId}-${version}-fat.jar</outputFile>
                    </configuration>
                </execution>
            </executions>
        </plugin>

For embedded deployment use:

vertx.deployVerticle("java-spring:org.jacpfx.service.SpringVerticle"); 

spring-vertx-ext's People

Contributors

jacpfx avatar amoahcp avatar jotschi avatar

Watchers

tempbottle avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.