Skip to content

Commit

Permalink
DI comparsion 1.1 - adding Bootique 2.0
Browse files Browse the repository at this point in the history
Note that this is not the fastest startup configuration, but rather a typical setup
with autoloading and command dispatch
  • Loading branch information
andrus committed Apr 17, 2020
1 parent 319b586 commit 0006e51
Show file tree
Hide file tree
Showing 7 changed files with 161 additions and 9 deletions.
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,29 @@ Processing".

```
# Warmup build
$ mvn clean package
mvn clean package
# Measure assembly time with "-o" to ensure loading dependencies over
# the network does not interfere...
$ mvn clean package -o
mvn clean && mvn package -o
```

```
# Get the file sizes
$ find . -name '*.jar' |xargs ls -l |grep -v original |grep -v common
find . -name '*.jar' |xargs ls -l |grep -v original |grep -v common
```

```
# Execution time
$ time java -jar ./cayennedi/target/cayennedi-*.jar
$ time java -jar ./dagger/target/dagger-*.jar
$ time java -jar ./guice/target/guice-*.jar
$ time java -jar ./owb/target/owb-*.jar
$ time java -jar ./spring/target/spring-*.jar
$ time java -jar ./springboot/target/springboot-*.jar
time java -jar ./bootique2/target/bootique2-*.jar
time java -jar ./cayennedi/target/cayennedi-*.jar
time java -jar ./dagger/target/dagger-*.jar
time java -jar ./guice/target/guice-*.jar
time java -jar ./owb/target/owb-*.jar
time java -jar ./spring/target/spring-*.jar
time java -jar ./springboot/target/springboot-*.jar
```

## Results
Expand Down
52 changes: 52 additions & 0 deletions bootique2/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<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.objectstyle.di</groupId>
<artifactId>di-comparison</artifactId>
<version>1.1-SNAPSHOT</version>
</parent>

<artifactId>bootique2</artifactId>
<packaging>jar</packaging>

<properties>
<main.class>org.objectstyle.bootique2.Main</main.class>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.bootique.bom</groupId>
<artifactId>bootique-bom</artifactId>
<version>${bootique2.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.objectstyle.di</groupId>
<artifactId>common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.bootique</groupId>
<artifactId>bootique</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
10 changes: 10 additions & 0 deletions bootique2/src/main/java/org/objectstyle/bootique2/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.objectstyle.bootique2;

import io.bootique.Bootique;

public class Main {

public static void main(String[] args) {
Bootique.app(args).autoLoadModules().exec().exit();
}
}
25 changes: 25 additions & 0 deletions bootique2/src/main/java/org/objectstyle/bootique2/MainCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.objectstyle.bootique2;

import io.bootique.cli.Cli;
import io.bootique.command.Command;
import io.bootique.command.CommandOutcome;
import org.objectstyle.di.service.Service;

import javax.inject.Inject;
import javax.inject.Provider;

public class MainCommand implements Command {

private Provider<Service> serviceProvider;

@Inject
public MainCommand(Provider<Service> serviceProvider) {
this.serviceProvider = serviceProvider;
}

@Override
public CommandOutcome run(Cli cli) {
System.out.println(serviceProvider.get().doIt());
return CommandOutcome.succeeded();
}
}
32 changes: 32 additions & 0 deletions bootique2/src/main/java/org/objectstyle/bootique2/MainModule.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.objectstyle.bootique2;

import io.bootique.BQCoreModule;
import io.bootique.BaseModule;
import io.bootique.di.Binder;
import io.bootique.di.Provides;
import org.objectstyle.di.service.Service;
import org.objectstyle.di.service.ServiceImpl;
import org.objectstyle.di.service.SubService;
import org.objectstyle.di.service.SubServiceImpl;

import javax.inject.Singleton;

public class MainModule extends BaseModule {

@Override
public void configure(Binder binder) {
BQCoreModule.extend(binder).setDefaultCommand(MainCommand.class);
}

@Provides
@Singleton
Service provideService(SubService subService) {
return new ServiceImpl(subService);
}

@Provides
@Singleton
SubService provideSubService() {
return new SubServiceImpl();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.objectstyle.bootique2.MainModule
26 changes: 26 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>

<bootique2.version>2.0-SNAPSHOT</bootique2.version>
<dagger.version>2.27</dagger.version>
<guice.version>4.2.3</guice.version>
<cayenne.version>4.1.RC2</cayenne.version>
Expand All @@ -24,6 +25,7 @@

<modules>
<module>common</module>
<module>bootique2</module>
<module>dagger</module>
<module>guice</module>
<module>cayennedi</module>
Expand All @@ -32,6 +34,30 @@
<module>owb</module>
</modules>

<repositories>
<repository>
<id>snapshots</id>
<url>https://maven.objectstyle.org/nexus/content/repositories/linkrest-snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>

<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>

<build>
<pluginManagement>
<plugins>
Expand Down

0 comments on commit 0006e51

Please sign in to comment.