-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DI comparsion 1.1 - adding Bootique 2.0
Note that this is not the fastest startup configuration, but rather a typical setup with autoloading and command dispatch
- Loading branch information
Showing
7 changed files
with
161 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
10
bootique2/src/main/java/org/objectstyle/bootique2/Main.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
25
bootique2/src/main/java/org/objectstyle/bootique2/MainCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
32
bootique2/src/main/java/org/objectstyle/bootique2/MainModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
bootique2/src/main/resources/META-INF/services/io.bootique.BQModuleProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.objectstyle.bootique2.MainModule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters