Skip to content

Commit a9f4e75

Browse files
committed
Controllers are now compiled in parallel.
1 parent ec5ef3c commit a9f4e75

File tree

4 files changed

+173
-10
lines changed

4 files changed

+173
-10
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ bin
2222
.classpath
2323
.settings/org.scala-ide.sdt.core.prefs
2424
.cache-tests
25+
release.properties
2526
/proteus/
2627
*.versionsBackup
2728
.factorypath

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
# Changelog
22
Proteus Changelog.
33

4+
## v0.4.6
5+
### No issue
6+
7+
**Cleanup CHANGELOG.**
8+
9+
10+
[22eb4349dcc9e02](https://github.com/noboomu/proteus/commit/22eb4349dcc9e02) Joshua Bauer *2020-11-19 21:06:07*
11+
12+
**Prep for next release.**
13+
14+
415
[3d4deba169cedff](https://github.com/noboomu/proteus/commit/3d4deba169cedff) Joshua Bauer *2020-11-19 20:58:09*
516

617
**Update README.md**

proteus-core/src/main/java/io/sinistral/proteus/ProteusApplication.java

+39-10
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import java.util.Map;
5353
import java.util.Set;
5454
import java.util.concurrent.CompletableFuture;
55+
import java.util.concurrent.CopyOnWriteArrayList;
5556
import java.util.concurrent.CountDownLatch;
5657
import java.util.concurrent.ExecutorService;
5758
import java.util.concurrent.Executors;
@@ -276,24 +277,52 @@ public boolean isRunning()
276277
public void buildServer()
277278
{
278279

280+
ExecutorService handlerExecutor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
281+
282+
CountDownLatch countDownLatch = new CountDownLatch(registeredControllers.size());
283+
284+
CopyOnWriteArrayList<Class<? extends Supplier<RoutingHandler>>> routerClasses = new CopyOnWriteArrayList<>();
285+
279286
for (Class<?> controllerClass : registeredControllers)
280287
{
281288

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

284-
injector.injectMembers(generator);
291+
try
292+
{
285293

286-
try
287-
{
288-
Supplier<RoutingHandler> generatedRouteSupplier = injector.getInstance(generator.compileClass());
294+
log.debug("Compiling {}...", controllerClass);
289295

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

292-
} catch (Exception e)
293-
{
294-
log.error("Exception creating handlers for " + controllerClass.getName() + "!!!\n" + e.getMessage(), e);
295-
}
298+
injector.injectMembers(generator);
299+
300+
routerClasses.add(generator.compileClass());
301+
302+
log.debug("Compiled {}", controllerClass);
303+
304+
} catch (Exception e)
305+
{
306+
log.error("Exception creating handlers for {}", controllerClass.getName(), e);
307+
}
308+
309+
countDownLatch.countDown();
310+
});
311+
312+
}
313+
314+
try
315+
{
316+
countDownLatch.await();
317+
} catch (Exception e)
318+
{
319+
log.error("Failed waiting for handlers to generate", e);
320+
}
296321

322+
for (Class<? extends Supplier<RoutingHandler>> clazz : routerClasses)
323+
{
324+
Supplier<RoutingHandler> generatedRouteSupplier = injector.getInstance(clazz);
325+
router.addAll(generatedRouteSupplier.get());
297326
}
298327

299328
this.addDefaultRoutes(router);

proteus-swagger/pom.xml.releaseBackup

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<parent>
4+
<artifactId>proteus-project</artifactId>
5+
<groupId>io.sinistral</groupId>
6+
<version>0.4.6-SNAPSHOT</version>
7+
8+
</parent>
9+
<modelVersion>4.0.0</modelVersion>
10+
11+
<artifactId>proteus-swagger</artifactId>
12+
13+
<name>Proteus Swagger</name>
14+
15+
<packaging>jar</packaging>
16+
17+
18+
<build>
19+
<resources>
20+
<resource>
21+
<directory>src/main/resources</directory>
22+
<filtering>false</filtering>
23+
</resource>
24+
</resources>
25+
<testResources>
26+
<testResource>
27+
<directory>src/test/resources</directory>
28+
</testResource>
29+
<testResource>
30+
<directory>src/test/java</directory>
31+
<excludes>
32+
<exclude>**/*.java</exclude>
33+
</excludes>
34+
</testResource>
35+
</testResources>
36+
37+
<plugins>
38+
<plugin>
39+
<groupId>org.apache.maven.plugins</groupId>
40+
<artifactId>maven-jar-plugin</artifactId>
41+
<version>3.1.0</version>
42+
<executions>
43+
<execution>
44+
<goals>
45+
<goal>test-jar</goal>
46+
</goals>
47+
</execution>
48+
</executions>
49+
</plugin>
50+
<plugin>
51+
<groupId>org.apache.maven.plugins</groupId>
52+
<artifactId>maven-source-plugin</artifactId>
53+
</plugin>
54+
<plugin>
55+
<groupId>org.apache.maven.plugins</groupId>
56+
<artifactId>maven-javadoc-plugin</artifactId>
57+
</plugin>
58+
<plugin>
59+
<artifactId>maven-surefire-plugin</artifactId>
60+
<groupId>org.apache.maven.plugins</groupId>
61+
62+
</plugin>
63+
<plugin>
64+
<groupId>org.apache.maven.plugins</groupId>
65+
<artifactId>maven-gpg-plugin</artifactId>
66+
</plugin>
67+
<plugin>
68+
<groupId>org.sonatype.plugins</groupId>
69+
<artifactId>nexus-staging-maven-plugin</artifactId>
70+
</plugin>
71+
<plugin>
72+
<groupId>org.apache.maven.plugins</groupId>
73+
<artifactId>maven-release-plugin</artifactId>
74+
</plugin>
75+
76+
<plugin>
77+
<groupId>org.apache.maven.plugins</groupId>
78+
<artifactId>maven-compiler-plugin</artifactId>
79+
</plugin>
80+
</plugins>
81+
</build>
82+
83+
84+
<dependencies>
85+
86+
87+
88+
<dependency>
89+
<groupId>io.swagger</groupId>
90+
<artifactId>swagger-annotations</artifactId>
91+
<version>${swagger.version}</version>
92+
</dependency>
93+
<dependency>
94+
<groupId>io.swagger</groupId>
95+
<artifactId>swagger-core</artifactId>
96+
<version>${swagger.version}</version>
97+
<exclusions>
98+
<exclusion>
99+
<groupId>org.slf4j</groupId>
100+
<artifactId>slf4j-api</artifactId>
101+
</exclusion>
102+
</exclusions>
103+
</dependency>
104+
<dependency>
105+
<groupId>io.swagger</groupId>
106+
<artifactId>swagger-jaxrs</artifactId>
107+
<version>${swagger.version}</version>
108+
</dependency>
109+
<dependency>
110+
<groupId>io.sinistral</groupId>
111+
<artifactId>proteus-core</artifactId>
112+
<version>${proteus.version}</version>
113+
</dependency>
114+
115+
</dependencies>
116+
117+
118+
119+
<distributionManagement>
120+
<downloadUrl>https://oss.sonatype.org/content/groups/public/io/sinistral/proteus-swagger</downloadUrl>
121+
</distributionManagement>
122+
</project>

0 commit comments

Comments
 (0)