当前位置: 首页>>代码示例>>Java>>正文


Java Message类代码示例

本文整理汇总了Java中org.apache.cxf.common.i18n.Message的典型用法代码示例。如果您正苦于以下问题:Java Message类的具体用法?Java Message怎么用?Java Message使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Message类属于org.apache.cxf.common.i18n包,在下文中一共展示了Message类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setProperty

import org.apache.cxf.common.i18n.Message; //导入依赖的package包/类
public void setProperty(String prop, Object value) {
    if (prop.equals(JAXBDataBinding.UNWRAP_JAXB_ELEMENT)) {
        unwrapJAXBElement = Boolean.TRUE.equals(value);
    } else if (prop.equals(org.apache.cxf.message.Message.class.getName())) {
        org.apache.cxf.message.Message m = (org.apache.cxf.message.Message)value;
        veventHandler = (ValidationEventHandler)m.getContextualProperty("jaxb-validation-event-handler");
        if (veventHandler == null) {
            veventHandler = databinding.getValidationEventHandler();
        }
        setEventHandler = MessageUtils.getContextualBoolean(m, "set-jaxb-validation-event-handler", true);
        
        Object unwrapProperty = m.get(JAXBDataBinding.UNWRAP_JAXB_ELEMENT);
        if (unwrapProperty == null) {
            unwrapProperty = m.getExchange().get(JAXBDataBinding.UNWRAP_JAXB_ELEMENT);
        }
        if (unwrapProperty != null) {
            unwrapJAXBElement = Boolean.TRUE.equals(unwrapProperty);
        }
    }
}
 
开发者ID:GeeQuery,项目名称:cxf-plus,代码行数:21,代码来源:DataReaderImpl.java

示例2: write

import org.apache.cxf.common.i18n.Message; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void write(Object obj, QName elementName, boolean optional, XMLStreamWriter output,
                  java.lang.reflect.Type objectType) throws Exception {
    AegisType aegisType = null;
    if (objectType instanceof Class) {
        aegisType = getContext().getTypeMapping().getType(objectType);
    }
    if (aegisType == null) {
        TypeCreator creator = getContext().getTypeMapping().getTypeCreator();
        aegisType = creator.createType(objectType);
    }
    
    if (aegisType == null) {
        Message message = new Message("NO_MAPPING_FOR_TYPE", LOG, objectType);
        throw new DatabindingException(message);
    }
    write(obj, elementName, optional, output, aegisType);
    
}
 
开发者ID:claudemamo,项目名称:jruby-cxf,代码行数:22,代码来源:AegisXMLStreamDataWriter.java

示例3: read

import org.apache.cxf.common.i18n.Message; //导入依赖的package包/类
/** {@inheritDoc}*/
public Object read(XMLStreamReader reader, AegisType desiredType) throws Exception {
    setupReaderPosition(reader);
    ElementReader elReader = new ElementReader(reader);

    if (elReader.isXsiNil()) {
        elReader.readToEnd();
        return null;
    }
    
    AegisType type = TypeUtil.getReadTypeStandalone(reader, aegisContext, desiredType);
    
    if (type == null) {
        throw new DatabindingException(new Message("NO_MAPPING", LOG));
    }

    return type.readObject(elReader, context);
}
 
开发者ID:claudemamo,项目名称:jruby-cxf,代码行数:19,代码来源:AegisXMLStreamDataReader.java

示例4: marshalWithBridge

