Example usage for javax.xml.namespace QName QName

List of usage examples for javax.xml.namespace QName QName

Introduction

In this page you can find the example usage for javax.xml.namespace QName QName.

Prototype

public QName(String localPart) 

Source Link

Document

QName constructor specifying the local part.

If the local part is null an IllegalArgumentException is thrown.

Usage

From source file:com.evolveum.midpoint.prism.PrismObjectValue.java

@Override
public String toString() {
    // we don't delegate to PrismObject, because various exceptions during that process could in turn call this method
    StringBuilder sb = new StringBuilder();
    sb.append("POV:");
    if (getParent() != null) {
        sb.append(getParent().getElementName().getLocalPart()).append(":");
    } else if (getComplexTypeDefinition() != null) {
        sb.append(getComplexTypeDefinition().getTypeName().getLocalPart()).append(":");
    }//from  w ww  .  ja v  a 2s .c  om
    sb.append(oid).append("(");
    PrismProperty nameProperty = findProperty(new QName(PrismConstants.NAME_LOCAL_NAME));
    sb.append(nameProperty != null ? nameProperty.getRealValue() : null);
    sb.append(")");
    return sb.toString();
}

From source file:com.evolveum.midpoint.prism.marshaller.BeanMarshaller.java

@Nullable
public <T> XNode marshall(@Nullable T bean, @Nullable SerializationContext ctx) throws SchemaException {
    if (bean == null) {
        return null;
    }/*ww  w  .  j ava 2  s . c o m*/
    Marshaller marshaller = specialMarshallers.get(bean.getClass());
    if (marshaller != null) {
        return marshaller.marshal(bean, ctx);
    }

    // avoiding chatty PolyString serializations (namespace declaration + orig + norm)
    if (bean instanceof PolyString) {
        bean = (T) ((PolyString) bean).getOrig();
    } else if (bean instanceof PolyStringType) {
        bean = (T) ((PolyStringType) bean).getOrig();
    }

    if (bean instanceof Containerable) {
        return prismContext.xnodeSerializer().context(ctx).serializeRealValue(bean, new QName("dummy"))
                .getSubnode();
    } else if (bean instanceof Enum) {
        return marshalEnum((Enum) bean, ctx);
    } else if (bean.getClass().getAnnotation(XmlType.class) != null) {
        return marshalXmlType(bean, ctx);
    } else {
        return marshalToPrimitive(bean, ctx);
    }
}

From source file:edu.washington.shibboleth.attribute.resolver.spring.dc.rws.RwsDataConnectorParser.java

/** {@inheritDoc} */
@Override/*from w ww .j  ava 2s  .co  m*/
protected void doV2Parse(@Nonnull final Element config, @Nonnull final ParserContext parserContext,
        @Nonnull final BeanDefinitionBuilder builder) {

    log.debug("parsing v2 configuration {}", config);
    String pluginId = "placeholder";

    String httpDataSourceId = StringSupport.trimOrNull(config.getAttribute("httpDataSourceRef"));
    Constraint.isNotNull(config, "httpDataSourceRef parameter is required");
    builder.addPropertyReference("httpDataSource", httpDataSourceId);

    builder.addPropertyValue("queryStringBuilder", createTemplatedQueryStringBuilder(config));

    final List<Element> attrElements = ElementSupport.getChildElements(config, ATTRIBUTE_ELEMENT_NAME);
    List<RwsAttribute> attributes = parseAttributes(attrElements);
    log.debug("Setting the following attributes for plugin {}: {}", pluginId, attributes);
    builder.addPropertyValue("rwsAttributes", attributes);

    String baseURL = StringSupport.trimOrNull(config.getAttribute("baseURL"));
    log.debug("Data connector {} base URL: {}", pluginId, baseURL);
    builder.addPropertyValue("baseUrl", baseURL);

    AUTHENTICATION_TYPE authnType = AUTHENTICATION_TYPE.NONE;
    if (AttributeSupport.hasAttribute(config, new QName("authenticationType"))) {
        authnType = AUTHENTICATION_TYPE
                .valueOf(StringSupport.trimOrNull(config.getAttribute("authenticationType")));
    }
    log.debug("Data connector {} authentication type: {}", pluginId, authnType);
    builder.addPropertyValue("authenticationType", authnType);

    String username = StringSupport.trimOrNull(config.getAttribute("username"));
    if (username != null)
        log.debug("Data connector {} username: {}", pluginId, username);
    builder.addPropertyValue("username", username);

    String password = StringSupport.trimOrNull(config.getAttribute("password"));
    builder.addPropertyValue("password", password);

    /***
            int maxConnections = 0;
            if (StringSupport.trimOrNull(config.getAttribute( "maxConnections")) {
    maxConnections = Integer.parseInt(StringSupport.trimOrNull(config.getAttribute( "maxConnections"));
            }
            log.debug("Data connector {} max connections: {}", pluginId, maxConnections);
            builder.addPropertyValue("maxConnections", maxConnections);
            
            int searchTimeLimit = 20000;
            if (StringSupport.trimOrNull(config.getAttribute( "searchTimeLimit")) {
    searchTimeLimit = Integer.parseInt(StringSupport.trimOrNull(config.getAttribute( "searchTimeLimit"));
            }
            log.debug("Data connector {} search timeout: {}ms", pluginId, searchTimeLimit);
            builder.addPropertyValue("searchTimeLimit", searchTimeLimit);
            
            int maxResultSize = 1;
            if (StringSupport.trimOrNull(config.getAttribute( "maxResultSize")) {
    maxResultSize = Integer.parseInt(StringSupport.trimOrNull(config.getAttribute( "maxResultSize"));
            }
            log.debug("Data connector {} max search result size: {}", pluginId, maxResultSize);
            builder.addPropertyValue("maxResultSize", maxResultSize);
            
            boolean cacheResults = false;
            if (StringSupport.trimOrNull(config.getAttribute( "cacheResults")) {
    cacheResults = AttributeSupport.getAttributeValueAsBoolean(StringSupport.trimOrNull(config.getAttribute( "cacheResults"));
            }
            log.debug("Data connector {} cache results: {}", pluginId, cacheResults);
            builder.addPropertyValue("cacheResults", cacheResults);
            
            boolean mergeResults = false;
            if (StringSupport.trimOrNull(config.getAttribute( "mergeResults")) {
    mergeResults = AttributeSupport.getAttributeValueAsBoolean(StringSupport.trimOrNull(config.getAttribute( "mergeResults"));
            }
            log.debug("Data connector{} merge results: {}", pluginId, mergeResults);
            builder.addPropertyValue("mergeResults", mergeResults);
            
            boolean noResultsIsError = false;
            if (StringSupport.trimOrNull(config.getAttribute( "noResultIsError")) {
    noResultsIsError = AttributeSupport.getAttributeValueAsBoolean(StringSupport.trimOrNull(config.getAttribute(
            "noResultIsError"));
            }
            log.debug("Data connector {} no results is error: {}", pluginId, noResultsIsError);
            builder.addPropertyValue("noResultsIsError", noResultsIsError);
            
            int pollingFrequency = 60000;
            if (StringSupport.trimOrNull(config.getAttribute( "pollingFrequency")) {
    pollingFrequency = Integer.parseInt(StringSupport.trimOrNull(config.getAttribute( "pollingFrequency"));
            }
            log.debug("Data connector {} polling frequency: {}ms", pluginId, pollingFrequency);
            builder.addPropertyValue("pollingFrequency", pollingFrequency);
            
    **/
}

From source file:edu.monash.merc.system.parser.xml.GPMWSXmlParser.java

public List<GPMEntryBean> parseGPMXml(String fileName, XMLInputFactory2 factory2) {

    xmlif2 = factory2;/*from  w  w  w  . j  a  v a  2s .c o m*/
    logger.info("Starting to parse " + fileName);

    XMLEventReader2 xmlEventReader = null;
    List<GPMEntryBean> gpmEntryBeans = new ArrayList<GPMEntryBean>();
    try {
        xmlEventReader = (XMLEventReader2) xmlif2.createXMLEventReader(new FileInputStream(fileName));

        QName proteinQN = new QName(ELE_GPM_PROTEIN);
        QName enspQN = new QName(ATTR_GPM_ENSP);
        QName ensgQN = new QName(ATTR_GPM_ENSG);
        QName identiQN = new QName(ELE_GPM_IDENTIFICATION);
        QName besteQN = new QName(ATTR_GPM_IDEN_BESTE);
        QName samplesQN = new QName(ATTR_GPM_IDEN_SAMPLES);
        String ensg = null;
        String ensp = null;
        String beste = null;
        String samples = null;

        GPMEntryBean gpmEntryBean = null;

        while (xmlEventReader.hasNextEvent()) {
            //eventType = reader.next();
            XMLEvent event = xmlEventReader.nextEvent();
            if (event.isStartElement()) {
                StartElement element = event.asStartElement();

                //protein entry
                if (element.getName().equals(proteinQN)) {
                    //get the version attribute
                    Attribute enspAttr = element.getAttributeByName(enspQN);
                    Attribute ensgAttr = element.getAttributeByName(ensgQN);
                    if (enspAttr != null) {
                        ensp = enspAttr.getValue();
                    }
                    if (ensgAttr != null) {
                        ensg = ensgAttr.getValue();
                    }
                    //create gpn entry bean
                    gpmEntryBean = new GPMEntryBean();
                    //create gpm dbsource
                    DBSourceBean gpmDbSourceBean = new DBSourceBean();
                    gpmDbSourceBean.setDbName(DbAcType.GPM.type());
                    gpmDbSourceBean.setPrimaryEvidences(true);
                    //set the gpm dbsource
                    gpmEntryBean.setPrimaryDbSourceBean(gpmDbSourceBean);

                    //create a gene bean
                    if (StringUtils.isNotBlank(ensg)) {
                        GeneBean geneBean = new GeneBean();
                        geneBean.setEnsgAccession(ensg);
                        gpmEntryBean.setGeneBean(geneBean);
                    }

                    //create an identified accession bean
                    AccessionBean identAccessionBean = parseIdentifiedAccessionBean(ensp);
                    gpmEntryBean.setIdentifiedAccessionBean(identAccessionBean);
                    //create dbsource and accession entry bean
                    List<DbSourceAcEntryBean> dbSourceAcEntryBeanList = parseDBSourceAcEntryBeans(ensp, ensg);
                    gpmEntryBean.setDbSourceAcEntryBeans(dbSourceAcEntryBeanList);

                }

                //protein entry
                if (element.getName().equals(identiQN)) {
                    Attribute besteAttr = element.getAttributeByName(besteQN);
                    Attribute samplesAttr = element.getAttributeByName(samplesQN);
                    if (besteAttr != null) {
                        beste = besteAttr.getValue();
                    }
                    if (samplesAttr != null) {
                        samples = samplesAttr.getValue();
                    }

                    //create pe ms prob evidence based on beste and ensp accesion
                    PEEvidenceBean peMsProbEvidence = createMsProbEvidence(beste, ensp);
                    //parse pe ms samples evidence
                    PEEvidenceBean peMsSamplesEvidence = createMsSamplesEvidence(samples, ensp);

                    if (peMsProbEvidence != null) {
                        gpmEntryBean.setPeMsProbEvidenceBean(peMsProbEvidence);
                    }
                    if (peMsSamplesEvidence != null) {
                        gpmEntryBean.setPeMsSamplesEvidenceBean(peMsSamplesEvidence);
                    }
                }
            }
            //End of element
            if (event.isEndElement()) {
                EndElement endElement = event.asEndElement();
                //hpa entry end
                if (endElement.getName().equals(proteinQN)) {
                    //if gene is not null, the  accession is not null and get some evidences for this gpm entry, then we add it to the list
                    GeneBean geneBean = gpmEntryBean.getGeneBean();
                    AccessionBean identifiedAcBean = gpmEntryBean.getIdentifiedAccessionBean();
                    PEEvidenceBean peMsProbEvidence = gpmEntryBean.getPeMsProbEvidenceBean();
                    PEEvidenceBean peMsSampEvidence = gpmEntryBean.getPeMsProbEvidenceBean();
                    if (geneBean != null && identifiedAcBean != null) {
                        if (peMsProbEvidence != null || peMsSampEvidence != null) {
                            gpmEntryBeans.add(gpmEntryBean);
                        }
                    }
                }
            }
        }
        return gpmEntryBeans;
    } catch (Exception ex) {
        logger.error(ex);
        throw new DMXMLParserException(ex);
    } finally {
        if (xmlEventReader != null) {
            try {
                xmlEventReader.close();
            } catch (Exception e) {
                //ignore whatever caught.
            }
        }
    }

}

