Skip to content

Commit

Permalink
adding springboot
Browse files Browse the repository at this point in the history
  • Loading branch information
andrus committed Mar 31, 2018
1 parent eb057ee commit dce1c85
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 8 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ $ time java -jar ./guice/target/guice-1.0-SNAPSHOT.jar

## Results

|DI|Jar with Dependencies, KB|Exec time, ms|
|----|-----|-----|
|Cayenne DI|78.9|166|
|Dagger| 51.3|122|
|Guice|3439.7|353|
|DI|Jar with Dependencies, KB|Compile Time, ms|Exec time, ms|
|----|-----|-----|----|
|Cayenne DI|79|93|166|
|Dagger| 51|1320|122|
|Guice|3440|483|353|
|Spring Boot|6993|527|1628|
9 changes: 6 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
<dagger.version>2.15</dagger.version>
<guice.version>4.2.0</guice.version>
<cayenne.version>4.0.B2</cayenne.version>

<springboot.version>2.0.0.RELEASE</springboot.version>
</properties>

<modules>
<module>common</module>
<module>dagger</module>
<module>guice</module>
<module>cayennedi</module>
<module>springboot</module>
</modules>

<build>
Expand Down Expand Up @@ -56,8 +57,10 @@
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>${main.class}</mainClass>
</transformer>
</transformers>
Expand Down
52 changes: 52 additions & 0 deletions springboot/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.0-SNAPSHOT</version>
</parent>

<artifactId>springboot</artifactId>
<version>1.0-SNAPSHOT</version>

<packaging>jar</packaging>

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

<dependencies>
<dependency>
<groupId>org.objectstyle.di</groupId>
<artifactId>common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>${springboot.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${springboot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

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

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 org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class Config {

@Bean
public Service service(SubService subService) {
return new ServiceImpl(subService);
}

@Bean
public SubService subService() {
return new SubServiceImpl();
}
}
12 changes: 12 additions & 0 deletions springboot/src/main/java/org/objectstyle/springboot/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.objectstyle.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Main {

public static void main(String[] args) {
SpringApplication.run(Main.class, args);
}
}
20 changes: 20 additions & 0 deletions springboot/src/main/java/org/objectstyle/springboot/Runner.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.objectstyle.springboot;

import org.objectstyle.di.service.Service;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

@Component
public class Runner implements CommandLineRunner {

private Service service;

public Runner(Service service) {
this.service = service;
}

@Override
public void run(String... args) throws Exception {
System.out.println(service.doIt());
}
}

0 comments on commit dce1c85

Please sign in to comment.