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