From source file:org.wso2.carbon.http2.transport.util.Http2ConnectionFactory.java

/**
 * Create new connection and return client handler
 *
 * @param uri/*  ww w.j a  v a  2 s .c  o m*/
 * @return Http2ClientHandler
 * @throws AxisFault
 */
private Http2ClientHandler cacheNewConnection(HttpHost uri) throws AxisFault {

    final SslContext sslCtx;
    final boolean SSL;
    if (uri.getSchemeName().equalsIgnoreCase("https")) {
        SSL = true;
    } else
        SSL = false;
    try {
        // Handling SSL
        if (SSL) {
            Parameter trustParam = trasportOut.getParameter(Http2Constants.TRUST_STORE_CONFIG_ELEMENT);
            OMElement tsEle = null;
            if (trustParam != null) {
                tsEle = trustParam.getParameterElement();
            }
            final String location = tsEle.getFirstChildWithName(new QName(Http2Constants.TRUST_STORE_LOCATION))
                    .getText();
            final String storePassword = tsEle
                    .getFirstChildWithName(new QName(Http2Constants.TRUST_STORE_PASSWORD)).getText();

            SslProvider provider = OpenSsl.isAlpnSupported() ? SslProvider.OPENSSL : SslProvider.JDK;
            sslCtx = SslContextBuilder.forClient()
                    .trustManager(SSLUtil.createTrustmanager(location, storePassword)).sslProvider(provider)
                    .ciphers(Http2SecurityUtil.CIPHERS, SupportedCipherSuiteFilter.INSTANCE)
                    .trustManager(InsecureTrustManagerFactory.INSTANCE)
                    .applicationProtocolConfig(
                            new ApplicationProtocolConfig(ApplicationProtocolConfig.Protocol.ALPN,
                                    ApplicationProtocolConfig.SelectorFailureBehavior.NO_ADVERTISE,
                                    ApplicationProtocolConfig.SelectedListenerFailureBehavior.ACCEPT,
                                    ApplicationProtocolNames.HTTP_2, ApplicationProtocolNames.HTTP_1_1))
                    .build();
        } else {
            sslCtx = null;
        }
        Http2ClientInitializer initializer = new Http2ClientInitializer(sslCtx, Integer.MAX_VALUE);

        String HOST = uri.getHostName();
        Integer PORT = uri.getPort();
        // Configure the client.
        Bootstrap b = new Bootstrap();
        b.group(workerGroup);
        b.channel(NioSocketChannel.class);
        b.option(ChannelOption.SO_KEEPALIVE, true);
        b.remoteAddress(HOST, PORT);
        b.handler(initializer);
        // Start the client.
        Channel channel = b.connect().syncUninterruptibly().channel();

        log.debug("Connected to [" + HOST + ':' + PORT + ']');

        Http2SettingsHandler http2SettingsHandler = initializer.settingsHandler();
        http2SettingsHandler.awaitSettings(5, TimeUnit.SECONDS);

        final String key = generateKey(URI.create(uri.toURI()));
        Http2ClientHandler handler = initializer.responseHandler();

        clientConnections.put(key, handler);

        channel.closeFuture().addListener(new GenericFutureListener<Future<? super Void>>() {
            @Override
            public void operationComplete(Future<? super Void> future) throws Exception {
                clientConnections.remove(key);
            }
        });
        return initializer.responseHandler();
    } catch (SSLException e) {
        throw new AxisFault("Error while connection establishment:", e);
    } catch (Exception e) {
        throw new AxisFault("Error while connection establishment:" + e);
    }
}

