-
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.
- Loading branch information
Showing
79 changed files
with
1,199 additions
and
1,049 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,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
90
bootstrapper/src/main/java/ch/adv/lib/bootstrapper/ADV.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,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(); | ||
} | ||
} |
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
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
lib-core/src/main/java/ch/adv/lib/core/access/ADVRequest.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,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
23
lib-core/src/main/java/ch/adv/lib/core/access/ADVResponse.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,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; | ||
} | ||
} |
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
18 changes: 18 additions & 0 deletions
18
lib-core/src/main/java/ch/adv/lib/core/access/JsonBuilderProvider.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,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(); | ||
} |
6 changes: 3 additions & 3 deletions
6
...adv/lib/core/service/ProtocolCommand.java → .../adv/lib/core/access/ProtocolCommand.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
Oops, something went wrong.