Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates to README.md, removed jersey-guice dependency, Intellij suppo… #297

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ Getting Started
-------------------
Karyon is currently available as a snapshot via jfrog.

```java
```groovy
repositories {
maven { url 'http://oss.jfrog.org/oss-snapshot-local' }
}
compile "com.netflix.karyon:karyon3-core:3.0.1-SNAPSHOT'

dependencies {
compile "com.netflix.karyon:karyon3-core:3.0.1-SNAPSHOT"
}
```

----------
Expand All @@ -30,7 +33,7 @@ A Karyon3 based main should normally consist of a simple block of code to create

```java
public class HelloWorld {
public static void main(String[] args) {
public static void main(String[] args) throws Exception {
Karyon.createInjector(
// Default archaius based karyon configuration
ArchaiusKaryonConfiguration.builder()
Expand Down Expand Up @@ -344,7 +347,7 @@ public class MyHealthIndicator extends AbstractHealthIndicator {

To enable the HealthIndicator simply register it as a set binding. It will automatically be picked up by the default HealthIndicatorRegistry
```java
Multbindings.newSetBinder(binder()).addBinding().to(MyHealthIndicator.class);
Multibinder.newSetBinder(binder(), HealthIndicator.class).addBinding().to(MyHealthIndicator.class);
```
### Curated health check registry
TBD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.io.PrintWriter;
import java.io.StringWriter;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.GZIPOutputStream;
Expand All @@ -13,6 +14,7 @@
import javax.inject.Provider;
import javax.inject.Singleton;

import com.google.common.net.HttpHeaders;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -51,14 +53,14 @@ public void handle(HttpExchange exchange) throws IOException {

final String path = exchange.getRequestURI().getPath();

exchange.getResponseHeaders().set("Server", "KaryonAdmin");
exchange.getResponseHeaders().set(HttpHeaders.SERVER, "KaryonAdmin");

try {
// Redirect the server root to the configured remote server using the naming convension
//
if (path.equals("/")) {
String addr = new Interpolator(cfg).interpolate(config.remoteServer());
exchange.getResponseHeaders().set("Location", addr);
exchange.getResponseHeaders().set(HttpHeaders.LOCATION, addr);
exchange.sendResponseHeaders(302, 0);
exchange.close();
}
Expand All @@ -73,7 +75,7 @@ else if (path.equals("/favicon.ico")) {
for (int i = 1; i < parts.length; i++) {
p.add(parts[i]);
}
exchange.getResponseHeaders().set("Access-Control-Allow-Origin", config.accessControlAllowOrigin());
exchange.getResponseHeaders().set(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, config.accessControlAllowOrigin());

Object response = resources.get().invoke(controller, p);
writeResponse(exchange, 200, response);
Expand All @@ -91,7 +93,7 @@ else if (path.equals("/favicon.ico")) {
}

private boolean shouldUseGzip(HttpExchange exchange) {
final String encoding = exchange.getRequestHeaders().getFirst("Accept-Encoding");
final String encoding = exchange.getRequestHeaders().getFirst(HttpHeaders.ACCEPT_ENCODING);
return (encoding != null && encoding.toLowerCase().contains("gzip"));
}

Expand All @@ -103,15 +105,15 @@ private OutputStream getOutputStream(boolean useGzip, HttpExchange exchange) thr

private void writeResponse(HttpExchange exchange, int code, Object payload) throws IOException {
final boolean useGzip = shouldUseGzip(exchange);
exchange.getResponseHeaders().set("Content-Type", "application/json");
exchange.getResponseHeaders().set(HttpHeaders.CONTENT_TYPE, "application/json");
if (useGzip) {
exchange.getResponseHeaders().set("Content-Encoding", "gzip");
exchange.getResponseHeaders().set(HttpHeaders.CONTENT_ENCODING, "gzip");
}
// Size of 0 indicates to use a chunked response
exchange.sendResponseHeaders(code, 0);
try (OutputStream os = getOutputStream(useGzip, exchange)) {
if (payload instanceof String) {
os.write(((String) payload).getBytes(Charset.forName("UTF-8")));
os.write(((String) payload).getBytes(StandardCharsets.UTF_8));
} else {
mapper.writeValue(os, payload);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ private boolean isInTest() {
return false;
}

return cmd.startsWith("org.eclipse.jdt.internal.junit.runner") ||
return cmd.startsWith("org.eclipse.jdt.internal.junit.runner") ||
cmd.startsWith("com.intellij.rt.execution.application.AppMain") ||
cmd.contains("Gradle Test Executor");
}

Expand Down
1 change: 0 additions & 1 deletion karyon3-jetty/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ dependencies {
compile project(':karyon3-archaius2')
compile "com.netflix.governator:governator-jetty:${governator_version}"

compile 'com.sun.jersey.contribs:jersey-guice:1.19'
testCompile project(':karyon3-log4j2')
}

Expand Down
2 changes: 1 addition & 1 deletion karyon3-servlet/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ apply plugin: 'java'
dependencies {
compile project(':karyon3-core')
compile project(':karyon3-archaius2')
compile "com.sun.jersey.contribs:jersey-guice:${jersey_version}"
compile "com.google.inject.extensions:guice-servlet:${guice_version}"

provided "javax.servlet:servlet-api:2.5"

Expand Down