-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from RedRoma/release/1.0
Release/1.0
- Loading branch information
Showing
18 changed files
with
1,742 additions
and
43 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 |
---|---|---|
@@ -1,4 +1,9 @@ | ||
sudo: false | ||
sudo: required | ||
language: java | ||
jdk: | ||
- oraclejdk8 | ||
|
||
before_install: | ||
- sudo apt-get update -qq | ||
- sudo apt-get update && sudo apt-get install oracle-java8-installer | ||
- java -version |
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 |
---|---|---|
@@ -1,13 +1,46 @@ | ||
# Banana Service Java Client | ||
Aroma Java Client | ||
============================================== | ||
|
||
[![Build Status](http://jenkins.sirwellington.tech/view/Banana/job/Banana%20Service/badge/icon)](http://jenkins.sirwellington.tech/view/Banana/job/Banana%20Service/) | ||
[<img src="https://raw.githubusercontent.com/RedRoma/Aroma/develop/Graphics/Logo.png" width="300">](https://github.com/RedRoma/Aroma) | ||
|
||
The Java Client to the Famed Banana Service! | ||
[![Build Status](http://jenkins.sirwellington.tech/view/Aroma/job/Aroma%20Java%20Client/badge/icon)](http://jenkins.sirwellington.tech/view/Aroma/job/Aroma%20Java%20Client/) | ||
|
||
The Banana Service is Service Notifications for Developers. | ||
The Java Client to the Famed Aroma Service! | ||
|
||
Developers are able to be notified of Urgent events that occur | ||
within the Micro-Services. | ||
The Aroma Service is Service Notifications for Developers. | ||
|
||
The Banana Service can also be used to setup Service | ||
Health Checks and Alerts. | ||
# Download | ||
|
||
To use, simply add the following maven dependency. | ||
|
||
>Not Released Yet | ||
## Release | ||
```xml | ||
<dependency> | ||
<groupId>tech.aroma</groupId> | ||
<artifactId></artifactId> | ||
<version>1.1</version> | ||
</dependency> | ||
``` | ||
|
||
## Snapshot | ||
|
||
>First add the Snapshot Repository | ||
```xml | ||
<repository> | ||
<id>ossrh</id> | ||
<url>https://oss.sonatype.org/content/repositories/snapshots</url> | ||
</repository> | ||
``` | ||
|
||
```xml | ||
<dependency> | ||
<groupId>tech.aroma</groupId> | ||
<artifactId>aroma-java-client</artifactId> | ||
<version>1.1-SNAPSHOT</version> | ||
</dependency> | ||
``` | ||
|
||
# [Javadocs](http://www.javadoc.io/doc/tech.aroma/aroma-java-client/) | ||
|
||
# API |
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 |
---|---|---|
|
@@ -5,15 +5,15 @@ | |
<parent> | ||
<groupId>tech.aroma.banana</groupId> | ||
<artifactId>banana</artifactId> | ||
<version>1.1-SNAPSHOT</version> | ||
<version>1.3</version> | ||
</parent> | ||
|
||
<artifactId>banana-java-client</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<version>1.0</version> | ||
<name>${project.artifactId}</name> | ||
<packaging>jar</packaging> | ||
|
||
<url>https://github.com/AromaTech/banana-thrift</url> | ||
<url>https://github.com/RedRoma/banana-thrift</url> | ||
<description> | ||
Part of the Banana Service Project. | ||
Simplicity is paramount. | ||
|
@@ -22,13 +22,13 @@ | |
|
||
<issueManagement> | ||
<system>GitHub Issues</system> | ||
<url>https://github.com/AromaTech/banana-java-client/issues</url> | ||
<url>https://github.com/RedRoma/banana-java-client/issues</url> | ||
</issueManagement> | ||
|
||
<scm> | ||
<connection>scm:git:[email protected]:AromaTech/banana-java-client.git</connection> | ||
<developerConnection>scm:git:[email protected]:AromaTech/banana-java-client.git</developerConnection> | ||
<url>[email protected]:AromaTech/banana-java-client-annotations.git</url> | ||
<connection>scm:git:[email protected]:RedRoma/banana-java-client.git</connection> | ||
<developerConnection>scm:git:[email protected]:RedRoma/banana-java-client.git</developerConnection> | ||
<url>[email protected]:RedRoma/banana-java-client-annotations.git</url> | ||
</scm> | ||
|
||
<inceptionYear>2015</inceptionYear> | ||
|
@@ -40,15 +40,82 @@ | |
<!-- END OF POM METADATA --> | ||
|
||
<dependencies> | ||
|
||
<!--=======================--> | ||
<!--UNIT TESTING--> | ||
<!--=======================--> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-all</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.hamcrest</groupId> | ||
<artifactId>hamcrest-library</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>tech.sirwellington.alchemy</groupId> | ||
<artifactId>alchemy-test</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.google.guava</groupId> | ||
<artifactId>guava</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-simple</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
|
||
<!--=======================--> | ||
<!--ALCHEMY--> | ||
<!--=======================--> | ||
<dependency> | ||
<groupId>tech.sirwellington.alchemy</groupId> | ||
<artifactId>alchemy-annotations</artifactId> | ||
<version>1.5</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>tech.sirwellington.alchemy</groupId> | ||
<artifactId>alchemy-arguments</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>tech.sirwellington.alchemy</groupId> | ||
<artifactId>alchemy-thrift</artifactId> | ||
</dependency> | ||
|
||
|
||
<!--=======================--> | ||
<!--AROMA DEPENDENCIES--> | ||
<!--=======================--> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>banana-thrift</artifactId> | ||
<version>1.1-SNAPSHOT</version> | ||
<version>1.6</version> | ||
</dependency> | ||
|
||
|
||
<!--=======================--> | ||
<!--LOGGING--> | ||
<!--=======================--> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
|
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,175 @@ | ||
/* | ||
* Copyright 2015 Aroma Tech. | ||
* | ||
* Licensed 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 | ||
* | ||
* http://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 tech.aroma.banana.client; | ||
|
||
import java.util.concurrent.ExecutorService; | ||
import java.util.concurrent.Executors; | ||
import tech.aroma.banana.client.exceptions.BananaException; | ||
import tech.aroma.banana.thrift.application.service.ApplicationServiceConstants; | ||
import tech.aroma.banana.thrift.authentication.ApplicationToken; | ||
import tech.aroma.banana.thrift.endpoint.Endpoint; | ||
import tech.aroma.banana.thrift.endpoint.TcpEndpoint; | ||
import tech.sirwellington.alchemy.annotations.arguments.NonEmpty; | ||
import tech.sirwellington.alchemy.annotations.arguments.Optional; | ||
import tech.sirwellington.alchemy.annotations.arguments.Required; | ||
import tech.sirwellington.alchemy.annotations.concurrency.ThreadSafe; | ||
import tech.sirwellington.alchemy.annotations.designs.FluidAPIDesign; | ||
import tech.sirwellington.alchemy.annotations.designs.patterns.BuilderPattern; | ||
|
||
import static tech.sirwellington.alchemy.annotations.designs.patterns.BuilderPattern.Role.BUILDER; | ||
import static tech.sirwellington.alchemy.annotations.designs.patterns.BuilderPattern.Role.PRODUCT; | ||
import static tech.sirwellington.alchemy.arguments.Arguments.checkThat; | ||
import static tech.sirwellington.alchemy.arguments.assertions.Assertions.notNull; | ||
import static tech.sirwellington.alchemy.arguments.assertions.NetworkAssertions.validPort; | ||
import static tech.sirwellington.alchemy.arguments.assertions.StringAssertions.nonEmptyString; | ||
|
||
/** | ||
* | ||
* @author SirWellington | ||
*/ | ||
@ThreadSafe | ||
@BuilderPattern(role = PRODUCT) | ||
@FluidAPIDesign | ||
public interface Banana | ||
{ | ||
|
||
Request begin(); | ||
|
||
interface Request | ||
{ | ||
Request text(@Required String message, @Optional Object...args); | ||
|
||
Request titled(@Required String title); | ||
|
||
Request withUrgency(@Required Urgency level) throws IllegalArgumentException; | ||
|
||
void send() throws IllegalArgumentException, BananaException; | ||
} | ||
|
||
static Banana create() | ||
{ | ||
return newBuilder() | ||
.withAsyncExecutorService(Executors.newSingleThreadExecutor()) | ||
.withApplicationToken("Banana") | ||
.build(); | ||
} | ||
|
||
static Builder newBuilder() | ||
{ | ||
return new Builder(); | ||
} | ||
|
||
@BuilderPattern(role = BUILDER) | ||
static final class Builder | ||
{ | ||
|
||
private String hostname = ApplicationServiceConstants.PRODUCTION_ENDPOINT.getHostname(); | ||
private int port = ApplicationServiceConstants.PRODUCTION_ENDPOINT.getPort(); | ||
private String applicationToken = ""; | ||
private ExecutorService async; | ||
|
||
Builder() | ||
{ | ||
|
||
} | ||
|
||
/** | ||
* Set the Token ID created from the Aroma App. | ||
* | ||
* @param applicationToken | ||
* @return | ||
* | ||
* @throws IllegalArgumentException | ||
*/ | ||
public Builder withApplicationToken(@Required String applicationToken) throws IllegalArgumentException | ||
{ | ||
checkThat(applicationToken) | ||
.are(nonEmptyString()); | ||
|
||
this.applicationToken = applicationToken; | ||
|
||
return this; | ||
} | ||
|
||
public Builder withEndpoint(@NonEmpty String hostname, int port) throws IllegalArgumentException | ||
{ | ||
checkThat(hostname) | ||
.usingMessage("hostname cannot be empty") | ||
.is(nonEmptyString()); | ||
|
||
checkThat(port) | ||
.is(validPort()); | ||
|
||
this.hostname = hostname; | ||
this.port = port; | ||
|
||
return this; | ||
} | ||
|
||
public Builder withAsyncExecutorService(@Required ExecutorService executor) throws IllegalArgumentException | ||
{ | ||
checkThat(executor) | ||
.is(notNull()); | ||
|
||
this.async = executor; | ||
|
||
return this; | ||
} | ||
|
||
public Banana build() throws IllegalStateException | ||
{ | ||
checkThat(hostname) | ||
.throwing(IllegalStateException.class) | ||
.usingMessage("missing hostname") | ||
.is(nonEmptyString()); | ||
|
||
checkThat(applicationToken) | ||
.throwing(IllegalStateException.class) | ||
.usingMessage("missing Application Token") | ||
.is(nonEmptyString()); | ||
|
||
checkThat(port) | ||
.throwing(IllegalStateException.class) | ||
.is(validPort()); | ||
|
||
if (async == null) | ||
{ | ||
async = Executors.newSingleThreadExecutor(); | ||
} | ||
|
||
Endpoint endpoint = createEndpoint(); | ||
|
||
ApplicationToken token = new ApplicationToken().setTokenId(applicationToken); | ||
|
||
ThriftClientProvider clientProvider = new ThriftClientProvider(() -> endpoint); | ||
BananaClient banana = new BananaClient(() -> clientProvider.get(), async, token); | ||
return banana; | ||
|
||
} | ||
|
||
private Endpoint createEndpoint() | ||
{ | ||
TcpEndpoint tcpEndpoint = new TcpEndpoint(hostname, port); | ||
|
||
Endpoint endpoint = new Endpoint(); | ||
endpoint.setTcp(tcpEndpoint); | ||
return endpoint; | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.