public class PriorityExecutorSerializer {
public static OMElement serialize(OMElement parent,
PriorityExecutor executor, String namespace) {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace nullNS = fac.createOMNamespace("", "");
OMElement executorElement = createElement(ExecutorConstants.PRIORITY_EXECUTOR, namespace);
if (executor.getName() != null) {
executorElement.addAttribute(fac.createOMAttribute(ExecutorConstants.NAME,
nullNS, executor.getName()));
}
if (executor.getBeforeExecuteHandler() != null) {
executorElement.addAttribute(fac.createOMAttribute(
ExecutorConstants.BEFORE_EXECUTE_HANDLER, nullNS,
executor.getBeforeExecuteHandler().getClass().getName()));
}
// create the queues configuration
MultiPriorityBlockingQueue queue = executor.getQueue();
NextQueueAlgorithm algo = queue.getNextQueueAlgorithm();
OMElement queuesEle = createElement(ExecutorConstants.QUEUES, namespace);
if (!(algo instanceof PRRNextQueueAlgorithm)) {
queuesEle.addAttribute(fac.createOMAttribute(ExecutorConstants.NEXT_QUEUE, nullNS,
algo.getClass().getName()));
}
if (!queue.isFixedSizeQueues()) {
queuesEle.addAttribute(fac.createOMAttribute(ExecutorConstants.IS_FIXED_SIZE,
nullNS, Boolean.toString(false)));
}
List<InternalQueue> intQueues = queue.getQueues();
for (InternalQueue intQueue : intQueues) {
OMElement queueEle = createElement(ExecutorConstants.QUEUE, namespace);
if (queue.isFixedSizeQueues()) {
queueEle.addAttribute(fac.createOMAttribute(ExecutorConstants.SIZE, nullNS,
Integer.toString(intQueue.getCapacity())));
}
queueEle.addAttribute(fac.createOMAttribute(ExecutorConstants.PRIORITY, nullNS,
Integer.toString(intQueue.getPriority())));
queuesEle.addChild(queueEle);
}
executorElement.addChild(queuesEle);
// create the Threads configuration
OMElement threadsEle = createElement(ExecutorConstants.THREADS, namespace);
threadsEle.addAttribute(fac.createOMAttribute(
ExecutorConstants.MAX, nullNS, Integer.toString(executor.getMax())));
threadsEle.addAttribute(fac.createOMAttribute(
ExecutorConstants.CORE, nullNS, Integer.toString(executor.getCore())));
threadsEle.addAttribute(fac.createOMAttribute(
ExecutorConstants.KEEP_ALIVE, nullNS, Integer.toString(executor.getKeepAlive())));
executorElement.addChild(threadsEle);
if (parent != null) {