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


Java OMException类代码示例

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


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

示例1: getBuilder

import org.apache.axiom.om.OMException; //导入依赖的package包/类
/**
 * Creates an OMBuilder for a plain XML message.
 *
 * @param inStream   InputStream for a XML message
 * @param charSetEnc Character set encoding to be used
 * @return Handler to a OMBuilder implementation instance
 * @throws javax.xml.stream.XMLStreamException
 */
public static StAXBuilder getBuilder(InputStream inStream, String charSetEnc) throws XMLStreamException {
    XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(inStream, charSetEnc);
    try {
        return new StAXSOAPModelBuilder(xmlReader);
    } catch (OMException e) {
        log.info("OMException in getSOAPBuilder", e);
        try {
            log.info("Remaining input stream :[" +
                    new String(IOUtils.getStreamAsByteArray(inStream), charSetEnc) + "]");
        } catch (IOException e1) {
            // Nothing here?
        }
        throw e;
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-gateway-framework,代码行数:24,代码来源:XMLUtil.java

示例2: getSOAPBuilder

import org.apache.axiom.om.OMException; //导入依赖的package包/类
/**
 * Creates an OMBuilder for a SOAP message. Default character set encording is used.
 *
 * @param inStream InputStream for a SOAP message
 * @return Handler to a OMBuilder implementation instance
 * @throws javax.xml.stream.XMLStreamException
 */
public static StAXBuilder getSOAPBuilder(InputStream inStream) throws XMLStreamException {
    XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(inStream);
    try {
        return new StAXSOAPModelBuilder(xmlReader);
    } catch (OMException e) {
        log.info("OMException in getSOAPBuilder", e);
        try {
            log.info("Remaining input stream :[" +
                    new String(IOUtils.getStreamAsByteArray(inStream) , "UTF-8") + "]");
        } catch (IOException e1) {
            // Nothing here?
        }
        throw e;
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-gateway-framework,代码行数:23,代码来源:XMLUtil.java

示例3: readElement

import org.apache.axiom.om.OMException; //导入依赖的package包/类
/**
 * Reads the information from the <code>eb:MessageInfo</code> element and stores it in the given implementation of
 * {@link MessageUnit}.
 * <p>Because the information read from the <code>eb:MessageInfo</code> is not stored in the message unit objects
 * themselves this method does not return an object with the info read from the header element but directly stores
 * the information in the provided message unit object.
 *
 * @param miElement     The {@link OMElement} object representing the <code>MessageInfo</code> element to read the
 *                      information from
 * @param msgUnit       The {@link MessageUnit} where information should be stored in
 */
public static void readElement(final OMElement miElement, final MessageUnit msgUnit) {
    if (miElement == null)
        return;

    try {
        msgUnit.setTimestamp(Utils.fromXMLDateTime(miElement.getFirstChildWithName(Q_TIMESTAMP).getText()));
    } catch (final OMException | ParseException e) {
        msgUnit.setTimestamp(null);
    }

    final OMElement messageId = miElement.getFirstChildWithName(Q_MESSAGEID);
    if (messageId != null && !Utils.isNullOrEmpty(messageId.getText()))
        msgUnit.setMessageId(messageId.getText());
    else
        msgUnit.setMessageId(null);

    final OMElement  refToMsgId = miElement.getFirstChildWithName(Q_REFTO_MESSAGEID);
    if (refToMsgId != null && !Utils.isNullOrEmpty(refToMsgId.getText()))
        msgUnit.setRefToMessageId(refToMsgId.getText());
}
 
开发者ID:holodeck-b2b,项目名称:Holodeck-B2B,代码行数:32,代码来源:MessageInfoElement.java

示例4: getJSONString

import org.apache.axiom.om.OMException; //导入依赖的package包/类
protected String getJSONString() {
    if (isRead) {
        return jsonString;
    } else {
        try {
            BufferedReader br = new BufferedReader(jsonReader);
            StringBuilder sb = new StringBuilder(512);
            char[] tempBuf = new char[512];
            int readLen;

            while((readLen = br.read(tempBuf)) != -1) {
                sb.append(tempBuf, 0, readLen);
            }
            jsonString = sb.toString();
        } catch (IOException e) {
            throw new OMException();
        }
        isRead = true;
        return jsonString;
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:22,代码来源:AbstractJSONDataSource.java

示例5: getXMLBytes

import org.apache.axiom.om.OMException; //导入依赖的package包/类
public byte[] getXMLBytes(String encoding) throws UnsupportedEncodingException {
    try {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        // Exposes getOutputStream, which allows faster writes.
        XMLStreamWriterWithOS writer = new XMLStreamWriterWithOS(baos, encoding);

        // Write the business object to the writer
        serialize(writer);

        // Flush the writer
        writer.flush();
        writer.close();
        return baos.toByteArray();
    } catch (XMLStreamException e) {
        throw new OMException(e);
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:19,代码来源:JAXBDataSource.java

示例6: getAttachmentAsByteArray

import org.apache.axiom.om.OMException; //导入依赖的package包/类
public final byte[] getAttachmentAsByteArray(String cid) {
    if (log.isDebugEnabled()) {
        log.debug("Attempting to retrieve attachment [" + cid + "] as a byte[]");
    }
    DataHandler dh = getAttachmentAsDataHandler(cid);
    if (dh != null) {
        try {
            return convert(dh);
        } catch (IOException ioe) {
            if (log.isDebugEnabled()) {
                log.debug("Exception occurred while getting the byte[] " + ioe);
            }
            throw new OMException(ioe);
        }
    }
    if (log.isDebugEnabled()) {
        log.debug("returning null byte[]");
    }
    return null;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:21,代码来源:AbstractJAXBAttachmentUnmarshaller.java

示例7: getAttachmentAsDataHandler

import org.apache.axiom.om.OMException; //导入依赖的package包/类
public final DataHandler getAttachmentAsDataHandler(String cid) {
    if (log.isDebugEnabled()) {
        log.debug("Attempting to retrieve attachment [" + cid + "] as a DataHandler");
    }

    DataHandler dh = getDataHandler(cid);
    if (dh != null) {
        return dh;
    } else {
        String cid2 = getNewCID(cid);
        if (log.isDebugEnabled()) {
            log.debug("A dataHandler was not found for [" + cid + "] trying [" + cid2 + "]");
        }
        dh = getDataHandler(cid2);
        if (dh != null) {
            return dh;
        }
    }
    // No Data Handler found
    throw new OMException(Messages.getMessage("noDataHandler", cid));
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:22,代码来源:AbstractJAXBAttachmentUnmarshaller.java

示例8: getBuilder

import org.apache.axiom.om.OMException; //导入依赖的package包/类
/**
 * Creates an OMBuilder for a plain XML message.
 *
 * @param inStream   InputStream for a XML message
 * @param charSetEnc Character set encoding to be used
 * @return Handler to a OMBuilder implementation instance
 * @throws XMLStreamException
 */
public static StAXBuilder getBuilder(InputStream inStream, String charSetEnc)
        throws XMLStreamException {
    XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(inStream, charSetEnc);
    try {
        return new StAXSOAPModelBuilder(xmlReader);
    } catch (OMException e) {
        log.info("OMException in getSOAPBuilder", e);
        try {
            log.info("Remaining input stream :[" +
                     new String(IOUtils.getStreamAsByteArray(inStream), charSetEnc) + "]");
        } catch (IOException e1) {
            // Nothing here?
        }
        throw e;
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:25,代码来源:BuilderUtil.java

示例9: getSOAPBuilder

import org.apache.axiom.om.OMException; //导入依赖的package包/类
/**
 * Creates an OMBuilder for a SOAP message. Default character set encording is used.
 *
 * @param inStream InputStream for a SOAP message
 * @return Handler to a OMBuilder implementation instance
 * @throws XMLStreamException
 */
public static StAXBuilder getSOAPBuilder(InputStream inStream) throws XMLStreamException {
    XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(inStream);
    try {
        return new StAXSOAPModelBuilder(xmlReader);
    } catch (OMException e) {
        log.info("OMException in getSOAPBuilder", e);
        try {
            log.info("Remaining input stream :[" +
                     new String(IOUtils.getStreamAsByteArray(inStream)) + "]");
        } catch (IOException e1) {
            // Nothing here?
        }
        throw e;
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:23,代码来源:BuilderUtil.java

示例10: getRootCause

import org.apache.axiom.om.OMException; //导入依赖的package包/类
/**
 * This method searches the causes of the specified throwable until it finds one that is
 * acceptable as a "root" cause.
 * <p/>
 * Example: If t is an AxisFault, the code traverses to the next cause.
 *
 * @param t Throwable
 * @return Throwable root cause
 */
private static Throwable getRootCause(Throwable t) {
    while (t != null) {
        Throwable nextCause = null;
        if (t instanceof InvocationTargetException ||
                t instanceof OMException ||
                t instanceof AxisFault) {
            // Skip over this cause
            nextCause = getCause(t);
            if (nextCause == null) {
                logRootCause(t);
                return t;
            }
            t = nextCause;
        } else {
            // This is the root cause
            logRootCause(t);
            return t;
        }
    }
    logRootCause(t);
    return t;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:32,代码来源:ExceptionFactory.java

示例11: getXMLBytes

import org.apache.axiom.om.OMException; //导入依赖的package包/类
/**
 * Returns a byte[] representing the xml data
 * @param encoding String encoding of InputStream
 * @return byte[]
 * @see getXMLInputStream
 */
public byte[] getXMLBytes(String encoding) throws UnsupportedEncodingException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    OMOutputFormat format = new OMOutputFormat();
    format.setCharSetEncoding(encoding);
    try {
        serialize(baos, format);
    } catch (XMLStreamException e) {
        new OMException(e);
    }
    return baos.toByteArray();
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:18,代码来源:ADBDataSource.java

示例12: marshalByElement

import org.apache.axiom.om.OMException; //导入依赖的package包/类
/**
 * Preferred way to marshal objects.
 * 
 * @param b Object that can be rendered as an element and the element name is known by the
 * Marshaller
 * @param m Marshaller
 * @param writer XMLStreamWriter
 */
private static void marshalByElement(final Object b, final Marshaller m, 
                                     final XMLStreamWriter writer,
                                     final boolean optimize) {
    AccessController.doPrivileged(new PrivilegedAction() {
        public Object run() {
            // Marshalling directly to the output stream is faster than marshalling through the
            // XMLStreamWriter. 
            // Take advantage of this optimization if there is an output stream.
            try {
                OutputStream os = (optimize) ? getOutputStream(writer,m) : null;
                if (os != null) {
                    if (DEBUG_ENABLED) {
                        log.debug("Invoking marshalByElement.  " +
                                    "Marshaling to an OutputStream. " +
                                  "Object is "
                                  + getDebugName(b));
                    }
                    writer.flush();
                    m.marshal(b, os);
                } else {
                    if (DEBUG_ENABLED) {
                        log.debug("Invoking marshalByElement.  " +
                                    "Marshaling to an XMLStreamWriter. " +
                                  "Object is "
                                  + getDebugName(b));
                    }
                    m.marshal(b, writer);
                }
            } catch (OMException e) {
                throw e;
            }
            catch (Throwable t) {
                throw new OMException(t);
            }
            return null;
        }});
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:46,代码来源:JAXBDSContext.java

示例13: copy

import org.apache.axiom.om.OMException; //导入依赖的package包/类
public OMDataSourceExt copy() throws OMException {
    
    if (DEBUG_ENABLED) {
        log.debug("Making a copy of the JAXB object");
    }
    return new JAXBDataSource(this.getObject(), 
                              (JAXBDSContext) this.getBusinessContext());
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:9,代码来源:JAXBBlockImpl.java

示例14: copy

import org.apache.axiom.om.OMException; //导入依赖的package包/类
public OMDataSourceExt copy() throws OMException {
    // TODO: This is a default implementation.  Much
    // more refactoring needs to occur to account for attachments.
    try {
        String encoding = "utf-8"; // Choose a common encoding
        byte[] bytes = this.getXMLBytes(encoding);
        return new ByteArrayDataSource(bytes, encoding);
    } catch (UnsupportedEncodingException e) {
        throw new OMException(e);
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:12,代码来源:BlockImpl.java

示例15: convertToOMElement

import org.apache.axiom.om.OMException; //导入依赖的package包/类
/**
 * Convert servicexmlStream to OMElement
 *
 * @param servicexmlStream InputStream contain xml content
 * @return OMElement format of the xml content
 * @throws XMLStreamException
 */

public static OMElement convertToOMElement(InputStream servicexmlStream)
        throws XMLStreamException, OMException{
    OMElement element = null;

    element = OMXMLBuilderFactory.createOMBuilder(servicexmlStream).getDocumentElement();
    element.build();
    return element;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:17,代码来源:DataRetrievalUtil.java


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