Skip to content

Commit

Permalink
Merge branch 'release/0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
murieletrentini committed Apr 30, 2018
2 parents 3176df3 + c0c1680 commit dbfe729
Show file tree
Hide file tree
Showing 79 changed files with 1,199 additions and 1,049 deletions.
6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ deploy:
provider: releases
api_key:
secure: RgEpe+YRA+PtfF5ZgYt5mteJEBIXw0WWMHMckRr5kJI3doe6P7GjOFKYTW5WsnkB40lPhcJKBbOyKHBel6qH+ISKA8LFulFJhReTTz55AHvLON0S1DfSqTwERf7Hc8nal5u8i7GLitLHrghlJTMiAoGbdJ7jVXmSejIsIs2q/etNV3x1bppcEtCqxn1jcMG591FDQQWsOgjxJLB2/rv30/pCN9CCF3oj2Ab56LK2Z1DUp+unvY/LxwuspDlsC2TNqmEI2SsKOCfGd6p/RLqdy5O/2/7Pt/kvUG48+KKae/g91IaMhXGT1StzRdZhpSb9aBwS3S3/il2A5t8MN1oJ+qaibJDwGq+iCFH7tQ3mBvq3j3xtoR7TRAwW1z3gvKnl/fuEbj10HcA7Mo8qdvunhCGGn9fOaIs/DgOv2AuwPwrezgfKb7GtkgDxtjzdck2xnaBjbSIwRaOfDjPZsxk+8/xYvGn1JJwasoUxbkgbt/DovOt8j2WS/Fd/tdwtyQFnYHzZJuZGnLzIP7YarueMT3baen0g9b+Zx5+y5V3iDJctP+IxGD8Iasm89QLkRZ1GPGB/MH5Nt3xF1vMhxX2yZsPvQVLAOergTcQfgv+3+UJN3GQLb7IgfRVGv+ENoJNIVsbF6xQKOXUj17wfK4d2NWGBqVM9pcyJIgaveUr7kZY=
file: "build/libs/adv-lib-0.1.jar"
file: "build/libs/adv-lib-0.2.jar"
skip_cleanup: true
on:
tags: true
11 changes: 11 additions & 0 deletions bootstrapper/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apply plugin: 'application'

mainClassName = "ch.adv.lib.bootstrapper.ADV"

dependencies {
compile "ch.qos.logback:logback-core:1+"
compile "ch.qos.logback:logback-classic:1+"

compile project(':lib-core')
compile project(':module-bb-array')
}
90 changes: 90 additions & 0 deletions bootstrapper/src/main/java/ch/adv/lib/bootstrapper/ADV.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package ch.adv.lib.bootstrapper;

