-
Notifications
You must be signed in to change notification settings - Fork 927
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Motivation: Dropwizard is another popular framework we'd like to integrate Armeria into. Modifications: - Add `armeria-dropwizard` which provides a Dropwizard bundle and SPI implementations. - Add documentation about Dropwizard integration - Add an example Result: Closes #2165
- Loading branch information
1 parent
626a341
commit db47ad3
Showing
56 changed files
with
2,681 additions
and
71 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,33 @@ | ||
buildscript { | ||
repositories { | ||
gradlePluginPortal() | ||
} | ||
dependencies { | ||
classpath "com.github.jengelman.gradle.plugins:shadow:${managedVersions['com.github.jengelman.gradle.plugins:shadow']}" | ||
} | ||
} | ||
|
||
dependencies { | ||
compile project(':jetty') | ||
// Dropwizard | ||
['core', 'util', 'lifecycle', 'jackson', 'validation', 'jetty', 'jersey'].each { | ||
compile "io.dropwizard:dropwizard-$it" | ||
} | ||
// Dropwizard Metrics | ||
compile 'io.dropwizard.metrics:metrics-core' | ||
|
||
testCompile 'io.dropwizard:dropwizard-testing' | ||
} | ||
|
||
// Do not relocate Guava because it's part of Dropwizard's public API. | ||
[tasks.shadedJar, tasks.shadedTestJar].each { task -> | ||
task.relocators.clear() | ||
project.ext.relocations.each { Map<String, String> props -> | ||
def from = props['from'] | ||
def to = props['to'] | ||
if (from in ['com.google.common', 'com.google.thirdparty.publicsuffix']) { | ||
return | ||
} | ||
task.relocate from, to | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
dropwizard/src/main/java/com/linecorp/armeria/dropwizard/ArmeriaBundle.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,47 @@ | ||
/* | ||
* Copyright 2019 LINE Corporation | ||
* | ||
* LINE Corporation licenses this file to you under the Apache License, | ||
* version 2.0 (the "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at: | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package com.linecorp.armeria.dropwizard; | ||
|
||
import com.linecorp.armeria.server.Server; | ||
import com.linecorp.armeria.server.ServerBuilder; | ||
|
||
import io.dropwizard.Configuration; | ||
import io.dropwizard.ConfiguredBundle; | ||
import io.dropwizard.setup.Bootstrap; | ||
import io.dropwizard.setup.Environment; | ||
|
||
/** | ||
* A Dropwizard {@link ConfiguredBundle} that routes requests through an | ||
* Armeria {@link Server} rather than the default Jetty server. | ||
* | ||
* @param <C> The Dropwizard {@link Configuration} type. | ||
*/ | ||
public abstract class ArmeriaBundle<C extends Configuration> | ||
implements ConfiguredBundle<C>, ArmeriaServerConfigurator { | ||
|
||
@Override | ||
public void initialize(Bootstrap<?> bootstrap) { | ||
} | ||
|
||
@Override | ||
public void run(C configuration, Environment environment) throws Exception { | ||
final ManagedArmeriaServer<C> managedArmeriaServer = new ManagedArmeriaServer<>(configuration, this); | ||
environment.lifecycle().manage(managedArmeriaServer); | ||
} | ||
|
||
@Override | ||
public abstract void configure(ServerBuilder builder); | ||
} |
30 changes: 30 additions & 0 deletions
30
dropwizard/src/main/java/com/linecorp/armeria/dropwizard/ArmeriaServerConfigurator.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,30 @@ | ||
/* | ||
* Copyright 2019 LINE Corporation | ||
* | ||
* LINE Corporation licenses this file to you under the Apache License, | ||
* version 2.0 (the "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at: | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package com.linecorp.armeria.dropwizard; | ||
|
||
import com.linecorp.armeria.server.ServerBuilder; | ||
|
||
/** | ||
* Interface used to configure a service on the default armeria server. Can be | ||
* used to register arbitrary services. | ||
*/ | ||
@FunctionalInterface | ||
interface ArmeriaServerConfigurator { | ||
/** | ||
* Configures the server using the specified {@link ServerBuilder}. | ||
*/ | ||
void configure(ServerBuilder builder); | ||
} |
Oops, something went wrong.