use of org.apache.synapse.aspects.flow.statistics.structuring.StructuringElement in project wso2-synapse by wso2.
the class StatisticIdentityGeneratorTest method init.
@BeforeClass
public static void init() {
synapseConfiguration = new SynapseConfiguration();
StatisticIdentityGenerator.setSynapseConfiguration(synapseConfiguration);
artifactHolder = new ArtifactHolder();
ArrayList<StructuringElement> structuringElementList = new ArrayList<>();
structuringElement = new StructuringElement(COMPONENT_ID, ComponentType.ENDPOINT);
structuringElementList.add(structuringElement);
artifactHolder.setList(structuringElementList);
artifactHolder.setParent(PARENT);
artifactHolder.setHashCode(HASH_CODE);
Stack<StructuringElement> structuringElementStack = new Stack<>();
structuringElementStack.add(structuringElement);
artifactHolder.setStack(structuringElementStack);
artifactHolder.setId(0);
}
use of org.apache.synapse.aspects.flow.statistics.structuring.StructuringElement in project wso2-synapse by wso2.
the class StatisticIdentityGenerator method process.
private static void process(String name, ComponentType componentType, ArtifactHolder holder) {
if (ComponentType.PROXYSERVICE == componentType || ComponentType.API == componentType || ComponentType.INBOUNDENDPOINT == componentType) {
StructuringElement proxyElem = new StructuringElement(name, componentType);
holder.getStack().push(proxyElem);
holder.getList().add(proxyElem);
holder.setLastParent(name);
}
if (ComponentType.SEQUENCE == componentType) {
StructuringElement seqElem = new StructuringElement(name, componentType);
if (holder.getStack().isEmpty()) {
// This is directly deploying a sequence
holder.getStack().push(seqElem);
holder.getList().add(seqElem);
} else {
// There's a parent for sequence
seqElem.setParentId(holder.getLastParent());
seqElem.setGroup(holder.getStack().peek().getId());
holder.getStack().push(seqElem);
holder.getList().add(seqElem);
}
holder.setLastParent(name);
}
if (ComponentType.RESOURCE == componentType) {
StructuringElement resourceElem = new StructuringElement(name, componentType);
// There must be an API, which has this resource
resourceElem.setParentId(holder.getStack().peek().getId());
resourceElem.setGroup(holder.getStack().peek().getId());
holder.getList().add(resourceElem);
holder.setLastParent(name);
holder.getStack().push(resourceElem);
}
if (ComponentType.MEDIATOR == componentType) {
StructuringElement medElem = new StructuringElement(name, componentType);
if (holder.getExitFromBox()) {
holder.setExitFromBox(false);
}
medElem.setParentId(holder.getLastParent());
medElem.setGroup(holder.getStack().peek().getId());
if (holder.getStack().isEmpty()) {
// This is not a desired situation! Mediators always lies inside a sequence
log.error("Sequence is missing for mediator : " + name);
}
holder.getList().add(medElem);
holder.setLastParent(name);
holder.getStack().push(medElem);
}
if (ComponentType.ENDPOINT == componentType) {
StructuringElement endpointElem = new StructuringElement(name, componentType);
// Add parent only the endpoint is called by a mediator
if (!holder.getStack().isEmpty()) {
endpointElem.setParentId(holder.getStack().peek().getId());
endpointElem.setGroup(holder.getStack().peek().getId());
}
holder.getList().add(endpointElem);
}
}
Aggregations