@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
cd ./forward
|
||||
./install-locally.sh
|
||||
cd ..
|
||||
cd ./helper
|
||||
./install-locally.sh
|
||||
cd ..
|
||||
cd ./mirror
|
||||
./install-locally.sh
|
||||
cd ..
|
||||
cd ./reverse
|
||||
./install-locally.sh
|
||||
cd ..
|
@ -0,0 +1,208 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.olexyn.misp.embedded</groupId>
|
||||
<artifactId>embedded</artifactId>
|
||||
<version>0.1</version>
|
||||
|
||||
<name>embedded</name>
|
||||
<!-- FIXME change it to the project's website -->
|
||||
<url>http://www.example.com</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.11</maven.compiler.source>
|
||||
<maven.compiler.target>1.11</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.11</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.olexyn.min.http.server</groupId>
|
||||
<artifactId>min-http-server</artifactId>
|
||||
<version>0.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>4.0.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.olexyn.misp.helper</groupId>
|
||||
<artifactId>misp-helper</artifactId>
|
||||
<version>0.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.6</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-server</artifactId>
|
||||
<version>9.4.28.v20200408</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-webapp</artifactId>
|
||||
<version>9.4.28.v20200408</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlets</artifactId>
|
||||
<version>9.4.28.v20200408</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>9.4.28.v20200408</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-util</artifactId>
|
||||
<version>9.4.28.v20200408</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-http</artifactId>
|
||||
<version>9.4.28.v20200408</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-io</artifactId>
|
||||
<version>9.4.28.v20200408</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-client</artifactId>
|
||||
<version>9.4.28.v20200408</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.websocket</groupId>
|
||||
<artifactId>websocket-server</artifactId>
|
||||
<version>9.4.28.v20200408</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.websocket</groupId>
|
||||
<artifactId>websocket-client</artifactId>
|
||||
<version>9.4.28.v20200408</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.websocket</groupId>
|
||||
<artifactId>websocket-servlet</artifactId>
|
||||
<version>9.4.28.v20200408</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.websocket</groupId>
|
||||
<artifactId>websocket-api</artifactId>
|
||||
<version>9.4.28.v20200408</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.aggregate</groupId>
|
||||
<artifactId>jetty-all</artifactId>
|
||||
<version>9.4.28.v20200408</version>
|
||||
<type>pom</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.olexyn.misp.mirror</groupId>
|
||||
<artifactId>misp-mirror</artifactId>
|
||||
<version>0.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.olexyn.misp.rev</groupId>
|
||||
<artifactId>misp-rev</artifactId>
|
||||
<version>0.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.olexyn.misp.reverse</groupId>
|
||||
<artifactId>reverse</artifactId>
|
||||
<version>0.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.olexyn.misp.fwd</groupId>
|
||||
<artifactId>misp-fwd</artifactId>
|
||||
<version>0.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.olexyn.misp.forward</groupId>
|
||||
<artifactId>forward</artifactId>
|
||||
<version>0.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.olexyn.misp.mirror</groupId>
|
||||
<artifactId>mirror</artifactId>
|
||||
<version>0.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20190722</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
|
||||
<plugins>
|
||||
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
|
||||
<plugin>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
</plugin>
|
||||
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-install-plugin</artifactId>
|
||||
<version>2.5.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>2.8.2</version>
|
||||
</plugin>
|
||||
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
|
||||
<plugin>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>3.7.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
</project>
|
@ -0,0 +1,30 @@
|
||||
package com.olexyn.misp.embedded;
|
||||
|
||||
import com.olexyn.min.http.server.MinJettyServer;
|
||||
import com.olexyn.misp.forward.Forward;
|
||||
import com.olexyn.misp.mirror.Mirror;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
*/
|
||||
public class Embedded implements Runnable {
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
MinJettyServer server = new MinJettyServer();
|
||||
|
||||
server.PORT = 8090;
|
||||
server.MAX_THREADS = 100;
|
||||
server.MIN_THREADS = 10;
|
||||
server.IDLE_TIMEOUT = 120;
|
||||
|
||||
|
||||
server.addServletWithMapping("/mirror", Mirror.class);
|
||||
server.addServletWithMapping("/app", Mirror.class);
|
||||
server.addServletWithMapping("/forward", Forward.class);
|
||||
|
||||
|
||||
server.start();
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.olexyn.misp.embedded;
|
||||
|
||||
import com.olexyn.misp.reverse.ReverseApp;
|
||||
|
||||
public class RunAll {
|
||||
|
||||
public static void main(String... args) throws InterruptedException {
|
||||
|
||||
|
||||
Thread serverT = new Thread(new Embedded());
|
||||
serverT.start();
|
||||
|
||||
Thread.sleep(2000);
|
||||
|
||||
Thread reverseT = new Thread(new ReverseApp());
|
||||
reverseT.start();
|
||||
}
|
||||
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
#!/bin/bash
|
||||
version="0.1"
|
||||
file="target/misp-fwd-${version}.war"
|
||||
groupId="com.olexyn.misp.fwd"
|
||||
artifactId="misp-fwd"
|
||||
file="target/forward-${version}.war"
|
||||
groupId="com.olexyn.misp.forward"
|
||||
artifactId="forward"
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 617 B After Width: | Height: | Size: 617 B |
Before Width: | Height: | Size: 617 B After Width: | Height: | Size: 617 B |
@ -1,10 +0,0 @@
|
||||
#!/bin/bash
|
||||
version="0.1"
|
||||
file="target/misp-rev-${version}.war"
|
||||
groupId="com.olexyn.misp.rev"
|
||||
artifactId="misp-rev"
|
||||
|
||||
|
||||
|
||||
mvn package
|
||||
mvn install:install-file -Dfile=${file} -DgroupId=${groupId} -DartifactId=${artifactId} -Dversion=${version} -Dpackaging=war -DgeneratePom=true
|
@ -1,90 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.olexyn.misp.rev</groupId>
|
||||
<artifactId>misp-rev</artifactId>
|
||||
<version>0.1</version>
|
||||
<packaging>war</packaging>
|
||||
|
||||
<name>misp-rev Maven Webapp</name>
|
||||
<!-- FIXME change it to the project's website -->
|
||||
<url>http://www.example.com</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.11</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.olexyn.misp.helper</groupId>
|
||||
<artifactId>misp-helper</artifactId>
|
||||
<version>0.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.6</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.orbit</groupId>
|
||||
<artifactId>javax.servlet</artifactId>
|
||||
<version>3.0.0.v201112011016</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20190722</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
</plugin>
|
||||
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>3.2.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-install-plugin</artifactId>
|
||||
<version>2.5.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>2.8.2</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
</project>
|
@ -1,16 +0,0 @@
|
||||
package com.olexyn.misp.rev;
|
||||
|
||||
import com.olexyn.misp.helper.Ride;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class ConnectionHelper {
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package com.olexyn.misp.rev;
|
||||
|
||||
public class Main {
|
||||
|
||||
|
||||
|
||||
public static void main(String... args){
|
||||
new RevProxy();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
<!DOCTYPE web-app PUBLIC
|
||||
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
|
||||
"http://java.sun.com/dtd/web-app_2_3.dtd" >
|
||||
|
||||
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
|
||||
version="2.4">
|
||||
|
||||
<display-name>misp-rev</display-name>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>misp-rev</servlet-name>
|
||||
<servlet-class>com.olexyn.misp.rev.RevProxy</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>misp-rev</servlet-name>
|
||||
<url-pattern>/core</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
</web-app>
|
Before Width: | Height: | Size: 617 B |
@ -1,20 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>misp-rev</title>
|
||||
</head>
|
||||
<body bgcolor=white>
|
||||
|
||||
<table border="0">
|
||||
<tr>
|
||||
<td align=center>
|
||||
<img src="images/io42630.png">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<h1>misp-rev</h1>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
@ -1,16 +0,0 @@
|
||||
#### About
|
||||
* Mockup for easy debugging.
|
||||
* Mock *requests* and *responses*.
|
||||
* Teleport them between *actors*.
|
||||
* There are 4 actors which are mocked:
|
||||
* `AppMock` : the App hosted on *localhost*.
|
||||
* `ClientMock` : the *mispclient* Servlet.
|
||||
* `BridgeMock` : the *mispbridge* Servlet.
|
||||
* `UserMock` : the user agent accessing the *mispbridge* from the internet.
|
||||
* `MockSet` knows all 4 actors, all the 4 actors know `MockSet`.
|
||||
* Thus all 4 actors know each other.
|
||||
|
||||
<br>
|
||||
|
||||
##### Threads in Mock
|
||||

|
@ -1,99 +0,0 @@
|
||||
package com.olexyn.misp.mock;
|
||||
|
||||
import com.olexyn.misp.helper.Ride;
|
||||
import com.olexyn.misp.mock.exchange.ExchangeMock;
|
||||
import com.olexyn.misp.adapter.Adapter;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Wraps a ClientServlet so it can be debugged easily, i.e. without running Tomcat.
|
||||
*/
|
||||
public class AdapterMock extends Adapter {
|
||||
|
||||
private MockSet mockSet;
|
||||
|
||||
|
||||
public AdapterMock(MockSet mockSet) {
|
||||
super();
|
||||
mockSet.adapterMock = this;
|
||||
this.mockSet = mockSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send POST (Ride).
|
||||
* Parse response.
|
||||
*/
|
||||
@Override
|
||||
protected Ride doSendPostRide(Ride ride) throws IOException, InterruptedException, ServletException {
|
||||
|
||||
// Mock Exchange
|
||||
final ExchangeMock exchange = new ExchangeMock();
|
||||
exchange.request.setMethod("POST");
|
||||
exchange.request.setContentType("application/json");
|
||||
exchange.request.setContent(ride.json().getBytes());
|
||||
|
||||
synchronized (exchange) {
|
||||
// Mock POST (Ride)
|
||||
exchange.notify();
|
||||
mockSet.bridgeMock.doPost(exchange.request, exchange.response);
|
||||
exchange.wait();
|
||||
exchange.notify();
|
||||
}
|
||||
|
||||
// handle OK (Ride)(Request)
|
||||
return new Ride(exchange.response.getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send GET (Request) to App.
|
||||
* Parse response.
|
||||
*/
|
||||
@Override
|
||||
protected String doSendGetRequest(String request) throws IOException {
|
||||
|
||||
// Mock Exchange
|
||||
final ExchangeMock exchange = new ExchangeMock();
|
||||
|
||||
exchange.request.setMethod("GET");
|
||||
exchange.request.setContent(request.getBytes());
|
||||
|
||||
synchronized (exchange) {
|
||||
// Mock GET (Request)
|
||||
exchange.notify();
|
||||
mockSet.appMock.doGet(exchange.request, exchange.response);
|
||||
|
||||
// handle OK (Data)
|
||||
exchange.notify();
|
||||
}
|
||||
|
||||
return exchange.response.getContentAsString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send GET (Ride)(Request)(Data).
|
||||
* Parse response.
|
||||
*/
|
||||
@Override
|
||||
protected void doSendGetRideRequest(Ride ride) throws IOException, InterruptedException {
|
||||
|
||||
// Mock Exchange
|
||||
final ExchangeMock exchange = new ExchangeMock();
|
||||
exchange.request.setMethod("GET");
|
||||
exchange.request.setContentType("application/json");
|
||||
exchange.request.setContent(ride.json().getBytes());
|
||||
|
||||
synchronized (exchange) {
|
||||
// Mock GET (Ride)(Request)(Data)
|
||||
exchange.notify();
|
||||
mockSet.bridgeMock.doGet(exchange.request, exchange.response);
|
||||
exchange.wait();
|
||||
exchange.notify();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package com.olexyn.misp.mock;
|
||||
|
||||
/**
|
||||
* Pass the MockSet.
|
||||
* Provide a Runnable.
|
||||
*/
|
||||
public class AdapterRunnable implements Runnable {
|
||||
|
||||
private MockSet mockSet;
|
||||
|
||||
public AdapterRunnable(MockSet mockSet){
|
||||
super();
|
||||
this.mockSet = mockSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
new AdapterMock(mockSet);
|
||||
}
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
package com.olexyn.misp.mock;
|
||||
|
||||
|
||||
import com.olexyn.misp.mock.exchange.ExchangeMock;
|
||||
import com.olexyn.misp.mock.exchange.RequestMock;
|
||||
import com.olexyn.misp.bridge.BridgeServlet;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
public class BridgeMock extends BridgeServlet {
|
||||
|
||||
public BridgeMock(MockSet mockSet) {
|
||||
super();
|
||||
mockSet.bridgeMock = this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* handle GET (Request)<br>
|
||||
* - wait for availableRides to have an entry <br>
|
||||
* - move move Ride to deliveredRides <br>
|
||||
* - wait for Ride to have Data <br>
|
||||
* - respond to the original request with Data
|
||||
*/
|
||||
@Override
|
||||
protected void handleGetRequest(HttpServletRequest request, HttpServletResponse response) throws IOException, InterruptedException {
|
||||
|
||||
final ExchangeMock exchange;
|
||||
|
||||
synchronized (exchange = ((RequestMock) request).exchange) {
|
||||
|
||||
super.handleGetRequest(request,response);
|
||||
|
||||
exchange.notify();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* handle GET (Ride)(Data)
|
||||
* if Ride in ForwardedRequest
|
||||
* remove Ride from ForwardedRequest
|
||||
* add Ride to NewData
|
||||
* send OK (Ride)(Data)
|
||||
* remove Ride from NewData
|
||||
* add Ride to ForwardedData
|
||||
* send OK (EOL)
|
||||
* remove Ride from ForwardedData
|
||||
* add Ride to EOL
|
||||
*/
|
||||
protected void handleGetRideRequestData(HttpServletRequest request, HttpServletResponse response) throws IOException, InterruptedException {
|
||||
|
||||
final ExchangeMock exchange;
|
||||
|
||||
synchronized (exchange = ((RequestMock) request).exchange) {
|
||||
|
||||
super.handleGetRideRequestData(request,response);
|
||||
|
||||
exchange.notify();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* handle POST (Ride)
|
||||
* - wait for Ride to be booked
|
||||
* - send OK to Client
|
||||
*/
|
||||
@Override
|
||||
protected void handlePostRide(HttpServletRequest request, HttpServletResponse response) throws IOException, InterruptedException {
|
||||
|
||||
final ExchangeMock exchange;
|
||||
|
||||
synchronized (exchange = ((RequestMock) request).exchange) {
|
||||
|
||||
super.handlePostRide(request,response);
|
||||
|
||||
exchange.notify();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package com.olexyn.misp.mock;
|
||||
|
||||
/**
|
||||
* Pass the MockSet.
|
||||
* Provide a Runnable.
|
||||
*/
|
||||
public class BridgeRunnable implements Runnable {
|
||||
|
||||
MockSet mockSet;
|
||||
|
||||
public BridgeRunnable(MockSet mockSet){
|
||||
super();
|
||||
this.mockSet = mockSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
new BridgeMock(mockSet);
|
||||
}
|
||||
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
package com.olexyn.misp.mock;
|
||||
|
||||
import com.olexyn.misp.mock.actor.AppMock;
|
||||
import com.olexyn.misp.mock.actor.UserMock;
|
||||
|
||||
public class Main {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String... args){
|
||||
|
||||
MockSet mockSet = new MockSet();
|
||||
|
||||
Runnable publicRunnable = new UserMock(mockSet);
|
||||
Runnable bridgeRunable = new BridgeRunnable(mockSet);
|
||||
Runnable adapterRunnable = new AdapterRunnable(mockSet);
|
||||
//Runnable clientRunnable = new ClientRunnable(mockSet);
|
||||
Runnable appRunnable = new AppMock(mockSet);
|
||||
|
||||
Thread userThread = new Thread(publicRunnable);
|
||||
Thread bridgeThread = new Thread(bridgeRunable);
|
||||
Thread adapterThread = new Thread(adapterRunnable);
|
||||
//Thread clientThread = new Thread(clientRunnable);
|
||||
Thread appThread = new Thread(appRunnable);
|
||||
|
||||
userThread.setName("userThread");
|
||||
userThread.start();
|
||||
bridgeThread.setName("bridgeThread");
|
||||
bridgeThread.start();
|
||||
adapterThread.setName("adapterThread");
|
||||
adapterThread.start();
|
||||
//clientThread.setName("clientThread");
|
||||
//clientThread.start();
|
||||
appThread.setName("appThread");
|
||||
appThread.start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,11 +0,0 @@
|
||||
package com.olexyn.misp.mock;
|
||||
|
||||
import com.olexyn.misp.mock.actor.AppMock;
|
||||
import com.olexyn.misp.mock.actor.UserMock;
|
||||
|
||||
public class MockSet {
|
||||
public UserMock userMock;
|
||||
public BridgeMock bridgeMock;
|
||||
public AdapterMock adapterMock;
|
||||
public AppMock appMock;
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
package com.olexyn.misp.mock.actor;
|
||||
|
||||
import com.olexyn.misp.mock.MockSet;
|
||||
import com.olexyn.misp.mock.exchange.ExchangeMock;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generic Runnable.
|
||||
* Serves as basis for Actors that are not Servlets.
|
||||
*/
|
||||
public abstract class ActorRunnable implements Runnable {
|
||||
|
||||
|
||||
List<ExchangeMock> exchanges = new ArrayList<>();
|
||||
|
||||
protected MockSet mockSet;
|
||||
|
||||
|
||||
|
||||
public ActorRunnable(MockSet mockSet){
|
||||
this.mockSet = mockSet;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
public void processExchange(ExchangeMock exchange) throws IOException, ServletException {
|
||||
|
||||
|
||||
if (exchange.request.getMethod().equalsIgnoreCase("GET")) {
|
||||
doGet(exchange.request, exchange.response);
|
||||
} else if (exchange.request.getMethod().equalsIgnoreCase("POST")) {
|
||||
doPost(exchange.request, exchange.response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public abstract void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException;
|
||||
|
||||
public abstract void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException;
|
||||
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
package com.olexyn.misp.mock.actor;
|
||||
|
||||
|
||||
|
||||
import com.olexyn.misp.mock.MockSet;
|
||||
import com.olexyn.misp.mock.exchange.ExchangeMock;
|
||||
import com.olexyn.misp.mock.exchange.RequestMock;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
public class AppMock extends ActorRunnable {
|
||||
|
||||
public AppMock(MockSet mockSet) {
|
||||
super(mockSet);
|
||||
mockSet.appMock = this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (true) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
|
||||
RequestMock mockRequest = (RequestMock) request;
|
||||
ExchangeMock exchange = mockRequest.exchange;
|
||||
|
||||
synchronized (exchange) {
|
||||
String parsedRequest = IOUtils.toString(request.getReader());
|
||||
|
||||
String dataString = "DATA-" + parsedRequest;
|
||||
|
||||
exchange.response.setStatus(200);
|
||||
PrintWriter writer = exchange.response.getWriter();
|
||||
writer.write(dataString);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
|
||||
exchange.notify();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response) {
|
||||
|
||||
}
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
package com.olexyn.misp.mock.actor;
|
||||
|
||||
import com.olexyn.misp.mock.MockSet;
|
||||
import com.olexyn.misp.mock.exchange.ExchangeMock;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
|
||||
|
||||
public class UserMock extends ActorRunnable {
|
||||
|
||||
|
||||
|
||||
final String longRequest;
|
||||
|
||||
int requestCount = 0;
|
||||
|
||||
public UserMock(MockSet mockSet){
|
||||
super(mockSet);
|
||||
mockSet.userMock = this;
|
||||
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i=0;i<100;i++){
|
||||
sb.append("foo");
|
||||
}
|
||||
longRequest = sb.toString();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (true){
|
||||
try {
|
||||
sendGetRequest();
|
||||
} catch (IOException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* # send GET (Request)
|
||||
* Generated by Loop
|
||||
*/
|
||||
void sendGetRequest() throws IOException, InterruptedException {
|
||||
|
||||
// Mock Exchange
|
||||
ExchangeMock exchange = new ExchangeMock();
|
||||
|
||||
exchange.request.setMethod("GET");
|
||||
//exchange.request.setContentType("application/json");
|
||||
|
||||
//String requestBody = longRequest+"-"+(++requestCount);
|
||||
String requestBody = "REQUEST-"+(++requestCount);
|
||||
String jsonString = "{\"request\":\""+requestBody+ "\"}";
|
||||
jsonString = "asdfasdfa";
|
||||
exchange.request.setContent(jsonString.getBytes());
|
||||
|
||||
synchronized (exchange){
|
||||
// Mock GET (Request)
|
||||
exchange.notify();
|
||||
mockSet.bridgeMock.doGet(exchange.request,exchange.response);
|
||||
exchange.wait();
|
||||
|
||||
// handle OK (Data)
|
||||
String data = exchange.response.getContentAsString();
|
||||
System.out.println(data + " of "+requestBody);
|
||||
exchange.notify();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
package com.olexyn.misp.mock.exchange;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* How "exchange" mocks an exchange:<br>
|
||||
* <br>
|
||||
* An "exchange" corresponds to request & reply pair.<br>
|
||||
* - i.e. a GET & OK pair.<br>
|
||||
* Steps:<br>
|
||||
* 1. new Exchange()<br>
|
||||
* 2. set properties of .request<br>
|
||||
* 3. "send" request by using exchange.notify(); recipient.doGet();<br>
|
||||
* 4. recipient does someting with request<br>
|
||||
* - - recipient sets proerties of .response<br>
|
||||
* - - recipient sends reply using exchange.notify();<br>
|
||||
* 5. "receive" response by using exchange.wait();
|
||||
*/
|
||||
public class ExchangeMock {
|
||||
|
||||
public static List<ExchangeMock> exchangeList = new ArrayList<>();
|
||||
|
||||
|
||||
private static int next_id=0;
|
||||
public int id;
|
||||
|
||||
public RequestMock request =new RequestMock(this);
|
||||
public ResponseMock response = new ResponseMock(this);
|
||||
|
||||
public ExchangeMock(){
|
||||
id = next_id++;
|
||||
exchangeList.add(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,84 +0,0 @@
|
||||
package com.olexyn.misp.mock.exchange;
|
||||
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.Part;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* - Contains reference to ExchangeMock
|
||||
* - Rest is dummy code.
|
||||
*/
|
||||
public class RequestMock extends MockHttpServletRequest implements HttpServletRequest {
|
||||
|
||||
public final ExchangeMock exchange;
|
||||
|
||||
public RequestMock(ExchangeMock exchange){
|
||||
super();
|
||||
this.exchange = exchange;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean authenticate(HttpServletResponse httpServletResponse) throws IOException, ServletException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void login(String s, String s1) throws ServletException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logout() throws ServletException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Part> getParts() throws IOException, ServletException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Part getPart(String s) throws IOException, ServletException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletContext getServletContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncContext startAsync() throws IllegalStateException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) throws IllegalStateException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAsyncStarted() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAsyncSupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncContext getAsyncContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DispatcherType getDispatcherType() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,209 +0,0 @@
|
||||
package com.olexyn.misp.mock.exchange;
|
||||
|
||||
|
||||
import org.springframework.mock.web.MockHttpServletResponse;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* - Contains reference to ExchangeMock
|
||||
* - Rest is dummy code.
|
||||
*/
|
||||
public class ResponseMock extends MockHttpServletResponse implements HttpServletResponse {
|
||||
|
||||
public ExchangeMock exchange;
|
||||
|
||||
public ResponseMock(ExchangeMock exchange){
|
||||
super();
|
||||
this.exchange = exchange;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addCookie(Cookie cookie) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsHeader(String s) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String encodeURL(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String encodeRedirectURL(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String encodeUrl(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String encodeRedirectUrl(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendError(int i, String s) throws IOException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendError(int i) throws IOException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRedirect(String s) throws IOException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDateHeader(String s, long l) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDateHeader(String s, long l) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeader(String s, String s1) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addHeader(String s, String s1) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIntHeader(String s, int i) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addIntHeader(String s, int i) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStatus(int i) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStatus(int i, String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatus() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHeader(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getHeaders(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set getHeaderNames() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCharacterEncoding() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletOutputStream getOutputStream() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrintWriter getWriter() throws UnsupportedEncodingException {
|
||||
return super.getWriter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCharacterEncoding(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContentLength(int i) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContentType(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBufferSize(int i) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBufferSize() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flushBuffer() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetBuffer() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommitted() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocale(Locale locale) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return null;
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 33 KiB |
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
version="0.1"
|
||||
artifactId="reverse"
|
||||
file="target/${artifactId}-${version}.jar"
|
||||
groupId="com.olexyn.misp.reverse"
|
||||
|
||||
|
||||
|
||||
|
||||
mvn package
|
||||
mvn install:install-file -Dfile=${file} -DgroupId=${groupId} -DartifactId=${artifactId} -Dversion=${version} -Dpackaging=jar -DgeneratePom=true
|
@ -0,0 +1,26 @@
|
||||
package com.olexyn.misp.reverse;
|
||||
|
||||
import com.olexyn.misp.helper.Ride;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
class GetRequestRunnable implements Runnable {
|
||||
|
||||
final private Reverse reverse;
|
||||
|
||||
public GetRequestRunnable(Reverse reverse) {
|
||||
this.reverse = reverse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (true) {
|
||||
synchronized (reverse.booked) {
|
||||
if (reverse.booked.size() > 0) {
|
||||
final Ride ride = reverse.booked.entrySet().iterator().next().getValue();
|
||||
try { reverse.sendGetRequest(ride); } catch (IOException ignored) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.olexyn.misp.reverse;
|
||||
|
||||
import com.olexyn.misp.helper.Ride;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
class GetRideRequestDataRunnable implements Runnable {
|
||||
|
||||
final private Reverse reverse;
|
||||
|
||||
public GetRideRequestDataRunnable(Reverse reverse) {
|
||||
this.reverse = reverse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (true) {
|
||||
synchronized (reverse.loaded) {
|
||||
if (reverse.loaded.size() > 0) {
|
||||
final Ride ride = reverse.loaded.entrySet().iterator().next().getValue();
|
||||
try { reverse.sendGetRideRequestData(ride); } catch (IOException ignored) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.olexyn.misp.reverse;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
class PostRideRunnable implements Runnable {
|
||||
|
||||
final private Reverse reverse;
|
||||
|
||||
public PostRideRunnable(Reverse reverse) {
|
||||
this.reverse = reverse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (true) {
|
||||
synchronized (reverse.available) {
|
||||
if (reverse.available.size() < reverse.AVAILABLE_RIDES_OVERHEAD_TRIGGER) {
|
||||
for (int i = 0; i < reverse.AVAILABLE_RIDES_OVERHEAD; i++) {
|
||||
try {reverse.sendPostRide();} catch (IOException ignored) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
* Run from `ReverseApp` :
|
||||
* as `main()`
|
||||
* or as `Runnable` from somewhere else.
|
@ -0,0 +1,30 @@
|
||||
package com.olexyn.misp.reverse;
|
||||
|
||||
public class ReverseApp implements Runnable {
|
||||
|
||||
|
||||
public static void main(String... args) {
|
||||
new ReverseApp().doRun();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
doRun();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void doRun() {
|
||||
Reverse reverse = new Reverse();
|
||||
|
||||
reverse.FORWARD_URL = "http://localhost:8090/forward";
|
||||
reverse.APP_URL = "http://localhost:8090/app";
|
||||
|
||||
reverse.AVAILABLE_RIDES_OVERHEAD_TRIGGER = 1;
|
||||
reverse.AVAILABLE_RIDES_OVERHEAD = 2;
|
||||
|
||||
reverse.start();
|
||||
}
|
||||
}
|
@ -1,113 +0,0 @@
|
||||
<?xml version="1.0"?><!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
|
||||
|
||||
<!-- =============================================================== -->
|
||||
<!-- Documentation of this file format can be found at: -->
|
||||
<!-- https://www.eclipse.org/jetty/documentation/current/ -->
|
||||
<!-- -->
|
||||
<!-- Additional configuration files are available in $JETTY_HOME/etc -->
|
||||
<!-- and can be mixed in. See start.ini file for the default -->
|
||||
<!-- configuration files. -->
|
||||
<!-- -->
|
||||
<!-- For a description of the configuration mechanism, see the -->
|
||||
<!-- output of: -->
|
||||
<!-- java -jar start.jar -? -->
|
||||
<!-- =============================================================== -->
|
||||
|
||||
<!-- =============================================================== -->
|
||||
<!-- Configure a Jetty Server instance with an ID "Server" -->
|
||||
<!-- Other configuration files may also configure the "Server" -->
|
||||
<!-- ID, in which case they are adding configuration to the same -->
|
||||
<!-- instance. If other configuration have a different ID, they -->
|
||||
<!-- will create and configure another instance of Jetty. -->
|
||||
<!-- Consult the javadoc of o.e.j.server.Server for all -->
|
||||
<!-- configuration that may be set here. -->
|
||||
<!-- =============================================================== -->
|
||||
<Configure id="Server" class="org.eclipse.jetty.server.Server">
|
||||
<Arg name="threadpool"><Ref refid="threadPool"/></Arg>
|
||||
|
||||
<Call name="addBean">
|
||||
<Arg><Ref refid="byteBufferPool"/></Arg>
|
||||
</Call>
|
||||
|
||||
<!-- =========================================================== -->
|
||||
<!-- Add shared Scheduler instance -->
|
||||
<!-- =========================================================== -->
|
||||
<Call name="addBean">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.util.thread.ScheduledExecutorScheduler">
|
||||
<Arg name="name"><Property name="jetty.scheduler.name"/></Arg>
|
||||
<Arg name="daemon" type="boolean"><Property name="jetty.scheduler.daemon" default="false" /></Arg>
|
||||
<Arg name="threads" type="int"><Property name="jetty.scheduler.threads" default="-1" /></Arg>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
|
||||
<!-- =========================================================== -->
|
||||
<!-- Http Configuration. -->
|
||||
<!-- This is a common configuration instance used by all -->
|
||||
<!-- connectors that can carry HTTP semantics (HTTP, HTTPS, etc.)-->
|
||||
<!-- It configures the non wire protocol aspects of the HTTP -->
|
||||
<!-- semantic. -->
|
||||
<!-- -->
|
||||
<!-- This configuration is only defined here and is used by -->
|
||||
<!-- reference from other XML files such as jetty-http.xml, -->
|
||||
<!-- jetty-https.xml and other configuration files which -->
|
||||
<!-- instantiate the connectors. -->
|
||||
<!-- -->
|
||||
<!-- Consult the javadoc of o.e.j.server.HttpConfiguration -->
|
||||
<!-- for all configuration that may be set here. -->
|
||||
<!-- =========================================================== -->
|
||||
<New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
|
||||
<Set name="secureScheme"><Property name="jetty.httpConfig.secureScheme" default="https" /></Set>
|
||||
<Set name="securePort"><Property name="jetty.httpConfig.securePort" deprecated="jetty.secure.port" default="8443" /></Set>
|
||||
<Set name="outputBufferSize"><Property name="jetty.httpConfig.outputBufferSize" deprecated="jetty.output.buffer.size" default="32768" /></Set>
|
||||
<Set name="outputAggregationSize"><Property name="jetty.httpConfig.outputAggregationSize" deprecated="jetty.output.aggregation.size" default="8192" /></Set>
|
||||
<Set name="requestHeaderSize"><Property name="jetty.httpConfig.requestHeaderSize" deprecated="jetty.request.header.size" default="8192" /></Set>
|
||||
<Set name="responseHeaderSize"><Property name="jetty.httpConfig.responseHeaderSize" deprecated="jetty.response.header.size" default="8192" /></Set>
|
||||
<Set name="sendServerVersion"><Property name="jetty.httpConfig.sendServerVersion" deprecated="jetty.send.server.version" default="true" /></Set>
|
||||
<Set name="sendDateHeader"><Property name="jetty.httpConfig.sendDateHeader" deprecated="jetty.send.date.header" default="false" /></Set>
|
||||
<Set name="headerCacheSize"><Property name="jetty.httpConfig.headerCacheSize" default="1024" /></Set>
|
||||
<Set name="delayDispatchUntilContent"><Property name="jetty.httpConfig.delayDispatchUntilContent" deprecated="jetty.delayDispatchUntilContent" default="true"/></Set>
|
||||
<Set name="maxErrorDispatches"><Property name="jetty.httpConfig.maxErrorDispatches" default="10"/></Set>
|
||||
<Set name="blockingTimeout"><Property deprecated="jetty.httpConfig.blockingTimeout" name="jetty.httpConfig.blockingTimeout.DEPRECATED" default="-1"/></Set>
|
||||
<Set name="persistentConnectionsEnabled"><Property name="jetty.httpConfig.persistentConnectionsEnabled" default="true"/></Set>
|
||||
<Set name="requestCookieCompliance"><Call class="org.eclipse.jetty.http.CookieCompliance" name="valueOf"><Arg><Property name="jetty.httpConfig.requestCookieCompliance" deprecated="jetty.httpConfig.cookieCompliance" default="RFC6265"/></Arg></Call></Set>
|
||||
<Set name="responseCookieCompliance"><Call class="org.eclipse.jetty.http.CookieCompliance" name="valueOf"><Arg><Property name="jetty.httpConfig.responseCookieCompliance" default="RFC6265"/></Arg></Call></Set>
|
||||
<Set name="multiPartFormDataCompliance"><Call class="org.eclipse.jetty.server.MultiPartFormDataCompliance" name="valueOf"><Arg><Property name="jetty.httpConfig.multiPartFormDataCompliance" default="RFC7578"/></Arg></Call></Set>
|
||||
</New>
|
||||
|
||||
<!-- =========================================================== -->
|
||||
<!-- Set the default handler structure for the Server -->
|
||||
<!-- A handler collection is used to pass received requests to -->
|
||||
<!-- both the ContextHandlerCollection, which selects the next -->
|
||||
<!-- handler by context path and virtual host, and the -->
|
||||
<!-- DefaultHandler, which handles any requests not handled by -->
|
||||
<!-- the context handlers. -->
|
||||
<!-- Other handlers may be added to the "Handlers" collection, -->
|
||||
<!-- for example the jetty-requestlog.xml file adds the -->
|
||||
<!-- RequestLogHandler after the default handler -->
|
||||
<!-- =========================================================== -->
|
||||
<Set name="handler">
|
||||
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
|
||||
<Set name="handlers">
|
||||
<Array type="org.eclipse.jetty.server.Handler">
|
||||
<Item>
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
|
||||
</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
</New>
|
||||
</Set>
|
||||
|
||||
<!-- =========================================================== -->
|
||||
<!-- extra server options -->
|
||||
<!-- =========================================================== -->
|
||||
<Set name="stopAtShutdown"><Property name="jetty.server.stopAtShutdown" default="true"/></Set>
|
||||
<Set name="stopTimeout"><Property name="jetty.server.stopTimeout" default="5000"/></Set>
|
||||
<Set name="dumpAfterStart"><Property name="jetty.server.dumpAfterStart" deprecated="jetty.dump.start" default="false"/></Set>
|
||||
<Set name="dumpBeforeStop"><Property name="jetty.server.dumpBeforeStop" deprecated="jetty.dump.stop" default="false"/></Set>
|
||||
|
||||
</Configure>
|
@ -1,10 +0,0 @@
|
||||
#!/bin/bash
|
||||
version="0.1"
|
||||
file="target/test-proxy-${version}.war"
|
||||
groupId="com.olexyn.test.proxy"
|
||||
artifactId="test-proxy"
|
||||
|
||||
|
||||
|
||||
mvn package
|
||||
mvn install:install-file -Dfile=${file} -DgroupId=${groupId} -DartifactId=${artifactId} -Dversion=${version} -Dpackaging=war -DgeneratePom=true
|
@ -1,56 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
|
||||
<Configure id="server" class="org.eclipse.jetty.server.Server">
|
||||
<New id="ServletContextHandler" class="org.eclipse.jetty.servlet.ServletContextHandler">
|
||||
<Set name="servletHandler">
|
||||
<New id="servletHandler" class="org.eclipse.jetty.servlet.ServletHandler">
|
||||
<Call id="proxyHolder" name="addServletWithMapping">
|
||||
<Arg>org.eclipse.jetty.servlets.ProxyServlet$Transparent</Arg>
|
||||
<Arg>/proxy/*</Arg>
|
||||
<Call name="setInitParameter">
|
||||
<Arg>maxThreads</Arg>
|
||||
<Arg>
|
||||
<Property name="jetty.proxy.maxThreads" default="128"/>
|
||||
</Arg>
|
||||
</Call>
|
||||
<Call name="setInitParameter">
|
||||
<Arg>maxConnections</Arg>
|
||||
<Arg>
|
||||
<Property name="jetty.proxy.maxConnections" default="256"/>
|
||||
</Arg>
|
||||
</Call>
|
||||
<Call name="setInitParameter">
|
||||
<Arg>idleTimeout</Arg>
|
||||
<Arg>
|
||||
<Property name="jetty.proxy.idleTimeout" default="30000"/>
|
||||
</Arg>
|
||||
</Call>
|
||||
<Call name="setInitParameter">
|
||||
<Arg>timeout</Arg>
|
||||
<Arg>
|
||||
<Property name="jetty.proxy.timeout" default="60000"/>
|
||||
</Arg>
|
||||
</Call>
|
||||
<Call name="setInitParameter">
|
||||
<Arg>ProxyTo</Arg>
|
||||
<Arg>http://localhost:8080/misp-mirror</Arg>
|
||||
</Call>
|
||||
<Call name="setInitParameter">
|
||||
<Arg>Prefix</Arg>
|
||||
<Arg>/proxy</Arg>
|
||||
</Call>
|
||||
</Call>
|
||||
</New>
|
||||
</Set>
|
||||
</New>
|
||||
<Set name="handler">
|
||||
<New class="org.eclipse.jetty.server.handler.HandlerList">
|
||||
<Set name="handlers">
|
||||
<Array type="org.eclipse.jetty.server.Handler">
|
||||
<Item>
|
||||
<Ref id="ServletContextHandler"></Ref>
|
||||
</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
</New>
|
||||
</Set>
|
||||
</Configure>
|
@ -1,22 +0,0 @@
|
||||
<!DOCTYPE web-app PUBLIC
|
||||
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
|
||||
"http://java.sun.com/dtd/web-app_2_3.dtd" >
|
||||
|
||||
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
|
||||
version="2.4">
|
||||
|
||||
<display-name>misp-proxy</display-name>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>test-proxy</servlet-name>
|
||||
<servlet-class>com.olexyn.test.proxy.ProxyServlet</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>test-proxy</servlet-name>
|
||||
<url-pattern>/core</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
</web-app>
|
@ -1,20 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>test-proxy</title>
|
||||
</head>
|
||||
<body bgcolor=white>
|
||||
|
||||
<table border="0">
|
||||
<tr>
|
||||
<td align=center>
|
||||
<img src="images/io42630.png">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<h1>test-proxy</h1>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |