Search in sources :

Example 6 with XMLMapper

use of org.jboss.staxmapper.XMLMapper in project wildfly by wildfly.

the class FileTimerPersistence method createMapper.

private XMLMapper createMapper(TimerServiceImpl timerService) {
    final XMLMapper mapper = XMLMapper.Factory.create();
    mapper.registerRootElement(new QName(EjbTimerXmlParser_1_0.NAMESPACE, EjbTimerXmlPersister.TIMERS), new EjbTimerXmlParser_1_0(timerService, factory, configuration, timerService.getTimedObjectInvoker().getValue().getClassLoader()));
    return mapper;
}
Also used : XMLMapper(org.jboss.staxmapper.XMLMapper) QName(javax.xml.namespace.QName)

Example 7 with XMLMapper

use of org.jboss.staxmapper.XMLMapper in project wildfly by wildfly.

the class MessagingXmlParsingDeploymentUnitProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final Set<VirtualFile> files = messageDestinations(deploymentUnit);
    final XMLMapper mapper = XMLMapper.Factory.create();
    final MessagingDeploymentParser_1_0 messagingDeploymentParser_1_0 = new MessagingDeploymentParser_1_0(JBossDescriptorPropertyReplacement.propertyReplacer(deploymentUnit));
    mapper.registerRootElement(ROOT_1_0, messagingDeploymentParser_1_0);
    mapper.registerRootElement(ROOT_NO_NAMESPACE, messagingDeploymentParser_1_0);
    for (final VirtualFile file : files) {
        InputStream xmlStream = null;
        try {
            final File f = file.getPhysicalFile();
            xmlStream = new FileInputStream(f);
            try {
                final XMLInputFactory inputFactory = INPUT_FACTORY;
                setIfSupported(inputFactory, XMLInputFactory.IS_VALIDATING, Boolean.FALSE);
                setIfSupported(inputFactory, XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
                final XMLStreamReader streamReader = inputFactory.createXMLStreamReader(xmlStream);
                final ParseResult result = new ParseResult();
                try {
                    mapper.parseDocument(result, streamReader);
                    deploymentUnit.addToAttachmentList(MessagingAttachments.PARSE_RESULT, result);
                } finally {
                    safeClose(streamReader, f.getAbsolutePath());
                }
            } catch (XMLStreamException e) {
                throw MessagingLogger.ROOT_LOGGER.couldNotParseDeployment(f.getPath(), e);
            }
        } catch (Exception e) {
            throw new DeploymentUnitProcessingException(e.getMessage(), e);
        } finally {
            VFSUtils.safeClose(xmlStream);
        }
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) XMLStreamReader(javax.xml.stream.XMLStreamReader) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) FileInputStream(java.io.FileInputStream) XMLStreamException(javax.xml.stream.XMLStreamException) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) XMLMapper(org.jboss.staxmapper.XMLMapper) XMLStreamException(javax.xml.stream.XMLStreamException) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) File(java.io.File) VirtualFile(org.jboss.vfs.VirtualFile) XMLInputFactory(javax.xml.stream.XMLInputFactory)

Aggregations

XMLMapper (org.jboss.staxmapper.XMLMapper)7 File (java.io.File)4 IOException (java.io.IOException)3 XMLStreamReader (javax.xml.stream.XMLStreamReader)3 VirtualFile (org.jboss.vfs.VirtualFile)3 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 SystemException (javax.transaction.SystemException)2 QName (javax.xml.namespace.QName)2 XMLInputFactory (javax.xml.stream.XMLInputFactory)2 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)2 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)2 FileOutputStream (java.io.FileOutputStream)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)1