Merged in brasseld/openesb-components/ESBCOMP-87-problem-when-using-flow-with- (pull request #20)
ESBCOMP-87 Thread safety issue on DOM manipulationmaster
commit
19fffa1e20
|
@ -27,7 +27,6 @@
|
|||
*
|
||||
* END_HEADER - DO NOT EDIT
|
||||
*/
|
||||
|
||||
package com.sun.xml.transform.sware.impl;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
@ -70,10 +69,10 @@ import com.sun.xml.transform.sware.schema.SwareParticle.ParticleType;
|
|||
/**
|
||||
* Sorts a DOM tree at one level. The algorithm looks up an aggregated particle
|
||||
* from a flattened complex type model group and then uses the particle path
|
||||
* stored in the aggregated particle to determine if an ordered insertion to
|
||||
* the sorted list is possible. A dynamic particle tree is maintained,
|
||||
* which reflects the static particle tree structure but adds another
|
||||
* dimention, which represents the axis for repeating nodes.
|
||||
* stored in the aggregated particle to determine if an ordered insertion to the
|
||||
* sorted list is possible. A dynamic particle tree is maintained, which
|
||||
* reflects the static particle tree structure but adds another dimention, which
|
||||
* represents the axis for repeating nodes.
|
||||
*
|
||||
* @author Jun Xu
|
||||
* @since 6.0
|
||||
|
@ -89,12 +88,11 @@ class DOMSorter {
|
|||
private final List<Tile> mUnsortedList = new ArrayList<Tile>();
|
||||
private final PureLinkedList<Tile> mSortedList = new PureLinkedList<Tile>();
|
||||
private final RootXNode mRootX;
|
||||
|
||||
private boolean mInplace = true;
|
||||
|
||||
/**
|
||||
* Constructs from a transformer, a flattened complex type, a source
|
||||
* elemnt and a target element.
|
||||
* Constructs from a transformer, a flattened complex type, a source elemnt
|
||||
* and a target element.
|
||||
*
|
||||
* @param transformer the reordering transformer that provides context
|
||||
* information
|
||||
|
@ -136,6 +134,7 @@ class DOMSorter {
|
|||
public boolean checkSortNeeded()
|
||||
throws TransformerException, DOMException {
|
||||
NodeList childNodes = mSourceElement.getChildNodes();
|
||||
synchronized (childNodes) {
|
||||
ParticlePath lastPath = null;
|
||||
for (int i = 0; i < childNodes.getLength(); i++) {
|
||||
Node childNode = childNodes.item(i);
|
||||
|
@ -249,6 +248,7 @@ class DOMSorter {
|
|||
throw new InvalidSchemaException("Invalid Schema.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -261,6 +261,7 @@ class DOMSorter {
|
|||
public void sort() throws TransformerException, DOMException {
|
||||
|
||||
NodeList childNodes = mSourceElement.getChildNodes();
|
||||
synchronized (childNodes) {
|
||||
List<Node> otherNodes = null;
|
||||
boolean noSort = false;
|
||||
int i = 0;
|
||||
|
@ -382,8 +383,8 @@ class DOMSorter {
|
|||
DOMUtil.getQName(tgtElem));
|
||||
if (aggPart != null) {
|
||||
partApp =
|
||||
aggPart.getParticleAppearances().size() > 0 ?
|
||||
aggPart.getParticleAppearances().iterator().next() : null;
|
||||
aggPart.getParticleAppearances().size() > 0
|
||||
? aggPart.getParticleAppearances().iterator().next() : null;
|
||||
}
|
||||
if (partApp != null) {
|
||||
elemDecl = (SwareElement) partApp.getParticle();
|
||||
|
@ -426,6 +427,7 @@ class DOMSorter {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Analyzes order and adds an element to the sorted list.
|
||||
|
@ -433,8 +435,7 @@ class DOMSorter {
|
|||
* @param source the source element
|
||||
* @param target the target element
|
||||
* @param others other DOM nodes than element nodes before this element
|
||||
* @return an instance of Entry<Tile> if adding to sorted list is
|
||||
* successful
|
||||
* @return an instance of Entry<Tile> if adding to sorted list is successful
|
||||
* @throws OrderIndeterministicException thrown if the order is not
|
||||
* deterministic
|
||||
* @throws TooManyElementsException thrown if maxOccurs is reached
|
||||
|
@ -542,9 +543,9 @@ class DOMSorter {
|
|||
}
|
||||
|
||||
/**
|
||||
* Determines where to add the new element into the sorted list and
|
||||
* then adds it, and also update the dynamic particle tree based
|
||||
* on the new element added.
|
||||
* Determines where to add the new element into the sorted list and then
|
||||
* adds it, and also update the dynamic particle tree based on the new
|
||||
* element added.
|
||||
*
|
||||
* @param partApp the particle appearance instance
|
||||
* @param s the source element
|
||||
|
@ -552,8 +553,7 @@ class DOMSorter {
|
|||
* @param others other DOM nodes than DOM elements before this element
|
||||
*
|
||||
* @return non-null instance of Entry<Tile> if the element is
|
||||
* successfully added to the sorted list, otherwise
|
||||
* <code>null</code>
|
||||
* successfully added to the sorted list, otherwise <code>null</code>
|
||||
* @throws SwareSchemaException invalid schema exception
|
||||
*/
|
||||
public Entry<Tile> addLeafParticle(ParticleAppearance partApp,
|
||||
|
@ -634,8 +634,8 @@ class DOMSorter {
|
|||
}
|
||||
|
||||
/**
|
||||
* Cracks out the new repeating indices path assuming that a new
|
||||
* element is going to be added.
|
||||
* Cracks out the new repeating indices path assuming that a new element
|
||||
* is going to be added.
|
||||
*
|
||||
* @param path the path of the particle appearance
|
||||
* @return the repeating indices path
|
||||
|
@ -742,10 +742,12 @@ class DOMSorter {
|
|||
* Generic node type for the dynamic particle tree.
|
||||
*/
|
||||
abstract class GNode {
|
||||
|
||||
final GNode mOwner;
|
||||
|
||||
/**
|
||||
* Constructs from an owner.
|
||||
*
|
||||
* @param owner
|
||||
*/
|
||||
GNode(GNode owner) {
|
||||
|
@ -754,6 +756,7 @@ class DOMSorter {
|
|||
|
||||
/**
|
||||
* Gets the owner.
|
||||
*
|
||||
* @return the owner
|
||||
*/
|
||||
public GNode getOwner() {
|
||||
|
@ -761,17 +764,17 @@ class DOMSorter {
|
|||
}
|
||||
|
||||
/**
|
||||
* Locally adds an element, which only searches for the posibility
|
||||
* in direct child or repeating nodes.
|
||||
* Locally adds an element, which only searches for the posibility in
|
||||
* direct child or repeating nodes.
|
||||
*
|
||||
* @param partApp the particle appearance instance
|
||||
* @param i either the particle index or the repeating index
|
||||
* @param s the source element
|
||||
* @param e the target element
|
||||
* @param others other DOM nodes than DOM element nodes before
|
||||
* this element
|
||||
* @return A reference to a tile in the sorted list or
|
||||
* <code>null</code> if unable to insert
|
||||
* @param others other DOM nodes than DOM element nodes before this
|
||||
* element
|
||||
* @return A reference to a tile in the sorted list or <code>null</code>
|
||||
* if unable to insert
|
||||
*/
|
||||
abstract Entry<Tile> localAdd(ParticleAppearance partApp, int i,
|
||||
Element s, Element e, List<Node> others);
|
||||
|
@ -791,6 +794,7 @@ class DOMSorter {
|
|||
}
|
||||
|
||||
class RootYNode extends YNode {
|
||||
|
||||
RootYNode(XNode owner, SwareGroup g) throws SwareSchemaException {
|
||||
super(owner, g, true);
|
||||
}
|
||||
|
@ -801,7 +805,6 @@ class DOMSorter {
|
|||
static final int NO_OP = 0;
|
||||
static final int ADD_BEFORE = 1;
|
||||
static final int ADD_AFTER = 2;
|
||||
|
||||
final SwareParticle mPart;
|
||||
final SwareParticle[] mChildParts;
|
||||
final XNode[] mXNodes;
|
||||
|
@ -928,6 +931,7 @@ class DOMSorter {
|
|||
}
|
||||
|
||||
class XNode extends GNode {
|
||||
|
||||
final int[] mPCounters;
|
||||
final List<YNode> mYNodes = new ArrayList<YNode>();
|
||||
final SwareParticle mPart;
|
||||
|
@ -1006,8 +1010,8 @@ class DOMSorter {
|
|||
protected final List<Node> mOthers;
|
||||
|
||||
/**
|
||||
* Constructs from source element, target element and a list of
|
||||
* other nodes that are before the source node.
|
||||
* Constructs from source element, target element and a list of other
|
||||
* nodes that are before the source node.
|
||||
*
|
||||
* @param source source element
|
||||
* @param target target element
|
||||
|
@ -1037,8 +1041,8 @@ class DOMSorter {
|
|||
protected final ParticleAppearance mPartApp;
|
||||
|
||||
/**
|
||||
* Constructs from source element, target element, a list of other
|
||||
* nodes that are before the source node and a particle appearance.
|
||||
* Constructs from source element, target element, a list of other nodes
|
||||
* that are before the source node and a particle appearance.
|
||||
*
|
||||
* @param source source element
|
||||
* @param target target element
|
||||
|
|
Loading…
Reference in New Issue