From source file:hydrograph.ui.engine.converter.impl.InputXmlConverter.java

@Override
protected List<TypeBaseField> getFieldOrRecord(List<GridRow> gridList) {
    logger.debug("Generating data for {} for property {}",
            new Object[] { properties.get(Constants.PARAM_NAME), PropertyNameConstants.SCHEMA.value() });

    List<TypeBaseField> typeBaseFields = new ArrayList<>();
    if (gridList != null && gridList.size() != 0) {
        for (GridRow object : gridList) {
            XPathGridRow xPathGridRow = (XPathGridRow) object;
            TypeBaseField gridRow = converterHelper.getSchemaGridTargetData(object);
            if (StringUtils.isNotBlank(xPathGridRow.getXPath())) {
                gridRow.getOtherAttributes().put(new QName(Constants.ABSOLUTE_OR_RELATIVE_XPATH_QNAME),
                        xPathGridRow.getXPath());
            }//  www.  j  a  v a 2 s .  c  o  m
            typeBaseFields.add(gridRow);
        }
    }
    return typeBaseFields;
}

From source file:com.msopentech.odatajclient.testservice.utils.XMLUtilities.java

/**
 * {@inheritDoc }/*from  www . j a  v  a 2  s. c  om*/
 */
@Override
protected InputStream addLinks(final String entitySetName, final String entitykey, final InputStream is,
        final Set<String> links) throws Exception {

    // -----------------------------------------
    // 0. Build reader and writer
    // -----------------------------------------
    final XMLEventReader reader = getEventReader(is);
    final XMLEventFactory eventFactory = XMLEventFactory.newInstance();

    final ByteArrayOutputStream bos = new ByteArrayOutputStream();
    final XMLOutputFactory xof = XMLOutputFactory.newInstance();
    final XMLEventWriter writer = xof.createXMLEventWriter(bos);
    // -----------------------------------------

    final XmlElement entry = getAtomElement(reader, writer, "entry");
    writer.add(entry.getStart());

    // add for links
    for (String link : links) {
        final Set<Attribute> attributes = new HashSet<Attribute>();
        attributes.add(eventFactory.createAttribute(new QName("title"), link));
        attributes.add(eventFactory.createAttribute(new QName("href"),
                Commons.getLinksURI(version, entitySetName, entitykey, link)));
        attributes.add(eventFactory.createAttribute(new QName("rel"), Constants.ATOM_LINK_REL + link));
        attributes.add(eventFactory.createAttribute(new QName("type"),
                Commons.linkInfo.get(version).isFeed(entitySetName, link) ? Constants.ATOM_LINK_FEED
                        : Constants.ATOM_LINK_ENTRY));

        writer.add(eventFactory.createStartElement(new QName(LINK), attributes.iterator(), null));
        writer.add(eventFactory.createEndElement(new QName(LINK), null));
    }

    writer.add(entry.getContentReader());
    writer.add(entry.getEnd());
    writer.add(reader);
    IOUtils.closeQuietly(is);

    writer.flush();
    writer.close();
    reader.close();

    return new ByteArrayInputStream(bos.toByteArray());
}

From source file:net.sf.taverna.t2.activities.soaplab.SoaplabActivity.java

