public Object parse(Element element, Parse parse, Parser parser) {
// MailTemplateRegistry is added to the WireDescriptor with a ProvidedObjectDescriptor
// The MailTemplateRegistry descriptor is lazy initialized by this binding
// mail-template will add a MailTemplate to the MailTemplateRegistry
ProvidedObjectDescriptor templateRegistryDescriptor;
MailTemplateRegistry templateRegistry;
WireDefinition wireDefinition = parse.contextStackFind(WireDefinition.class);
String templateRegistryDescriptorName = (wireDefinition != null ? wireDefinition.getDescriptorName(MailTemplateRegistry.class) : null);
if (templateRegistryDescriptorName != null) {
templateRegistryDescriptor = (ProvidedObjectDescriptor) wireDefinition.getDescriptor(templateRegistryDescriptorName);
templateRegistry = (MailTemplateRegistry) templateRegistryDescriptor.getProvidedObject();
} else {
templateRegistry = new MailTemplateRegistry();
templateRegistryDescriptor = new ProvidedObjectDescriptor(templateRegistry, true);
}
// create the mail template and add it to the registry
MailTemplate mailTemplate = parseMailTemplate(element, parse);
String templateName = XmlUtil.attribute(element, "name", true, parse);