import ch.adv.lib.array.logic.GuiceArrayModule;
import ch.adv.lib.core.logic.ADVCore;
import ch.adv.lib.core.logic.ADVModule;
import ch.adv.lib.core.logic.GuiceCoreModule;
import ch.adv.lib.core.logic.util.ADVException;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Singleton;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Entry Point to the ADVCore Application.
* Registers all available modules with Guice
*
* @author mtrentini
*/
@Singleton
public class ADV {
private static final Logger logger =
LoggerFactory.getLogger(ADV.class);

private static ADVCore advCore;

/**
* Starts the Algorithm & Data Structure Visualizer.
* <p>
* Tries to automatically start the ADVCore UI if it can be found on the
* classpath.
* Opens a {@link java.net.Socket} connection to the ADVCore UI.
*
* @param args main method arguments
* @throws ADVException if no connection can be established to the
* ADVCore UI
*/
public static void launch(String[] args) throws ADVException {
Injector injector = createInjector();
advCore = injector.getInstance(ADVCore.class);
logger.info("Launching ADV Application ... ");
advCore.setup(args);
}

/**
* @return an injector with the GuiceModule of each ADV Module.
*/
private static Injector createInjector() {
return Guice.createInjector(
new GuiceCoreModule(),
new GuiceArrayModule()
);
}

/**
* Lets the session be built by the module builder.
* Lets said session be stringifyed by the module stringifyer.
* Hands the resulting json String to the connector;
*
* @param module the module bundling the snapshot content
* @param snapshotDescription an explanatory description for what is
* happening in the snapshot
*/
public static void snapshot(ADVModule module, String snapshotDescription) {
logger.info("Initialize sending snapshot ...");
advCore.snapshot(module, snapshotDescription);
}

/**
* Convenience method for optional snapshot description
* <p>
* Lets the session be built by the module builder.
* Lets said session be stringifyed by the module stringifyer.
* Hands the resulting json String to the connector;
*
* @param module the module bundling the snapshot content
*/
public static void snapshot(ADVModule module) {
logger.info("Sending snapshot ...");
advCore.snapshot(module, null);
}

/**
* Closes the {@link java.net.Socket} to the ADVCore UI
*/
public static void disconnect() {
logger.info("Starting disconnection...");
advCore.disconnectFromSocket();
}
}
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ allprojects {
apply plugin: 'jacoco'

group = 'ch.adv'
version = '0.1'
version = '0.2'

repositories {
mavenCentral()
Expand Down Expand Up @@ -85,10 +85,10 @@ dependencies {

jar {
dependsOn configurations.childJars
exclude('**/logback.xml')
from { configurations.childJars.collect { zipTree(it) } }
}


task jacocoRootReport(type: JacocoReport) {

dependsOn = subprojects.test
Expand Down
2 changes: 1 addition & 1 deletion excludeFilter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<!-- For help creating filter: http://spotbugs.readthedocs.io/en/latest/filter.html#match-a-particular-bug-pattern-in-a-particular-method -->
<!-- Match a particular bug pattern in a particular method -->
<Match>
<Class name="ch.adv.lib.array.mocks.ArraytestModule"/>
<Class name="ch.adv.lib.array.logic.mocks.ArraytestModule"/>
<Method name="getArray"/>
<Bug pattern="EI_EXPOSE_REP"/>
</Match>
Expand Down
4 changes: 0 additions & 4 deletions lib-core/settings.gradle

This file was deleted.

27 changes: 27 additions & 0 deletions lib-core/src/main/java/ch/adv/lib/core/access/ADVRequest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package ch.adv.lib.core.access;

/**
* Encapsulates a request to the ADVCore UI.
*/
class ADVRequest {

private final ProtocolCommand command;
private final String json;

ADVRequest(ProtocolCommand command) {
this(command, null);
}

ADVRequest(ProtocolCommand command, String json) {
this.command = command;
this.json = json;
}

ProtocolCommand getCommand() {
return command;
}

String getJson() {
return json;
}
}
23 changes: 23 additions & 0 deletions lib-core/src/main/java/ch/adv/lib/core/access/ADVResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package ch.adv.lib.core.access;

/**
* Encapsulates a response from the ADVCore UI.
*/
class ADVResponse {

private final ProtocolCommand command;
private final String exceptionMessage;

ADVResponse(ProtocolCommand command, String exceptionMessage) {
this.command = command;
this.exceptionMessage = exceptionMessage;
}

ProtocolCommand getCommand() {
return command;
}

String getExceptionMessage() {
return exceptionMessage;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package ch.adv.lib.core.service;
package ch.adv.lib.core.access;

/**
* Offeres methods to connect the ADV Lib to the ADV UI over a communication
* Offers methods to connect the ADVCore Lib to the ADVCore UI over a
* communication
* channel like a socket.
*/
public interface Connector {
Expand All @@ -22,17 +23,25 @@ public interface Connector {
boolean disconnect();

/**
* Sets the portNr, where the ADV UI can be reached.
* Sets the portNr, where the ADVCore UI can be reached.
*
* @param portNr to be set
*/
void setPort(int portNr);

/**
* Opens the communication channel to the ADV UI. Needs to be called
* Sets the host, where the ADVCore UI can be reached.
*
* @param host to be set
*/
void setHost(String host);

/**
* Opens the communication channel to the ADVCore UI. Needs to be called
* before {@link Connector#send(String)} send()}.
*
* @return true, if the connection coulb be established successfully.
*/
boolean connect();

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ch.adv.lib.core.service;
package ch.adv.lib.core.access;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
Expand All @@ -8,7 +8,7 @@
/**
* Contains preconfigured GsonBuilder
*/
public class GsonProvider {
public class GsonProvider implements JsonBuilderProvider<Gson> {
private final GsonBuilder minifier;
private final GsonBuilder prettifyer;

Expand All @@ -17,17 +17,19 @@ public GsonProvider() {
this.prettifyer.setPrettyPrinting();
this.prettifyer.excludeFieldsWithModifiers(Modifier.TRANSIENT);

this.minifier = new GsonBuilder();
// transient and static fields are excluded by default. we only want
// transient fields to be excluded. That's why we exclude them
// explicitly!
this.minifier = new GsonBuilder();
this.minifier.excludeFieldsWithModifiers(Modifier.TRANSIENT);
}

@Override
public Gson getMinifier() {
return minifier.create();
}

@Override
public Gson getPrettifyer() {
return prettifyer.create();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package ch.adv.lib.core.access;

/**
* Provide Minifier and Prettifyer to serialize json
*
* @param <T> the type of the json builder
*/
public interface JsonBuilderProvider<T> {
/**
* @return a json builder which builds concise json.
*/
T getMinifier();

/**
* @return a json builder which builds a pretty, human readyble json.
*/
T getPrettifyer();
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package ch.adv.lib.core.service;
package ch.adv.lib.core.access;

import com.google.gson.annotations.SerializedName;

/**
* Available commands for the ADV protocol.
* Available commands for the ADVCore protocol.
*/
public enum ProtocolCommand {
enum ProtocolCommand {

@SerializedName("TRANSMIT")
TRANSMIT("TRANSMIT"),
Expand Down
Loading

0 comments on commit dbfe729

Please sign in to comment.