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
{ | |
"model": { | |
"input1.xml": { | |
"servlet1": { | |
"name1": "value1" | |
}, | |
"servlet2": { | |
"name1": "value1", | |
"name2": "value2" | |
}, |
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
// npm install xml2js | |
// compile using "./node_modules/.bin/tsc read_xml_out_csv.ts -w" | |
// run using node read_xml_out_csv.js | |
const parseString: any = require('xml2js').parseString; | |
import * as fs from "fs"; | |
const model = {}; // dictionary of dictionaries with filename -> servlet -> parameter name -> parameter value | |
const params = {}; // all params that are found (mapped to undefined) | |
const start = Date.now(); |
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
filename | servlet name | name1 | name2 | ||
---|---|---|---|---|---|
input1.xml | servlet1 | value1 | |||
input1.xml | servlet2 | value1 | value2 | ||
input1.xml | servlet3 | value2 | |||
input2.xml | servlet4 | value4 |
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
<?xml version="1.0"?> | |
<config> | |
<!-- 0..n servlets --> | |
<servlet> | |
<name>servlet1</name> | |
<!-- 0..n name-value pairs --> | |
<param-name>name1</param-name> | |
<param-value>value1</param-value> |
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
/* | |
* built using Scala 2.12.4 in intellij | |
* prerequisites: add library for org.scala-lang.modules:scala-xml_2.12:1.0.6 | |
*/ | |
package ch.maxant.readxmloutcsv | |
import java.io.{File, PrintWriter} | |
import scala.xml.XML | |
import java.lang.System.{currentTimeMillis => now} |
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
# prerequisites: | |
# https://github.com/stchris/untangle/blob/master/examples.py | |
# C:\temp>c:\Python27\Scripts\pip.exe install untangle | |
# run: C:\temp\read_xml_out_csv>c:\Python27\python.exe read_xml_out_csv.py | |
import untangle | |
import os | |
import time | |
def now(): | |
return time.time()*1000.0 |
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
@Resource UserTransaction ut; | |
@Override | |
protected void doGet(HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { | |
ut.begin(); | |
... | |
CompletableFuture<String> cf = new CompletableFuture<>(); | |
service.foo(cf, pw); | |
... |
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
@Stateless | |
public class Service5 { | |
@Resource ManagedExecutorService mes; | |
@Resource EJBContext ctx; | |
@PersistenceContext(name="asdf") EntityManager em; | |
@Asynchronous | |
public void foo(CompletableFuture<String> cf, final PrintWriter pw) { |
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
//type 1 | |
Future<String> f = service.foo(s); | |
String s = f.get(); //blocks the thread, but at least others can run | |
//... do something useful with the string... | |
//type 2 | |
Future<String> f = service.foo(s); | |
while(!f.isDone()){ | |
try { | |
Thread.sleep(100); |
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
@Stateless | |
public class Service2 { | |
@Asynchronous | |
public Future<String> foo(String s) { | |
// simulate some long running process | |
Thread.sleep(5000); | |
s += "<br>Service2: threadId=" + Thread.currentThread().getId(); | |
return new AsyncResult<String>(s); |
NewerOlder