Package org.apache.cxf.jaxrs.ext

Examples of org.apache.cxf.jaxrs.ext.MessageContext


   
    protected void marshal(Marshaller ms, Object actualObject, Class<?> actualClass,
                  Type genericType, String enc, OutputStream os, boolean isCollection) throws Exception {
        OutputStream actualOs = os;
       
        MessageContext mc = getContext();
        if (mc != null && MessageUtils.isTrue(mc.get(Marshaller.JAXB_FORMATTED_OUTPUT))) {
            actualOs = new CachedOutputStream();   
        }
        XMLStreamWriter writer = createWriter(actualObject, actualClass, genericType, enc,
                                              actualOs, isCollection);
        ms.marshal(actualObject, writer);
View Full Code Here


        writer = JSONUtils.createIgnoreNsWriterIfNeeded(writer, ignoreNamespaces);
        return createTransformWriterIfNeeded(writer, os);
    }
   
    protected boolean isDropRootNeeded() {
        MessageContext mc = getContext();
        if (mc != null) {
            Object prop = mc.get(DROP_ROOT_CONTEXT_PROPERTY);
            if (prop != null) {
                // means the property has been set explicitly
                return MessageUtils.isTrue(prop);
            }
        }
View Full Code Here

                                           Class<?> pClass, Type genericType,
                                           Annotation[] paramAnns,
                                           String defaultValue,
                                           boolean decode) {
       
        MessageContext mc = new MessageContextImpl(m);
        MediaType mt = mc.getHttpHeaders().getMediaType();
       
        @SuppressWarnings("unchecked")
        MultivaluedMap<String, String> params =
            (MultivaluedMap<String, String>)m.get(FormUtils.FORM_PARAM_MAP);
       
View Full Code Here

        }
        return unmarshalFromInputStream(unmarshaller, is, mt);
    }
   
    protected XMLStreamReader getStreamReader(InputStream is, Class<?> type, MediaType mt) {
        MessageContext mc = getContext();
        XMLStreamReader reader = mc != null ? mc.getContent(XMLStreamReader.class) : null;
        if (reader == null && mc != null) {
            XMLInputFactory factory = (XMLInputFactory)mc.get(XMLInputFactory.class.getName());
            if (factory != null) {
                try {
                    reader = factory.createXMLStreamReader(is);
                } catch (XMLStreamException e) {
                    throw new WebApplicationException(
View Full Code Here

                attachments));
        }
    }
   
    private Collection<Attachment> getAttachments(boolean write) {
        MessageContext mc = getContext();
        if (mc != null) {
            // TODO: there has to be a better fix
            String propertyName = write ? "WRITE-" + Message.ATTACHMENTS : Message.ATTACHMENTS;
            return CastUtils.cast((Collection<?>)mc.get(propertyName));
        } else {
            return null;
        }
    }
View Full Code Here

        throws Exception {
       
        for (Map.Entry<String, Object> entry : mProperties.entrySet()) {
            ms.setProperty(entry.getKey(), entry.getValue());
        }
        MessageContext mc = getContext();
        if (mc != null) {
            // check Marshaller properties which might've been set earlier on,
            // they'll overwrite statically configured ones
            for (String key : MARSHALLER_PROPERTIES) {
                Object value = mc.get(key);
                if (value != null) {
                    ms.setProperty(key, value);
                }
            }
           
        }
        XMLStreamWriter writer = getStreamWriter(obj, os, mt);
        if (writer != null) {
            if (os == null) {
                ms.setProperty(Marshaller.JAXB_FRAGMENT, true);
            } else if (mc != null) {
                if (mc.getContent(XMLStreamWriter.class) != null) {
                    ms.setProperty(Marshaller.JAXB_FRAGMENT, true);
                }
                mc.put(XMLStreamWriter.class.getName(), writer);   
            }
            marshalToWriter(ms, obj, writer, mt);
            writer.writeEndDocument();
        } else {
            marshalToOutputStream(ms, obj, os, mt);
View Full Code Here

        }
    }
   
    protected XMLStreamWriter getStreamWriter(Object obj, OutputStream os, MediaType mt) {
        XMLStreamWriter writer = null;
        MessageContext mc = getContext();
        if (mc != null) {
            writer = mc.getContent(XMLStreamWriter.class);
            if (writer == null) {
                XMLOutputFactory factory = (XMLOutputFactory)mc.get(XMLOutputFactory.class.getName());
                if (factory != null) {
                    try {
                        writer = factory.createXMLStreamWriter(os);
                    } catch (XMLStreamException e) {
                        throw new WebApplicationException(
View Full Code Here

                                           Class<?> pClass, Type genericType,
                                           Annotation[] paramAnns,
                                           String defaultValue,
                                           boolean decode) {
       
        MessageContext mc = new MessageContextImpl(m);
        MediaType mt = mc.getHttpHeaders().getMediaType();
       
        @SuppressWarnings("unchecked")
        MultivaluedMap<String, String> params =
            (MultivaluedMap<String, String>)m.get(FormUtils.FORM_PARAM_MAP);
       
View Full Code Here

                                           Class<?> pClass, Type genericType,
                                           Annotation[] paramAnns,
                                           String defaultValue,
                                           boolean decode) {
       
        MessageContext mc = new MessageContextImpl(m);
        MediaType mt = mc.getHttpHeaders().getMediaType();
       
        @SuppressWarnings("unchecked")
        MultivaluedMap<String, String> params =
            (MultivaluedMap<String, String>)m.get(FormUtils.FORM_PARAM_MAP);
       
View Full Code Here

            out.close();
        }
    }
   
    protected XMLStreamReader getReaderFromMessage() {
        MessageContext mc = getContext();
        if (mc != null) {
            return (XMLStreamReader)mc.getContent(XMLStreamReader.class);
        } else {
            return null;
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.cxf.jaxrs.ext.MessageContext

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.