Package org.apache.axis2.builder

Examples of org.apache.axis2.builder.Builder


            }
        }
       
        int index = contentType.indexOf(';');
        String type = index > 0 ? contentType.substring(0, index) : contentType;
        Builder builder = BuilderUtil.getBuilderFromSelector(type, msgContext);
        if (builder == null) {
            if (log.isDebugEnabled()) {
                log.debug("No message builder found for type '" + type + "'. Falling back to SOAP.");
            }
            builder = new SOAPBuilder();
        }
       
        OMElement documentElement;
        if (message instanceof BytesMessage) {
            // Extract the charset encoding from the content type and
            // set the CHARACTER_SET_ENCODING property as e.g. SOAPBuilder relies on this.
            String charSetEnc = null;
            try {
                if (contentType != null) {
                    charSetEnc = new ContentType(contentType).getParameter("charset");
                }
            } catch (ParseException ex) {
                // ignore
            }
            msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEnc);
           
            if (builder instanceof DataSourceMessageBuilder) {
                documentElement = ((DataSourceMessageBuilder)builder).processDocument(
                        new BytesMessageDataSource((BytesMessage)message), contentType,
                        msgContext);
            } else {
                documentElement = builder.processDocument(
                        new BytesMessageInputStream((BytesMessage)message), contentType,
                        msgContext);
            }
        } else if (message instanceof TextMessage) {
            TextMessageBuilder textMessageBuilder;
View Full Code Here


     * @param contentType
     * @return the configured message builder implementation class name against
     *         the given content type.
     */
    public Builder getMessageBuilder(String contentType) {
        Builder builder = null;
        if (messageBuilders.isEmpty()) {
            return null;
        }
        if (contentType != null) {
            builder = (Builder) messageBuilders.get(contentType);
View Full Code Here

        }
        return builder;
    }

    public Builder getMessageBuilder(String contentType, boolean defaultBuilder) {
        Builder builder = getMessageBuilder(contentType);
        if (builder == null && defaultBuilder){
            builder = new UnknownContentBuilder();
        }
        return builder;
    }
View Full Code Here

                    log.error(msg);
                    throw new RuntimeException(msg);
                }
                if (event.getType() == ServiceEvent.REGISTERED || event.getType() ==
                                                                  ServiceEvent.MODIFIED) {
                    Builder builder = (Builder) service;
                    lock.lock();
                    try {
                        axisConfig.addMessageBuilder(contextType, builder);
                    } finally {
                        lock.unlock();
View Full Code Here

    public void setDefaultBuilder(Builder defaultBuilder) {
        this.defaultBuilder = defaultBuilder;
    }

    public Builder getBuilder(String contentType) {
        Builder builder = messageBuilders.get(contentType);
        if (builder == null) {
            return defaultBuilder;
        }

        return builder;
View Full Code Here

        if (messageBuilders != null) {
            OMAttribute defaultBuilderAttr = messageBuilders.getAttribute(
                    new QName("defaultBuilder"));
            if (defaultBuilderAttr != null) {
                Builder builder = loadBuilder(defaultBuilderAttr.getAttributeValue());
                if (builder != null) {
                    endpoint.setDefaultBuilder(builder);
                }
            }

            Iterator it = messageBuilders.getChildrenWithName(
                    new QName(URLEndpointsConfiguration.MESSAGE_BUILDER));
            while(it.hasNext()) {
                OMElement builderElement = (OMElement) it.next();

                OMAttribute contentTypeAttr = builderElement.getAttribute(
                        new QName(URLEndpointsConfiguration.CONTENT_TYPE));
                if (contentTypeAttr == null) {
                    handleException(URLEndpointsConfiguration.CONTENT_TYPE +
                            " attribute cannot be null for URLEndpoint " +
                            "with the " + URLEndpointsConfiguration.URL_PATTERN + " : " + pattern);
                }

                OMAttribute classAttr = builderElement.getAttribute(
                        new QName(URLEndpointsConfiguration.CLASS));
                if (classAttr == null) {
                    handleException(URLEndpointsConfiguration.CLASS +
                            " attribute cannot be null for URLEndpoint " +
                            "with the " + URLEndpointsConfiguration.URL_PATTERN + " : " + pattern);
                }

                if (classAttr != null && contentTypeAttr != null) {
                    Builder builder = loadBuilder(classAttr.getAttributeValue());
                    if (builder != null) {
                        endpoint.addBuilder(contentTypeAttr.getAttributeValue(), builder);
                    }
                }
            }
View Full Code Here

            }
        }
       
        int index = contentType.indexOf(';');
        String type = index > 0 ? contentType.substring(0, index) : contentType;
        Builder builder = MessageProcessorSelector.getMessageBuilder(type, msgContext);
        if (builder == null) {
            if (log.isDebugEnabled()) {
                log.debug("No message builder found for type '" + type + "'. Falling back to SOAP.");
            }
            builder = new SOAPBuilder();
        }
       
        OMElement documentElement;
        if (message instanceof BytesMessage) {
            // Extract the charset encoding from the content type and
            // set the CHARACTER_SET_ENCODING property as e.g. SOAPBuilder relies on this.
            String charSetEnc = null;
            try {
                if (contentType != null) {
                    charSetEnc = new ContentType(contentType).getParameter("charset");
                }
            } catch (ParseException ex) {
                // ignore
            }
            msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEnc);
           
            if (builder instanceof DataSourceMessageBuilder) {
                documentElement = ((DataSourceMessageBuilder)builder).processDocument(
                        new BytesMessageDataSource((BytesMessage)message), contentType,
                        msgContext);
            } else {
                documentElement = builder.processDocument(
                        new BytesMessageInputStream((BytesMessage)message), contentType,
                        msgContext);
            }
        } else if (message instanceof TextMessage) {
            TextMessageBuilder textMessageBuilder;
View Full Code Here

    public void testBadgerfishQName() throws Exception {
        String jsonString = getBadgerfishJSONString();
        ByteArrayInputStream inStream = new ByteArrayInputStream(jsonString.getBytes("utf-8"));

        MessageContext msgCtx = new MessageContext();
        Builder builder = new JSONBadgerfishOMBuilder();
        OMElement elem = builder.processDocument(inStream,
                JSONTestConstants.CONTENT_TYPE_BADGERFISH, msgCtx);
       
        QName qname = elem.getQName();
        assertEquals("http://def.ns", qname.getNamespaceURI());
        assertEquals("p", qname.getLocalPart());
View Full Code Here

        String jsonString = getBadgerfishJSONString();
        ByteArrayInputStream inStream = new ByteArrayInputStream(jsonString.getBytes());

        MessageContext msgCtx = new MessageContext();
        Builder omBuilder = new JSONBadgerfishOMBuilder();
        OMElement elem = omBuilder.processDocument(inStream,
                JSONTestConstants.CONTENT_TYPE_BADGERFISH, msgCtx);

        elem.toString();

        SOAPEnvelope envelope = TransportUtils.createSOAPEnvelope(elem);
View Full Code Here

            IOException, ParserConfigurationException, SAXException {
        String jsonString = getBadgerfishJSONString();
        ByteArrayInputStream inStream = new ByteArrayInputStream(jsonString.getBytes());
        MessageContext msgCtx = new MessageContext();

        Builder omBuilder = new JSONBadgerfishOMBuilder();
        OMElement elem = omBuilder.processDocument(inStream,
                JSONTestConstants.CONTENT_TYPE_BADGERFISH, msgCtx);

        elem.toString();

        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
View Full Code Here

TOP

Related Classes of org.apache.axis2.builder.Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.