Skip to content

Commit

Permalink
Controllers are now compiled in parallel.
Browse files Browse the repository at this point in the history
  • Loading branch information
noboomu committed Nov 19, 2020
1 parent ec5ef3c commit a9f4e75
Show file tree
Hide file tree
Showing 4 changed files with 173 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ bin
.classpath
.settings/org.scala-ide.sdt.core.prefs
.cache-tests
release.properties
/proteus/
*.versionsBackup
.factorypath
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# Changelog
Proteus Changelog.

## v0.4.6
### No issue

**Cleanup CHANGELOG.**


[22eb4349dcc9e02](https://github.com/noboomu/proteus/commit/22eb4349dcc9e02) Joshua Bauer *2020-11-19 21:06:07*

**Prep for next release.**


[3d4deba169cedff](https://github.com/noboomu/proteus/commit/3d4deba169cedff) Joshua Bauer *2020-11-19 20:58:09*

**Update README.md**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
Expand Down Expand Up @@ -276,24 +277,52 @@ public boolean isRunning()
public void buildServer()
{

ExecutorService handlerExecutor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());

CountDownLatch countDownLatch = new CountDownLatch(registeredControllers.size());

CopyOnWriteArrayList<Class<? extends Supplier<RoutingHandler>>> routerClasses = new CopyOnWriteArrayList<>();

for (Class<?> controllerClass : registeredControllers)
{

HandlerGenerator generator = new HandlerGenerator("io.sinistral.proteus.controllers.handlers", controllerClass);
handlerExecutor.execute(() -> {

injector.injectMembers(generator);
try
{

try
{
Supplier<RoutingHandler> generatedRouteSupplier = injector.getInstance(generator.compileClass());
log.debug("Compiling {}...", controllerClass);

router.addAll(generatedRouteSupplier.get());
HandlerGenerator generator = new HandlerGenerator("io.sinistral.proteus.controllers.handlers", controllerClass);

} catch (Exception e)
{
log.error("Exception creating handlers for " + controllerClass.getName() + "!!!\n" + e.getMessage(), e);
}
injector.injectMembers(generator);

routerClasses.add(generator.compileClass());

log.debug("Compiled {}", controllerClass);

} catch (Exception e)
{
log.error("Exception creating handlers for {}", controllerClass.getName(), e);
}

countDownLatch.countDown();
});

}

try
{
countDownLatch.await();
} catch (Exception e)
{
log.error("Failed waiting for handlers to generate", e);
}

for (Class<? extends Supplier<RoutingHandler>> clazz : routerClasses)
{
Supplier<RoutingHandler> generatedRouteSupplier = injector.getInstance(clazz);
router.addAll(generatedRouteSupplier.get());
}

this.addDefaultRoutes(router);
Expand Down
122 changes: 122 additions & 0 deletions proteus-swagger/pom.xml.releaseBackup
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?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">
<parent>
<artifactId>proteus-project</artifactId>
<groupId>io.sinistral</groupId>
<version>0.4.6-SNAPSHOT</version>

</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>proteus-swagger</artifactId>

<name>Proteus Swagger</name>

<packaging>jar</packaging>


<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
<testResource>
<directory>src/test/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
</testResources>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>

</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
</plugins>
</build>


<dependencies>



<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-core</artifactId>
<version>${swagger.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jaxrs</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>io.sinistral</groupId>
<artifactId>proteus-core</artifactId>
<version>${proteus.version}</version>
</dependency>

</dependencies>



<distributionManagement>
<downloadUrl>https://oss.sonatype.org/content/groups/public/io/sinistral/proteus-swagger</downloadUrl>
</distributionManagement>
</project>

0 comments on commit a9f4e75

Please sign in to comment.