import org.apache.cxf.common.i18n.Message; //导入依赖的package包/类
public static void marshalWithBridge(QName qname,
                                     Class<?> cls,
                                     Annotation anns[],
                                     Set<Type> ctxClasses,
                                     Object elValue,
                                     Object source, AttachmentMarshaller am) {
    try {
    	com.github.cxfplus.jaxbplus.JAXBUtils.BridgeWrapper bridge = com.github.cxfplus.jaxbplus.JAXBUtils.createBridge(ctxClasses, qname, cls, anns);

        if (source instanceof XMLStreamWriter) {
            bridge.marshal(elValue, (XMLStreamWriter)source, am);
        } else if (source instanceof OutputStream) {
            //the namespace is missing when marshal the xsd:QName type 
            //to the OutputStream directly 
            java.io.StringWriter sw = new java.io.StringWriter();
            StreamResult s1 = new StreamResult(sw);
            bridge.marshal(elValue, s1);
            ((OutputStream)source).write(sw.toString().getBytes());
        } else if (source instanceof Node) {
            bridge.marshal(elValue, (Node)source, am);
        } else {
            throw new Fault(new Message("UNKNOWN_SOURCE", LOG, source.getClass().getName()));
        }
    } catch (Exception ex) {
        if (ex instanceof javax.xml.bind.MarshalException) {
            javax.xml.bind.MarshalException marshalEx = (javax.xml.bind.MarshalException)ex;
            Message faultMessage = new Message("MARSHAL_ERROR", LOG, marshalEx.getLinkedException()
                .getMessage());
            throw new Fault(faultMessage, ex);
        } else {
            throw new Fault(new Message("MARSHAL_ERROR", LOG, ex.getMessage()), ex);
        }
    }

}
 
开发者ID:GeeQuery,项目名称:cxf-plus,代码行数:36,代码来源:JAXBEncoderDecoder.java

示例5: unmarshalWithBridge

import org.apache.cxf.common.i18n.Message; //导入依赖的package包/类
public static Object unmarshalWithBridge(QName qname,
                                         Class<?> cls,
                                         Annotation anns[],
                                         Set<Type> ctxClasses,
                                         Object source,
                                         AttachmentUnmarshaller am) {
    
    try {
    	com.github.cxfplus.jaxbplus.JAXBUtils.BridgeWrapper bridge = com.github.cxfplus.jaxbplus.JAXBUtils.createBridge(ctxClasses, qname, cls, anns);
       
        if (source instanceof XMLStreamReader) {
            //DOMUtils.writeXml(StaxUtils.read((XMLStreamReader)source), System.out);
            return bridge.unmarshal((XMLStreamReader)source, am);               
        } else if (source instanceof InputStream) {
            return bridge.unmarshal((InputStream)source);
        } else if (source instanceof Node) {
            return bridge.unmarshal((Node)source, am);
        } else {
            throw new Fault(new Message("UNKNOWN_SOURCE", LOG, source.getClass().getName()));
        }
    } catch (Exception ex) {
        if (ex instanceof javax.xml.bind.MarshalException) {
            javax.xml.bind.MarshalException marshalEx = (javax.xml.bind.MarshalException)ex;
            Message faultMessage = new Message("MARSHAL_ERROR", LOG, marshalEx.getLinkedException()
                .getMessage());
            throw new Fault(faultMessage, ex);
        } else {
            throw new Fault(new Message("MARSHAL_ERROR", LOG, ex.getMessage()), ex);
        }
    }

}
 
开发者ID:GeeQuery,项目名称:cxf-plus,代码行数:33,代码来源:JAXBEncoderDecoder.java

示例6: writeObject

import org.apache.cxf.common.i18n.Message; //导入依赖的package包/类
private static void writeObject(Marshaller u, Object source, Object mObj) throws Fault, JAXBException {
    if (source instanceof XMLStreamWriter) {
        u.marshal(mObj, (XMLStreamWriter)source);
    } else if (source instanceof OutputStream) {
        u.marshal(mObj, (OutputStream)source);
    } else if (source instanceof Node) {
        u.marshal(mObj, (Node)source);
    } else if (source instanceof XMLEventWriter) {
        u.marshal(mObj, (XMLEventWriter)source);
    } else {
        throw new Fault(new Message("UNKNOWN_SOURCE", LOG, source.getClass().getName()));
    }
}
 
开发者ID:GeeQuery,项目名称:cxf-plus,代码行数:14,代码来源:JAXBEncoderDecoder.java

示例7: getStreamWriter

import org.apache.cxf.common.i18n.Message; //导入依赖的package包/类
private static XMLStreamWriter getStreamWriter(Object source) throws Fault {
    if (source instanceof XMLStreamWriter) {
        return (XMLStreamWriter)source;
    } else if (source instanceof OutputStream) {
        return StaxUtils.createXMLStreamWriter((OutputStream)source);
    } else if (source instanceof Node) {
        return new W3CDOMStreamWriter((Element)source);
    }
    throw new Fault(new Message("UNKNOWN_SOURCE", LOG, source.getClass().getName()));
}
 
