Package org.jibx.ws.codec

Examples of org.jibx.ws.codec.MediaType


            // make sure we have a service instance
            serv = m_serviceMapper.getServiceInstance(req);
            if (serv == null) {
                rsp.sendError(HttpServletResponse.SC_NOT_FOUND);
            } else {
                MediaType intype = getMediaType(req.getContentType(), serv.getMediaTypeMapper());
                MediaType outtype = getAcceptableMediaType(req.getHeader("Accept"), intype);

                synchronized (s_codecPool) {
                    // allocated codec(s) and buffers for the input and output
                    incodec = s_codecPool.getCodec(intype);
                    if (intype.equals(outtype)) {
View Full Code Here


     * @param protocol the protocol that the service is using
     * @return media type with parameters removed
     * @throws ServletException if <code>mediastring</code> contains no supported media type
     */
    private MediaType getMediaType(String mediastring, MediaTypeMapper mapper) throws ServletException {
        MediaType media;
        if (mediastring == null) {
            try {
                media = mapper.getMediaTypeFor(null);
            } catch (WsConfigurationException e) {
                throw new ServletException("Internal JiBX/WS error. Unable to find default media type due to '"
                    + e.getMessage() + "'.");
            }
        } else {
            try {
                media = new MediaType(mediastring, true);
            } catch (ParseException e) {
                throw new ServletException("Error parsing media type in content-type from request: " + mediastring);
            }
            if (!CodecDirectory.hasCodecFor(media)) {
                throw new ServletException("No supported media type in content-type from request: " + mediastring);
View Full Code Here

            m_dimeOutput = new DimeOutputBuffer();
            OutByteBuffer obuff = new OutByteBuffer();
            m_dimeOutput.setBuffer(obuff);
            obuff.setOutput(m_socket.getOutputStream());
        }
        MediaType type = msgProps.getContentType();
        int typecode = type == null ? DimeCommon.TYPE_NONE : DimeCommon.TYPE_MEDIA;
        m_dimeOutput.nextMessage();
        m_dimeOutput.nextPart(null, typecode, type == null ? null : type.toString());
    }
View Full Code Here

        /** {@inheritDoc} */
        public IXMLWriter getNormalWriter(String[] uris) throws IOException {
            if (m_writer == null) {

                // first set the output content type
                MediaType contentType = m_codec.getMediaType();

                MediaType.Parameter charset = null;
                if (m_characterCode != null) {
                    charset = new MediaType.Parameter(CHARSET_KEY, m_characterCode);
                }
                m_response.setContentType(contentType.toStringWithParams(new MediaType.Parameter[]{charset}));

                // set up the actual writer
                OutputStream outputStream = m_response.getOutputStream();
                if (m_interceptor != null) {
                    outputStream = m_interceptor.intercept(outputStream);
View Full Code Here

                    InByteBuffer ibuff = new InByteBuffer();
                    m_dimeInput.setBuffer(ibuff);
                    ibuff.setInput(m_socket.getInputStream());
                }
                if (m_dimeInput.nextMessage() && m_dimeInput.nextPart()) {
                    MediaType mediaType = null;
                    if (m_dimeInput.getPartTypeCode() == DimeCommon.TYPE_MEDIA) {
                        String partTypeText = m_dimeInput.getPartTypeText();
                        try {
                            MediaType partMediaType = new MediaType(partTypeText);
                            if (CodecDirectory.hasCodecFor(partMediaType)) {
                                mediaType = partMediaType;
                            }
                        } catch (ParseException e) {
                            throw new IOException("Unable to parse media type '" + partTypeText + "'");
View Full Code Here

            connection.setRequestProperty(propertyName, props.getProperty(propertyName));
        }
    }
   
    private static String getContentTypeProperty(MessageProperties props) {
        MediaType contentType = props.getContentType();
        MediaType.Parameter charset = null;
        MediaType.Parameter action = null;
        if (props.getCharset() != null) {
            charset = new MediaType.Parameter(CHARSET_KEY, props.getCharset().toLowerCase());
        }
        if (props.getOperation() != null) {
            action = new MediaType.Parameter(ACTION_KEY, props.getOperation());
        }
        return contentType.toStringWithParams(new MediaType.Parameter[] {charset, action});
    }
View Full Code Here

        }
       
        /** {@inheritDoc} */
        public IXMLReader getReader() throws IOException, WsException {
            if (m_reader == null) {
                MediaType mediaType = getContentMediaType();
                m_buffer = (InByteBuffer)m_inBufferCache.getInstance();
               
                InputStream inputStream;
                if (hasError()) {
                    inputStream = m_connection.getErrorStream();
View Full Code Here

            }
            return m_reader;
        }

        private MediaType getContentMediaType() throws IOException {
            MediaType mediaType = null;
            String ctype = getContentType();
            MediaType contentType;
            if (ctype != null) {
                try {
                    contentType = new MediaType(ctype);
                } catch (ParseException e) {
                    throw new IOException("Unable to parse content-type '" + ctype + "'");
                }
                if (CodecDirectory.hasCodecFor(contentType)) {
                    mediaType = contentType;
View Full Code Here

                Service serv = null;
                try {
                    if (s_logger.isDebugEnabled()) {
                        s_logger.debug("Beginning processing of receive message from " + m_clientAddress);
                    }
                    MediaType mediaType = null;
                    if (m_dimeInput.getPartTypeCode() == DimeCommon.TYPE_MEDIA) {
                        String partTypeText = m_dimeInput.getPartTypeText();
                        try {
                            MediaType partMediaType = new MediaType(partTypeText);
                            if (CodecDirectory.hasCodecFor(partMediaType)) {
                                mediaType = partMediaType;
                            }
                        } catch (ParseException e) {
                            throw new IOException("Unable to parse media type '" + partTypeText + "'");
View Full Code Here

         */
        public IXMLWriter getNormalWriter(String[] uris) throws IOException {
            if (!m_initialized) {
               
                // initialize DIME output first, then hook to writer, so data offset will be past header
                MediaType mediaType = m_codec.getMediaType();
                int typecode = mediaType == null ? DimeCommon.TYPE_NONE : DimeCommon.TYPE_MEDIA;
                m_dimeOutput.nextMessage();
                m_dimeOutput.nextPart(null, typecode, mediaType.toString());
                m_writer = m_codec.getWriter(m_dimeOutput, null, uris);
                initializeWriter(m_writer);
                m_initialized = true;
               
            }
View Full Code Here

TOP

Related Classes of org.jibx.ws.codec.MediaType

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.