@Override
public void executeAsynch(final Map<String, T2Reference> data, final AsynchronousActivityCallback callback) {
    callback.requestRun(new Runnable() {

        @SuppressWarnings("unchecked")
        public void run() {
            ReferenceService referenceService = callback.getContext().getReferenceService();

            Map<String, T2Reference> outputData = new HashMap<String, T2Reference>();

            try {
                // Copy the contents of the data set in the input map
                // to a new Map object which just contains the raw data
                // objects
                Map<String, Object> soaplabInputMap = new HashMap<String, Object>();
                for (Map.Entry<String, T2Reference> entry : data.entrySet()) {
                    Class<?> inputType = getInputType(entry.getKey());
                    logger.info("Resolving " + entry.getKey() + " to " + inputType);
                    soaplabInputMap.put(entry.getKey(), referenceService.renderIdentifier(entry.getValue(),
                            inputType, callback.getContext()));
                    logger.info("  Value = " + soaplabInputMap.get(entry.getKey()));
                }//  ww w  .  java2  s  .c  o m

                // Invoke the web service...
                Call call = (Call) new Service().createCall();
                call.setTimeout(new Integer(INVOCATION_TIMEOUT));
                // TODO is there endpoint stored in the configuration as a
                // String or a URL?
                // URL soaplabWSDLURL = new
                // URL(configurationBean.getEndpoint());
                call.setTargetEndpointAddress(json.get("endpoint").textValue());

                // Invoke the job and wait for it to complete
                call.setOperationName(new QName("createAndRun"));
                String jobID = (String) call.invoke(new Object[] { soaplabInputMap });
                // Get the array of desired outputs to avoid pulling
                // everything back
                // TODO Decide how to get the bound ports for the processor
                // OutputPort[] boundOutputs =
                // this.proc.getBoundOutputPorts();
                OutputPort[] boundOutputs = getOutputPorts().toArray(new OutputPort[0]);
                String[] outputPortNames = new String[boundOutputs.length];
                for (int i = 0; i < outputPortNames.length; i++) {
                    outputPortNames[i] = boundOutputs[i].getName();
                    logger.debug("Adding output : " + outputPortNames[i]);
                }

                if (!isPollingDefined()) {
                    // If we're not polling then use this behaviour
                    call.setOperationName(new QName("waitFor"));
                    call.invoke(new Object[] { jobID });
                } else {
                    // Wait for the polling interval then request a status
                    // and do this until the status is terminal.
                    boolean polling = true;
                    // Number of milliseconds to wait before the first
                    // status request.
                    int pollingInterval = json.get("pollingInterval").intValue();
                    while (polling) {
                        try {
                            Thread.sleep(pollingInterval);
                        } catch (InterruptedException ie) {
                            // do nothing
                        }
                        call.setOperationName(new QName("getStatus"));
                        String statusString = (String) call.invoke(new Object[] { jobID });
                        logger.info("Polling, status is : " + statusString);
                        if (statusString.equals("RUNNING") || statusString.equals("CREATED")) {
                            pollingInterval = (int) ((double) pollingInterval
                                    * json.get("pollingBackoff").doubleValue());
                            if (pollingInterval > json.get("pollingIntervalMax").intValue()) {
                                pollingInterval = json.get("pollingIntervalMax").intValue();
                            }
                        } else {
                            // Either completed with an error or success
                            polling = false;
                        }
                    }
                }

                // Get the status code
                call.setOperationName(new QName("getStatus"));
                String statusString = (String) call.invoke(new Object[] { jobID });
                if (statusString.equals("TERMINATED_BY_ERROR")) {
                    // Get the report
                    call.setOperationName(new QName("getSomeResults"));
                    HashMap<String, String> temp = new HashMap<String, String>(
                            (Map) call.invoke(new Object[] { jobID, new String[] { "report" } }));
                    String reportText = temp.get("report");
                    callback.fail("Soaplab call returned an error : " + reportText);
                    return;
                }

                // Get the results required by downstream processors
                call.setOperationName(new QName("getSomeResults"));
                HashMap<String, Object> outputMap = new HashMap<String, Object>(
                        (Map) call.invoke(new Object[] { jobID, outputPortNames }));

                // Tell soaplab that we don't need this session any more
                call.setOperationName(new QName("destroy"));
                call.invoke(new Object[] { jobID });

                // Build the map of DataThing objects
                for (Map.Entry<String, Object> entry : outputMap.entrySet()) {
                    String parameterName = entry.getKey();
                    Object outputObject = entry.getValue();
                    if (logger.isDebugEnabled())
                        logger.debug("Soaplab : parameter '" + parameterName + "' has type '"
                                + outputObject.getClass().getName() + "'");

                    if (outputObject instanceof String[]) {
                        // outputThing = DataThingFactory
                        // .bake((String[]) outputObject);
                        outputData.put(parameterName, referenceService.register(Arrays.asList(outputObject), 1,
                                true, callback.getContext()));
                    } else if (outputObject instanceof byte[][]) {
                        // Create a List of byte arrays, this will
                        // map to l('application/octet-stream') in
                        // the output document.
                        // outputThing = DataThingFactory
                        // .bake((byte[][]) outputObject);
                        List<byte[]> list = new ArrayList<byte[]>();
                        for (byte[] byteArray : (byte[][]) outputObject) {
                            list.add(byteArray);
                        }
                        outputData.put(parameterName,
                                referenceService.register(list, 1, true, callback.getContext()));
                        // outputData.put(parameterName, dataFacade
                        // .register(Arrays.asList(outputObject)));
                    } else if (outputObject instanceof List) {
                        List<?> convertedList = convertList((List<?>) outputObject);
                        outputData.put(parameterName,
                                referenceService.register(convertedList, 1, true, callback.getContext()));
                    } else {
                        // Fallthrough case, this mostly applies to
                        // output of type byte[] or string, both of which
                        // are handled perfectly sensibly by default.
                        outputData.put(parameterName,
                                referenceService.register(outputObject, 0, true, callback.getContext()));
                    }
                }

                // success
                callback.receiveResult(outputData, new int[0]);
            } catch (ReferenceServiceException e) {
                callback.fail("Error accessing soaplab input/output data", e);
            } catch (IOException e) {
                callback.fail("Failure calling soaplab", e);
            } catch (ServiceException e) {
                callback.fail("Failure calling soaplab", e);
            }
        }

    });

}