开发者ID:GeeQuery,项目名称:cxf-plus,代码行数:11,代码来源:JAXBEncoderDecoder.java

示例8: marshallNullElement

import org.apache.cxf.common.i18n.Message; //导入依赖的package包/类
public static void marshallNullElement(Marshaller marshaller,
                                       Object source,
                                       MessagePartInfo part) {
    Class<?> clazz = part != null ? (Class)part.getTypeClass() : null;
    try {
        writeObject(marshaller, source, new JAXBElement(part.getElementQName(), clazz, null));
    } catch (JAXBException e) {
        throw new Fault(new Message("MARSHAL_ERROR", LOG, e.getMessage()), e);
    }
}
 
开发者ID:GeeQuery,项目名称:cxf-plus,代码行数:11,代码来源:JAXBEncoderDecoder.java

示例9: createBridgeXsElement

import org.apache.cxf.common.i18n.Message; //导入依赖的package包/类
private void createBridgeXsElement(MessagePartInfo part, QName qn, QName typeName) {
    XmlSchemaElement el = null;
    SchemaInfo schemaInfo = serviceInfo.getSchema(qn.getNamespaceURI());
    if (schemaInfo != null) {
        el = schemaInfo.getElementByQName(qn);
        if (el == null) {
            el = createXsElement(schemaInfo.getSchema(), part, typeName, schemaInfo);

        } else if (!typeName.equals(el.getSchemaTypeName())) {
            throw new Fault(new Message("CANNOT_CREATE_ELEMENT", LOG,
                                        qn, typeName, el.getSchemaTypeName()));
        }
        return;
    }

    XmlSchema schema = schemas.newXmlSchemaInCollection(qn.getNamespaceURI());
    if (qualifiedSchemas) {
        schema.setElementFormDefault(XmlSchemaForm.QUALIFIED);
    }
    schemaInfo = new SchemaInfo(qn.getNamespaceURI(), qualifiedSchemas, false);
    schemaInfo.setSchema(schema);

    el = createXsElement(schema, part, typeName, schemaInfo);

    NamespaceMap nsMap = new NamespaceMap();
    nsMap.add(WSDLConstants.CONVENTIONAL_TNS_PREFIX, schema.getTargetNamespace());
    nsMap.add(WSDLConstants.NP_SCHEMA_XSD, WSDLConstants.NS_SCHEMA_XSD);
    schema.setNamespaceContext(nsMap);

    serviceInfo.addSchema(schemaInfo);
}
 
开发者ID:GeeQuery,项目名称:cxf-plus,代码行数:32,代码来源:JAXBSchemaInitializer.java

示例10: createUnmarshaller

import org.apache.cxf.common.i18n.Message; //导入依赖的package包/类
private Unmarshaller createUnmarshaller() {
    try {
        Unmarshaller um = null;
        um = context.createUnmarshaller();
        if (databinding.getUnmarshallerListener() != null) {
            um.setListener(databinding.getUnmarshallerListener());
        }
        if (setEventHandler) {
            um.setEventHandler(new WSUIDValidationHandler(veventHandler));
        }
        if (databinding.getUnmarshallerProperties() != null) {
            for (Map.Entry<String, Object> propEntry 
                : databinding.getUnmarshallerProperties().entrySet()) {
                try {
                    um.setProperty(propEntry.getKey(), propEntry.getValue());
                } catch (PropertyException pe) {
                    LOG.log(Level.INFO, "PropertyException setting Marshaller properties", pe);
                }
            }
        }
        um.setSchema(schema);
        um.setAttachmentUnmarshaller(getAttachmentUnmarshaller());
        return um;
    } catch (JAXBException ex) {
        if (ex instanceof javax.xml.bind.UnmarshalException) {
            javax.xml.bind.UnmarshalException unmarshalEx = (javax.xml.bind.UnmarshalException)ex;
            throw new Fault(new Message("UNMARSHAL_ERROR", LOG, unmarshalEx.getLinkedException()
                .getMessage()), ex);
        } else {
            throw new Fault(new Message("UNMARSHAL_ERROR", LOG, ex.getMessage()), ex);
        }
    }
}
 
