Always wanted to share a 10 Java Web development process, the most satisfied with a software project design and implementation, but always because of their laziness, do not love to tidy up and stop before, today finally whim, decided to share this experience.
In the face of Internet technology, as a high-level software engineering, to be on the path of programmers to go on, then we can not avoid to open their own brain hole, with a new design concept, a perfect design concept at least support a product line, a bad idea can only support a functional point, The future of the Internet era in the software industry to go forward, then must take the product line, the best product is to support this product line of any personalized requirements.
My previous project was to implement a project that supported all individual needs, starting with the concept of the product. The products we have done before are reconciled. The so-called reconciliation is the two documents between the records, according to the records of the unique identification, the comparison of the amount, at the same time get four reconciliation results record (the amount is consistent, the amount is inconsistent, more than 1 documents, more than 2 documents) of the four results. Different reconciliation results have different automatic processing. At the same time our product concept is able to support the reconciliation between multiple systems, that is, to support different formats of files, different reconciliation strategies, do not need to modify the code to complete a product such as the design and implementation. After a long investigation, we finally decided to use Java code to reference the JS code. That is to say through the page configuration JS strategy, and then use the implementation of the comparison file to parse JS, to achieve ultra-dynamic product results.
The code is implemented as follows: Parsing JS
Public Reconciliation createreconciliation (Acccheckcfg acccheckcfg) {
ScriptEngine engine = new Scriptenginemanager (). Getenginebyname ("Nashorn");
try {
Engine.eval (Acccheckcfg.getjsscript ());
Reconciliation DYDZWJ = new reconciliation ();//define corresponding entity
if (engine instanceof invocable) {
Invocable invengine = (invocable) engine;
Invengine.invokefunction ("Putparameters", null, dydzwj,-1);//Copy the content defined in the script into the Dydzwj object.
return DYDZWJ;
}
} catch (Exception e) {
TODO auto-generated Catch block
E.printstacktrace ();
}
return null;
}
JS instance:
function Putparameters (pojoinfo,reclog) {
Pojoinfo.setautoprocess ("01");
Pojoinfo.setautoesbpath ("");
Pojoinfo.settempletpath ("");
Pojoinfo.setxpath1 ("/message/body/bankcode");
Pojoinfo.setvalue1 (Reclog.getaccsyscode ());
Pojoinfo.setxpath2 ("/message/body/transdate");
Pojoinfo.setvalue2 (Reclog.getaccchecktime ());
Pojoinfo.setxpath3 ("/message/body/transcode");
Pojoinfo.setvalue3 (Reclog.getdatarec1key ());
Pojoinfo.setretxpath1 ("/message/body/transcode");
Pojoinfo.setretxpath2 ("/message/body/temp1");
Pojoinfo.setretxpath3 ("/MESSAGE/BODY/TEMP2");
}
This article from the "Woodcutter's shoulder Pole" blog, declined to reprint!
Java Reference JS code for efficient dynamic mechanism