private static final QName CLASS_Q = new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "class");
protected Mediator createSpecificMediator(OMElement elem, Properties properties) {
ClassMediator classMediator = new ClassMediator();
OMAttribute name = elem.getAttribute(ATT_NAME);
if (name == null) {
String msg = "The name of the actual mediator class is a required attribute";
log.error(msg);
throw new SynapseException(msg);
}
Class clazz = null;
Mediator m = null;
try {
clazz = getClass().getClassLoader().loadClass(
name.getAttributeValue());
m = (Mediator) clazz.newInstance();
} catch (Exception e) {
String msg = "Error : " + name.getAttributeValue();
log.error(msg, e);
throw new SynapseException(msg, e);
}
for (Iterator it = elem.getChildrenWithName(PROP_Q); it.hasNext();) {
OMElement child = (OMElement) it.next();
String propName = child.getAttribute(ATT_NAME).getAttributeValue();
if (propName == null) {
handleException(
"A Class mediator property must specify the name attribute");
} else {
if (child.getAttribute(ATT_VALUE) != null) {
String value = child.getAttribute(ATT_VALUE).getAttributeValue();
classMediator.addProperty(propName, value);
PropertyHelper.setInstanceProperty(propName, value, m);
} else {
OMNode omElt = child.getFirstElement();
if (omElt != null) {
classMediator.addProperty(propName, omElt);
PropertyHelper.setInstanceProperty(propName, omElt, m);
} else {
handleException("A Class mediator property must specify " +
"name and value attributes, or a name and a child XML fragment");
}
}
}
}
// after successfully creating the mediator
// set its common attributes such as tracing etc
classMediator.setMediator(m);
processAuditStatus(classMediator, elem);
return classMediator;
}