T288 SparkInitializer created. Added package for java classes
This commit is contained in:
@@ -24,7 +24,7 @@
|
|||||||
<!-- <manifest>-->
|
<!-- <manifest>-->
|
||||||
<!-- <addClasspath>true</addClasspath>-->
|
<!-- <addClasspath>true</addClasspath>-->
|
||||||
<!-- <classpathPrefix>lib/</classpathPrefix>-->
|
<!-- <classpathPrefix>lib/</classpathPrefix>-->
|
||||||
<!-- <mainClass>Main</mainClass>-->
|
<!-- <mainClass>r11.mltx.restxslt.Main</mainClass>-->
|
||||||
<!-- </manifest>-->
|
<!-- </manifest>-->
|
||||||
<!-- </archive>-->
|
<!-- </archive>-->
|
||||||
<!-- </configuration>-->
|
<!-- </configuration>-->
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
<manifest>
|
<manifest>
|
||||||
<addClasspath>true</addClasspath>
|
<addClasspath>true</addClasspath>
|
||||||
<classpathPrefix>lib/</classpathPrefix>
|
<classpathPrefix>lib/</classpathPrefix>
|
||||||
<mainClass>Main</mainClass>
|
<mainClass>r11.mltx.restxslt.Main</mainClass>
|
||||||
</manifest>
|
</manifest>
|
||||||
</archive>
|
</archive>
|
||||||
<descriptorRefs>
|
<descriptorRefs>
|
||||||
|
|||||||
7
REST_XSLT/src/main/java/r11/mltx/restxslt/Main.java
Normal file
7
REST_XSLT/src/main/java/r11/mltx/restxslt/Main.java
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package r11.mltx.restxslt;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SparkInitializer.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,14 +1,16 @@
|
|||||||
|
package r11.mltx.restxslt;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import processors.Saxon;
|
import r11.mltx.restxslt.processors.Saxon;
|
||||||
import processors.Xalan;
|
import r11.mltx.restxslt.processors.Xalan;
|
||||||
import spark.*;
|
import spark.*;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class Main {
|
public class SparkInitializer {
|
||||||
public static void main(String[] args) {
|
public static void run(){
|
||||||
Spark.port(8081);
|
Spark.port(8081);
|
||||||
|
|
||||||
Spark.after((Filter) (request, response) -> {
|
Spark.after((Filter) (request, response) -> {
|
||||||
@@ -25,9 +27,8 @@ public class Main {
|
|||||||
System.out.println("Server is online");
|
System.out.println("Server is online");
|
||||||
}
|
}
|
||||||
|
|
||||||
static Route procinfoHandler = (Request req, Response resp) -> {
|
private static Route procinfoHandler = (Request req, Response resp) -> {
|
||||||
try {
|
try {
|
||||||
// req.session().id
|
|
||||||
resp.header("processor", "Saxon " + Saxon.getVersion() + " over s9api");
|
resp.header("processor", "Saxon " + Saxon.getVersion() + " over s9api");
|
||||||
return Saxon.getVersion();
|
return Saxon.getVersion();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@@ -35,7 +36,7 @@ public class Main {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static Route xsdHandler = (Request req, Response resp) -> {
|
private static Route xsdHandler = (Request req, Response resp) -> {
|
||||||
String body = req.body();
|
String body = req.body();
|
||||||
System.out.println("Request: " + body);
|
System.out.println("Request: " + body);
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
@@ -72,7 +73,7 @@ public class Main {
|
|||||||
return resp;
|
return resp;
|
||||||
};
|
};
|
||||||
|
|
||||||
static Route xpathHandler = (Request req, Response resp) -> {
|
private static Route xpathHandler = (Request req, Response resp) -> {
|
||||||
|
|
||||||
String body = req.body();
|
String body = req.body();
|
||||||
System.out.println("Request: " + body);
|
System.out.println("Request: " + body);
|
||||||
@@ -148,7 +149,7 @@ public class Main {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static Route xsltHandler = (Request req, Response resp) -> {
|
private static Route xsltHandler = (Request req, Response resp) -> {
|
||||||
String body = req.body();
|
String body = req.body();
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
Map<String, String> jsonMap = null;
|
Map<String, String> jsonMap = null;
|
||||||
@@ -173,7 +174,6 @@ public class Main {
|
|||||||
long duration = 0;
|
long duration = 0;
|
||||||
switch (processor) {
|
switch (processor) {
|
||||||
case "saxon":
|
case "saxon":
|
||||||
// resp.header("processor", "Saxon " + Saxon.getVersion());
|
|
||||||
timeStart = System.currentTimeMillis();
|
timeStart = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
tmp = Saxon.processXSLT(data, query);
|
tmp = Saxon.processXSLT(data, query);
|
||||||
@@ -215,6 +215,5 @@ public class Main {
|
|||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
return ex.getMessage();
|
return ex.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package processors;
|
package r11.mltx.restxslt.processors;
|
||||||
|
|
||||||
import net.sf.saxon.om.NamespaceBinding;
|
import net.sf.saxon.om.NamespaceBinding;
|
||||||
import net.sf.saxon.om.NamespaceMap;
|
import net.sf.saxon.om.NamespaceMap;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package processors;
|
package r11.mltx.restxslt.processors;
|
||||||
|
|
||||||
import net.sf.saxon.om.NamespaceMap;
|
import net.sf.saxon.om.NamespaceMap;
|
||||||
import net.sf.saxon.s9api.*;
|
import net.sf.saxon.s9api.*;
|
||||||
@@ -1,10 +1,8 @@
|
|||||||
package processors;
|
package r11.mltx.restxslt.processors;
|
||||||
|
|
||||||
import org.apache.xpath.domapi.XPathEvaluatorImpl;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
|
|
||||||
import javax.xml.XMLConstants;
|
import javax.xml.XMLConstants;
|
||||||
import javax.xml.namespace.NamespaceContext;
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import javax.xml.transform.*;
|
import javax.xml.transform.*;
|
||||||
@@ -18,12 +16,10 @@ import javax.xml.xpath.XPath;
|
|||||||
import javax.xml.xpath.XPathConstants;
|
import javax.xml.xpath.XPathConstants;
|
||||||
import javax.xml.xpath.XPathExpression;
|
import javax.xml.xpath.XPathExpression;
|
||||||
import javax.xml.xpath.XPathFactory;
|
import javax.xml.xpath.XPathFactory;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
import org.xml.sax.SAXException;
|
|
||||||
|
|
||||||
public class Xalan {
|
public class Xalan {
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package processors;
|
package r11.mltx.restxslt.processors;
|
||||||
|
|
||||||
import org.w3c.dom.*;
|
import org.w3c.dom.*;
|
||||||
|
|
||||||
Reference in New Issue
Block a user