// includes
List<Descriptor> includeDescriptors = new ArrayList<Descriptor>();
for (Element includeElement : XmlUtil.elements(filterElement, "include")) {
includeDescriptors.add(parsePattern(includeElement, parse, parser));
}
ListDescriptor includesDescriptor = new ListDescriptor();
includesDescriptor.setValueDescriptors(includeDescriptors);
// excludes
List<Descriptor> excludeDescriptors = new ArrayList<Descriptor>();
for (Element excludeElement : XmlUtil.elements(filterElement, "exclude")) {
excludeDescriptors.add(parsePattern(excludeElement, parse, parser));
}
ListDescriptor excludesDescriptor = new ListDescriptor();
excludesDescriptor.setValueDescriptors(excludeDescriptors);
// address filter
ObjectDescriptor filterDescriptor = new ObjectDescriptor(AddressFilter.class);
filterDescriptor.addInjection("includePatterns", includesDescriptor);
filterDescriptor.addInjection("excludePatterns", excludesDescriptor);
serverDescriptor.addInjection("addressFilter", filterDescriptor);
}
// mail session properties
Element propertiesElement = XmlUtil.element(serverElement, "session-properties");
if (propertiesElement != null) {
Descriptor propertiesDescriptor =
(Descriptor) propertiesBinding.parse(propertiesElement, parse, parser);
serverDescriptor.addInjection("sessionProperties", propertiesDescriptor);
}
else {
parse.addProblem("missing mail session properties", element);
}
// authenticator
Element authenticatorElement = XmlUtil.element(serverElement, "authenticator");
if (authenticatorElement != null) {
Descriptor authenticatorDescriptor =
(Descriptor) objectBinding.parse(authenticatorElement, parse, parser);
serverDescriptor.addInjection("authenticator", authenticatorDescriptor);
}
}
// mail servers
ListDescriptor serversDescriptor = new ListDescriptor();
serversDescriptor.setValueDescriptors(serverDescriptors);
// mail session
ObjectDescriptor sessionDescriptor = new ObjectDescriptor(MailSessionImpl.class);
sessionDescriptor.addInjection("mailServers", serversDescriptor);
return sessionDescriptor;