[ https://issues.apache.org/jira/browse/XERCESJ-1429?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13049391#comment-13049391 ]
Thiwanka Somasiri commented on XERCESJ-1429: -------------------------------------------- This is a rough sketch for the AsynchronousDOMParserImpl class: package org.apache.xerces.parsers; import org.apache.xerces.util.SymbolTable; import org.apache.xerces.xni.grammars.XMLGrammarPool; import org.apache.xerces.xni.parser.XMLParserConfiguration; import org.w3c.dom.events.Event; import org.w3c.dom.events.EventListener; import org.w3c.dom.Document; import org.w3c.dom.events.*; import org.w3c.dom.ls.LSInput; import java.util.HashSet; /** * @version $Id: $ */ public class AsynchronousDOMParserImpl extends DOMParserImpl implements EventTarget{ //Create the HashSet to hold the event listeners that the users are subscribed to private HashSet listenerSet = new HashSet(); // To be added a new data structure to hold the event type private DOMParserImpl parser; private boolean fBusy = false; private LSInput ls; //Call the super class constructors - there are four constructors in the DOMParserImpl class public AsynchronousDOMParserImpl(String configuration, String schemaType){ super(configuration, schemaType); //Check whether these super() should be removed or not parser = new DOMParserImpl(configuration, schemaType); } public AsynchronousDOMParserImpl(XMLParserConfiguration config){ super(config); parser = new DOMParserImpl(config); } public AsynchronousDOMParserImpl(SymbolTable symbolTable){ super(symbolTable); parser = new DOMParserImpl(symbolTable); } public AsynchronousDOMParserImpl(SymbolTable symbolTable, XMLGrammarPool grammarPool){ super(symbolTable, grammarPool); parser = new DOMParserImpl(symbolTable, grammarPool); } public void addEventListener(String type, EventListener listener, boolean useCapture){ } public void removeEventListener(String type, EventListener listener, boolean useCapture){ } public boolean dispatchEvent(Event evt){ return false;//TODO change the return value } public Document parse(LSInput is){ try{ //final LSInput input = is; ls = is; //Set the busy flag true before creating the thread - use a setBusyFlag() setBusyFlag(); //Instantiate an object from the inner class and start the thread AsynchronousDOMParserImpl.TestInner target = new AsynchronousDOMParserImpl.TestInner(); Thread t = new Thread(target); t.start(); }catch(Exception e){ //TODO apply the proper exception e.printStackTrace(); }finally{ resetBusyFlag(); } return null; } public void setBusyFlag(){ fBusy = true; } public void resetBusyFlag(){ fBusy = false; } public boolean getBusy () { return fBusy; } class TestInner implements Runnable{ public void run(){ try{ parser.parse(ls); }catch(Exception e){ //TODO apply the proper exception e.printStackTrace(); }finally{ resetBusyFlag(); } } } } > [GSoC]: Asynchronous LSParser and parseWithContext > -------------------------------------------------- > > Key: XERCESJ-1429 > URL: https://issues.apache.org/jira/browse/XERCESJ-1429 > Project: Xerces2-J > Issue Type: New Feature > Components: DOM (Level 3 Load & Save) > Affects Versions: 2.9.1 > Reporter: Michael Glavassevich > Labels: gsoc2011 > > The goal of this project is to complete the implementation of the DOM Level 3 > LSParser. Though Xerces has a functional LSParser, there are a couple parts > of the spec which still need to be implemented. This includes an asynchronous > [1] version which returns from the parse method immediately and builds the > DOM tree on another thread as well as parseWithContext [2] which allows a > document fragment to be parsed and attached to an existing DOM. > Possible Mentors: Michael Glavassevich > [1] > http://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407/load-save.html#LS-LSParser > [2] > http://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407/load-save.html#LS-LSParser-parseWithContext -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: j-dev-unsubscr...@xerces.apache.org For additional commands, e-mail: j-dev-h...@xerces.apache.org