/** * Write element content. The start element is already written. * * @param writer * @throws XMLStreamException */ public void writeContent(XMLStreamWriter writer) throws XMLStreamException { for (int i = 0; i < moduleEntries.size(); i++) { MappingModuleEntry entry = moduleEntries.get(i); writer.writeStartElement(Element.MAPPING_MODULE.getLocalName()); writer.writeAttribute(Attribute.CODE.getLocalName(), entry.getMappingModuleName()); writer.writeAttribute(Attribute.TYPE.getLocalName(), entry.getMappingModuleType()); Map<String, ?> options = entry.getOptions(); if (options != null && options.size() > 0) { for (Entry<String, ?> option : options.entrySet()) { writer.writeStartElement(Element.MODULE_OPTION.getLocalName()); writer.writeAttribute(Attribute.NAME.getLocalName(), option.getKey()); writer.writeAttribute(Attribute.VALUE.getLocalName(), option.getValue().toString()); writer.writeEndElement(); } } writer.writeEndElement(); } writer.writeEndElement(); } }
@SuppressWarnings("unchecked") private <T> MappingProvider<T> getMappingProvider(MappingModuleEntry mme) { ClassLoader tcl = SecurityActions.getContextClassLoader(); MappingProvider<T> mp = null; try { String fqn = mme.getMappingModuleName(); Class<?> cl = SecurityActions.loadClass(fqn,tcl); mp = (MappingProvider<T>) cl.newInstance(); mp.init(mme.getOptions()); } catch(Exception e) { if(trace) log.trace("Error in getting Mapping Provider",e); } return mp; } }
@SuppressWarnings("unchecked") private <T> MappingProvider<T> getMappingProvider(ClassLoader cl, MappingModuleEntry mme) { MappingProvider<T> mp = null; try { String fqn = mme.getMappingModuleName(); Class<?> clazz = SecurityActions.loadClass(cl, fqn); mp = (MappingProvider<T>) clazz.newInstance(); mp.init(mme.getOptions()); } catch(Exception e) { PicketBoxLogger.LOGGER.debugIgnoredException(e); } return mp; } }