开发者ID:GeeQuery,项目名称:cxf-plus,代码行数:34,代码来源:DataReaderImpl.java

示例11: initialize

import org.apache.cxf.common.i18n.Message; //导入依赖的package包/类
@Override
public void initialize(Client client, Bus bus) {
    checkZmqConfig();
    Conduit conduit = client.getConduit();
    if (!(conduit instanceof ZMQConduit)) {
        throw new ConfigurationException(new Message("ZMQCONFIGFEATURE_ONLY_ZMQ", LOG));
    }
    Endpoint ep = client.getEndpoint();
    changeTransportUriToZmq(ep);
    ZMQConduit zmqConduit = (ZMQConduit)conduit;
    zmqConduit.setZmqConfig(zmqConfig);
    super.initialize(client, bus);
}
 
开发者ID:claudemamo,项目名称:cxf-rt-transports-zeromq,代码行数:14,代码来源:ZMQConfigFeature.java

示例12: write

import org.apache.cxf.common.i18n.Message; //导入依赖的package包/类
public void write(Object obj, MessagePartInfo part, Element output) {
    AegisType type = databinding.getType(part);

    if (type == null) {
        throw new Fault(new Message("NO_MESSAGE_FOR_PART", LOG));
    }


    Context context = new Context(databinding.getAegisContext());

    context.setAttachments(attachments);
    type = TypeUtil.getWriteType(databinding.getAegisContext(), obj, type);
    try {
        W3CDOMStreamWriter domWriter = new W3CDOMStreamWriter(output);
        ElementWriter writer = new ElementWriter(domWriter);
        MessageWriter w2 = writer.getElementWriter(part.getConcreteName());
        if (type.isNillable() && type.isWriteOuter() && obj == null) {
            w2.writeXsiNil();
            w2.close();
            return;
        }

        type.writeObject(obj, w2, context);
        w2.close();
    } catch (DatabindingException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:claudemamo,项目名称:jruby-cxf,代码行数:29,代码来源:ElementDataWriter.java

示例13: setupReaderPosition

import org.apache.cxf.common.i18n.Message; //导入依赖的package包/类
private void setupReaderPosition(XMLStreamReader reader) throws Exception {
    if (reader.getEventType() == XMLStreamConstants.START_DOCUMENT) {
        while (XMLStreamConstants.START_ELEMENT != reader.getEventType()) {
            reader.nextTag();
        }
    }
    if (reader.getEventType() != XMLStreamConstants.START_ELEMENT) {
        Message message = new Message("STREAM_BAD_POSITION", LOG);
        throw new org.jrubycxf.aegis.DatabindingException(message.toString());
    }
}
 
开发者ID:claudemamo,项目名称:jruby-cxf,代码行数:12,代码来源:AegisXMLStreamDataReader.java

示例14: marshallException

import org.apache.cxf.common.i18n.Message; //导入依赖的package包/类
public static void marshallException(Marshaller marshaller, Exception elValue,
                                     MessagePartInfo part, Object source) {
    XMLStreamWriter writer = getStreamWriter(source);
    QName qn = part.getElementQName();
    try {
        writer.writeStartElement("ns1", qn.getLocalPart(), qn.getNamespaceURI());
        Class<?> cls = part.getTypeClass();
        XmlAccessorType accessorType = cls.getAnnotation(XmlAccessorType.class);
        if (accessorType == null && cls.getPackage() != null) {
            accessorType = cls.getPackage().getAnnotation(XmlAccessorType.class);
        }
        XmlAccessType accessType = accessorType != null
            ? accessorType.value() : XmlAccessType.PUBLIC_MEMBER;
        String namespace = part.getElementQName().getNamespaceURI();
        
        SchemaInfo sch = part.getMessageInfo().getOperation().getInterface()
            .getService().getSchema(namespace);
        if (sch != null) {
            if (!sch.isElementFormQualified()) {
                namespace = null;
            }
        } else {
            LOG.warning("Schema associated with " + namespace + " is null");
        }
        
        for (Field f : cls.getDeclaredFields()) {
            if (JAXBContextInitializer.isFieldAccepted(f, accessType)) {
                QName fname = new QName(namespace, f.getName());
                f.setAccessible(true);
                if (JAXBSchemaInitializer.isArray(f.getGenericType())) {
                    writeArrayObject(marshaller, writer, fname, f.get(elValue));                        
                } else {
                    writeObject(marshaller, writer, new JAXBElement(fname, String.class, 
                                                                    f.get(elValue)));
                }
            }
        }
        for (Method m : cls.getMethods()) {
            if (JAXBContextInitializer.isMethodAccepted(m, accessType)) {
                int idx = m.getName().startsWith("get") ? 3 : 2;
                String name = m.getName().substring(idx);
                name = Character.toLowerCase(name.charAt(0)) + name.substring(1);
                QName mname = new QName(namespace, name);
                if (JAXBSchemaInitializer.isArray(m.getGenericReturnType())) {
                    writeArrayObject(marshaller, writer, mname, m.invoke(elValue));
                } else {
                    writeObject(marshaller, writer, new JAXBElement(mname, String.class, 
                                                                    m.invoke(elValue)));
                }
            }
        }

        writer.writeEndElement();
        writer.flush();
    } catch (Exception e) {
        throw new Fault(new Message("MARSHAL_ERROR", LOG, e.getMessage()), e);
    }
}
 
开发者ID:GeeQuery,项目名称:cxf-plus,代码行数:59,代码来源:JAXBEncoderDecoder.java

示例15: createMarshaller

import org.apache.cxf.common.i18n.Message; //导入依赖的package包/类
public Marshaller createMarshaller(Object elValue, MessagePartInfo part) {
    Class<?> cls = null;
    if (part != null) {
        cls = part.getTypeClass();
    }

    if (cls == null) {
        cls = null != elValue ? elValue.getClass() : null;
    }

    if (cls != null && cls.isArray() && elValue instanceof Collection) {
        Collection<?> col = (Collection<?>)elValue;
        elValue = col.toArray((Object[])Array.newInstance(cls.getComponentType(), col.size()));
    }
    Marshaller marshaller;
    try {
        
        marshaller = context.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
        marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.FALSE);
        marshaller.setListener(databinding.getMarshallerListener());
        if (databinding.getValidationEventHandler() != null) {
            marshaller.setEventHandler(databinding.getValidationEventHandler());
        }
        
        final Map<String, String> nspref = databinding.getDeclaredNamespaceMappings();
        if (nspref != null) {
            JAXBUtils.setNamespaceWrapper(nspref, marshaller);
        }
        if (databinding.getMarshallerProperties() != null) {
            for (Map.Entry<String, Object> propEntry 
                : databinding.getMarshallerProperties().entrySet()) {
                try {
                    marshaller.setProperty(propEntry.getKey(), propEntry.getValue());
                } catch (PropertyException pe) {
                    LOG.log(Level.INFO, "PropertyException setting Marshaller properties", pe);
                }
            }
        }
        
        marshaller.setSchema(schema);
        AttachmentMarshaller atmarsh = getAttachmentMarshaller();
        marshaller.setAttachmentMarshaller(atmarsh);
        
        if (schema != null
            && atmarsh instanceof JAXBAttachmentMarshaller) {
            //we need a special even handler for XOP attachments 
            marshaller.setEventHandler(new MtomValidationHandler(marshaller.getEventHandler(),
                                                        (JAXBAttachmentMarshaller)atmarsh));
        }
    } catch (JAXBException ex) {
        if (ex instanceof javax.xml.bind.MarshalException) {
            javax.xml.bind.MarshalException marshalEx = (javax.xml.bind.MarshalException)ex;
            Message faultMessage = new Message("MARSHAL_ERROR", LOG, marshalEx.getLinkedException()
                .getMessage());
            throw new Fault(faultMessage, ex);
        } else {
            throw new Fault(new Message("MARSHAL_ERROR", LOG, ex.getMessage()), ex);
        }
    }
    return marshaller;
}
 
开发者ID:GeeQuery,项目名称:cxf-plus,代码行数:64,代码来源:DataWriterImpl.java


注:本文中的org.apache.cxf.common.i18n.Message类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。