Skip to content

Commit

Permalink
Merge pull request #291 from elandau/3.x_archaius
Browse files Browse the repository at this point in the history
More javadoc fixes
  • Loading branch information
elandau committed Sep 25, 2015
2 parents bd36e13 + 94a7500 commit 6716ea9
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 126 deletions.
2 changes: 1 addition & 1 deletion buildViaTravis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo -e "Build Pull Request #$TRAVIS_PULL_REQUEST => Branch [$TRAVIS_BRANCH]"
./gradlew build
./gradlew build javadoc
elif [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_TAG" == "" ]; then
echo -e 'Build Branch with Snapshot => Branch ['$TRAVIS_BRANCH']'
./gradlew -Prelease.travisci=true -PbintrayUser="${bintrayUser}" -PbintrayKey="${bintrayKey}" -PsonatypeUsername="${sonatypeUsername}" -PsonatypePassword="${sonatypePassword}" build snapshot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static abstract class Builder<T extends Builder<T>> extends DefaultKaryon
* Configuration name to use for property loading. Default configuration
* name is 'application'. This value is injectable as
*
* @Named("karyon.configName") String configName
* <code>{@literal @}Named("karyon.configName") String configName</code>
*
* @param value
* @return
Expand Down
71 changes: 35 additions & 36 deletions karyon3-core/src/main/java/com/netflix/karyon/Karyon.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,41 @@
* shutdown mechanism. All application services are specified using Guice modules, with
* any application services simply being bound asEagerSingleton.
*
<pre>
{@code
@Path("/")
public class HelloWorldApp extends DefaultLifecycleListener {
public static void main(String[] args) throws InterruptedException {
Karyon.createInjector(
ArchaiusGovernatorConfiguration.builder()
.addModules(
new JettyModule(),
new JerseyServletModule() {
@Override
protected void configureServlets() {
serve("/*").with(GuiceContainer.class);
bind(GuiceContainer.class).asEagerSingleton();
bind(HelloWorldApp.class).asEagerSingleton();
}
}
)
.build()
)
.awaitTermination();
}
@GET
public String sayHello() {
return "hello world";
}
@Override
public void onStarted() {
System.out.println("Started ***** ");
}
}
}
</pre>
* <code>
*
* {@literal @}Path("/")
* public class HelloWorldApp extends DefaultLifecycleListener {
* public static void main(String[] args) throws InterruptedException {
* Karyon.createInjector(
* ArchaiusGovernatorConfiguration.builder()
* .addModules(
* new JettyModule(),
* new JerseyServletModule() {
* {@literal @}Override
* protected void configureServlets() {
* serve("/*").with(GuiceContainer.class);
* bind(GuiceContainer.class).asEagerSingleton();
*
* bind(HelloWorldApp.class).asEagerSingleton();
* }
* }
* )
* .build()
* )
* .awaitTermination();
* }
*
* {@literal @}GET
* public String sayHello() {
* return "hello world";
* }
*
* {@literal @}Override
* public void onStarted() {
* System.out.println("Started ***** ");
* }
* }
* </code>
* @author elandau
*
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,32 @@
* scripts or call a remote service.
*
* To register a health indicator,
* <pre>
* {@code
* <code>
* Multbindings.newSetBinder(binder()).addBinding().to(MyHealthIndicator.class);
* }
* </pre>
* </code>
*
* Here is a sample health indicator implementation.
*
* <pre>
* {@code
* public class MyHealthIndicator implements HealthIndicator {
* @Inject
* <code>
* public class MyHealthIndicator extends AbstractHealthIndicator {
* {@literal @}Inject
* public MyHealthIndicator(MyService service) {
* this.service = service;
* }
*
* @Override
* public CompletableFuture<HealthIndicatorStatus> check() {
* if (service.getErrorRate() > 0.1) {
* return CompletableFuture.completedFuture(HealthIndicatorStatuses.unhealthy(getName()));
* {@literal @}Inject
*
* public CompletableFuture{@literal <}HealthIndicatorStatus{@literal >} check() {
* if (service.getErrorRate() {@literal >} 0.1) {
* return CompletableFuture.completedFuture(unhealthy(getName()));
* }
* else {
* return CompletableFuture.completedFuture(HealthIndicatorStatuses.healthy(getName()));
* return CompletableFuture.completedFuture(healthy(getName()));
* }
* }
* }
* }
* </pre>
* </code>
*
* @author elandau
*
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,13 @@
* list of all active indicators. To create a curated list of {@link HealthIndicator}s regardless of
* Guice bindings create a binding to HealthIndicatorRegistry as follows
*
* <pre>
* {@code
*
* @Provides
* @Singleton
* HealthIndicatorRegistry getHealthIndicatorRegistry(@Named("cpu") HealthIndicator cpuIndicator, @Named("foo") HealthIndicator fooIndicator) {
* <code>
* {@literal @}Provides
* {@literal @}Singleton
* HealthIndicatorRegistry getHealthIndicatorRegistry({@literal @}Named("cpu") HealthIndicator cpuIndicator, {@literal @}Named("foo") HealthIndicator fooIndicator) {
* return HealthIndicatorRegistry.from(cpuIndicator, fooIndicator);
* }
*
* }
* </pre>
* </code>
*
* @author elandau
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,17 @@
*
* To make lifecycle state entirely manual set the following binding
*
* <pre>
* {@code
* <code>
* bind(ApplicationLifecycle.class).to(ManualApplicationLifecycle.class);
* }
* </pre>
* </code>
*
* The inject ApplicationLifecycle and set it to Starting based on your custom logic
*
* <pre>
* {@code
* @Singleton
* <code>
* {@literal @}Singleton
* public class Foo {
* private final ApplicationLifecycle appLifecycle
* @Inject
* {@literal @}Inject
* public Foo(ApplicationLifecycle appLifecycle) {
* this.appLifecycle = appLifecycle; }
* }
Expand All @@ -38,26 +35,22 @@
* this.appLifecycle.setStarted();
* }
* }
* }
* </pre>
* </code>
*
* To linked ApplicationLifecycle to both to DI lifecycle and manual state,
*
* <pre>
* {@code
* <code>
* bind(ApplicationLifecycle.class).toInstance(new LifecycleListenerApplicationLifecycle(LifecycleState.Starting));
* }
* </pre>
* </code>
*
* The manually set the lifecycle,
*
* <pre>
* {@code
* @Singleton
* <code>
* {@literal @}Singleton
* public class Foo {
* private final ApplicationLifecycle appLifecycle;
*
* @Inject
* {@literal @}Inject
* public Foo(ApplicationLifecycle appLifecycle) {
* this.appLifecycle = appLifecycle;
* }
Expand All @@ -66,8 +59,7 @@
* this.appLifecycle.setStarted();
* }
* }
* }
* </pre>
* </code>
*
* @author elandau
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
/**
* To use an implementation of <code>Log4jConfigurator</code>
*
* {@code
* Multibinder<Log4jConfigurator> appenderBinder = Multibinder.newSetBinder(binder(), Log4jConfigurator.class);
* appenderBinder.addBinding().to(Log4jConfiguratorImpl.class);
*
*
* }
*/

public interface Log4jConfigurator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,70 +18,63 @@
* or simple prefix.
*
* Example,
* <pre>
* {@code
* <code>
new RxNettyServerModule() {
@Override
{@literal @}Override
protected void configureEndpoints() {
serve("/foo").with(FooRequestHandler.class);
serve("*.html", "*.ico").with(StaticFileRequestHandler.class);
}
},
* }
}
* </code>
*
* To support multiple servers (i.e ports) simply qualify the serve() statements with a standard DI Qualifier.
* By default Karyon will construct an HttpServer and ServerConfig using the same Qualifier and associate
* the server with these routes.
*
* <pre>
* {@code
* <code>
new RxNettyServerModule() {
@Override
{@literal @}Override
protected void configureEndpoints() {
serve(MyServerName.class, "/foo").with(FooRequestHandler.class);
}
},
* }
* </pre>
}
* </code>
*
* By default configuration for the server will be associate with the prefix: karyon.httpserver.{SimpleQualifierName}.
* Where SimpleQulifierName is the simple class name of the qualifier. Alternatively a custom configuration may
* be constructed using the binding
*
* <pre>
* {@code
* <code>
new AbstractModule() {
@Provides
@Singleton
@MyServerQualifier
{@literal @}Provides
{@literal @}Singleton
{@literal @}MyServerQualifier
public ServerConfig getServerConfig() {
return ...; //
}
}
* }
* </pre>
* </code>
*
* By default Kayron will configure a plain RxNetty HttpServer<ByteBuf, ByteBuf>. To construct a server with custom
* By default Kayron will configure a plain RxNetty HttpServer{@literal <}ByteBuf, ByteBuf{@literal >}. To construct a server with custom
* configuration simply create a binding for the qualified server (note that the default server has an implicit qualifier
* of DefaultServer.class)
*
* <pre>
* {@code
*
* <code>
new AbstractModule() {
@Provides
@Singleton
@MyServerQualifier
HttpServer<ByteBuf, ByteBuf> getShutdownServer(@MyServerQualifier ServerConfig config, final @MyServerQualifier Set<HttpEndpointDefinition> defs) {
{@literal @}Provides
{@literal @}Singleton
{@literal @}MyServerQualifier
HttpServer{@literal <}ByteBuf, ByteBuf{@literal >} getShutdownServer({@literal @}MyServerQualifier ServerConfig config, final {@literal @}MyServerQualifier Set{@literal <}HttpEndpointDefinition{@literal >} defs) {
return RxNetty.newHttpServerBuilder(
config.getServerPort(),
new HttpRoutingRequestHandler(def)
)
.build();
}
}
* }
* </pre>
* </code>
*
* @author elandau
*
*/
Expand Down Expand Up @@ -142,11 +135,6 @@ protected final EndpointKeyBindingBuilder serveRegex(Class<? extends Annotation>
return endpointsModuleBuilder.serveRegex(qualifier, patterns);
}

/**
* See the EDSL examples at {@link EndpointModule#configureEndpoints()}
*
* @since 2.0
*/
public static interface EndpointKeyBindingBuilder {
void with(Class<? extends RequestHandler<ByteBuf, ByteBuf>> endpointKey);
void with(Key<? extends RequestHandler<ByteBuf, ByteBuf>> endpointKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@
* ServletContextListener's contextDestroyed event.
*
* To use, subclass your main server class from GovernatorServletContextListener
* <pre>
* {@code
*
* <code>
package com.cloudservice.StartServer;
public class StartServer extends KaryonServletContextListener
{
@Override
{@literal @}Override
protected LifecycleInjector createInjector() {
return Governator.createInjector(
new JerseyServletModule() {
@Override
{@literal @}Override
protected void configureServlets() {
serve("/REST/*").with(GuiceContainer.class);
binder().bind(GuiceContainer.class).asEagerSingleton();
Expand All @@ -37,12 +35,11 @@ protected void configureServlets() {
);
}
}
* }
* </pre>
* </code>
*
* Then reference this class from web.xml.
*
<PRE>
* <code>
&lt;filter&gt;
&lt;filter-name&gt;guiceFilter&lt;/filter-name&gt;
&lt;filter-class&gt;com.google.inject.servlet.GuiceFilter&lt;/filter-class&gt;
Expand All @@ -57,7 +54,7 @@ protected void configureServlets() {
&lt;listener-class&gt;com.cloudservice.StartServer&lt;/listener-class&gt;
&lt;/listener&gt;
</PRE>
* </code>
*
* @author Eran Landau
*/
Expand Down

0 comments on commit 6716ea9

Please sign in to comment.