From source file:org.apache.servicemix.jms.JmsConsumerEndpointTest.java

public void testConsumerStateless() throws Exception {
    JmsComponent component = new JmsComponent();
    JmsConsumerEndpoint endpoint = new JmsConsumerEndpoint();
    endpoint.setService(new QName("jms"));
    endpoint.setEndpoint("endpoint");
    endpoint.setTargetService(new QName("receiver"));
    endpoint.setListenerType("simple");
    endpoint.setConnectionFactory(connectionFactory);
    endpoint.setDestinationName("destination");
    endpoint.setStateless(true);//from  ww  w  . j  a  v a  2  s .  c o m
    component.setEndpoints(new JmsConsumerEndpoint[] { endpoint });
    container.activateComponent(component, "servicemix-jms");

    jmsTemplate.convertAndSend("destination", "<hello>world</hello>");
    receiver.getMessageList().assertMessagesReceived(1);
}

From source file:de.tudarmstadt.ukp.dkpro.core.io.tiger.TigerXmlWriter.java

@Override
public void process(JCas aJCas) throws AnalysisEngineProcessException {
    OutputStream docOS = null;//  w ww .  j a v  a 2s  .  c  om
    try {
        docOS = getOutputStream(aJCas, filenameSuffix);

        XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newInstance();
        XMLEventWriter xmlEventWriter = new IndentingXMLEventWriter(
                xmlOutputFactory.createXMLEventWriter(docOS));

        JAXBContext context = JAXBContext.newInstance(TigerSentence.class);
        Marshaller marshaller = context.createMarshaller();
        // We use the marshaller only for individual sentences. That way, we do not have to 
        // build the whole TIGER object graph before seralizing, which should safe us some
        // memory.
        marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);

        XMLEventFactory xmlef = XMLEventFactory.newInstance();
        xmlEventWriter.add(xmlef.createStartDocument());
        xmlEventWriter.add(xmlef.createStartElement("", "", "corpus"));
        xmlEventWriter.add(xmlef.createStartElement("", "", "body"));

        int sentenceNumber = 1;
        for (Sentence s : select(aJCas, Sentence.class)) {
            TigerSentence ts = convertSentence(s, sentenceNumber);
            marshaller.marshal(new JAXBElement<TigerSentence>(new QName("s"), TigerSentence.class, ts),
                    xmlEventWriter);
            sentenceNumber++;
        }

        xmlEventWriter.add(xmlef.createEndElement("", "", "body"));
        xmlEventWriter.add(xmlef.createEndElement("", "", "corpus"));
        xmlEventWriter.add(xmlef.createEndDocument());
    } catch (Exception e) {
        throw new AnalysisEngineProcessException(e);
    } finally {
        closeQuietly(docOS);
    }
}