Search in sources :

Example 36 with Converter

use of org.apache.camel.Converter in project camel by apache.

the class CxfConverter method soapMessageToString.

@Converter
public static String soapMessageToString(final SOAPMessage soapMessage, Exchange exchange) throws SOAPException, IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    soapMessage.writeTo(baos);
    return baos.toString(IOHelper.getCharsetName(exchange));
}
Also used : ByteArrayOutputStream(java.io.ByteArrayOutputStream) FallbackConverter(org.apache.camel.FallbackConverter) Converter(org.apache.camel.Converter) TypeConverter(org.apache.camel.TypeConverter)

Example 37 with Converter

use of org.apache.camel.Converter in project camel by apache.

the class CxfConverter method soapMessageToInputStream.

@Converter
public static InputStream soapMessageToInputStream(final SOAPMessage soapMessage, Exchange exchange) throws SOAPException, IOException {
    CachedOutputStream cos = new CachedOutputStream(exchange);
    soapMessage.writeTo(cos);
    InputStream in = cos.getInputStream();
    return in;
}
Also used : InputStream(java.io.InputStream) CachedOutputStream(org.apache.camel.converter.stream.CachedOutputStream) FallbackConverter(org.apache.camel.FallbackConverter) Converter(org.apache.camel.Converter) TypeConverter(org.apache.camel.TypeConverter)

Example 38 with Converter

use of org.apache.camel.Converter in project camel by apache.

the class MinaConverter method toByteBuffer.

@Converter
public static ByteBuffer toByteBuffer(byte[] bytes) {
    ByteBuffer buf = ByteBuffer.allocate(bytes.length);
    buf.put(bytes);
    return buf;
}
Also used : ByteBuffer(org.apache.mina.common.ByteBuffer) Converter(org.apache.camel.Converter)

Example 39 with Converter

use of org.apache.camel.Converter in project camel by apache.

the class Mina2Converter method toIoBuffer.

@Converter
public static IoBuffer toIoBuffer(byte[] bytes) {
    IoBuffer buf = IoBuffer.allocate(bytes.length);
    buf.put(bytes);
    return buf;
}
Also used : IoBuffer(org.apache.mina.core.buffer.IoBuffer) Converter(org.apache.camel.Converter)

Example 40 with Converter

use of org.apache.camel.Converter in project camel by apache.

the class DnsRecordConverter method toRecord.

/**
     * @param ip, like "192.168.1.1"
     * @return the complete DNS record for that IP.
     */
@Converter
public static Record toRecord(String ip) throws IOException {
    Resolver res = new ExtendedResolver();
    Name name = ReverseMap.fromAddress(ip);
    int type = Type.PTR;
    int dclass = DClass.IN;
    Record rec = Record.newRecord(name, type, dclass);
    Message query = Message.newQuery(rec);
    Message response = res.send(query);
    Record[] answers = response.getSectionArray(Section.ANSWER);
    if (answers.length == 0) {
        return null;
    } else {
        return answers[0];
    }
}
Also used : ExtendedResolver(org.xbill.DNS.ExtendedResolver) ExtendedResolver(org.xbill.DNS.ExtendedResolver) Resolver(org.xbill.DNS.Resolver) Message(org.xbill.DNS.Message) Record(org.xbill.DNS.Record) Name(org.xbill.DNS.Name) Converter(org.apache.camel.Converter)

Aggregations

Converter (org.apache.camel.Converter)71 TypeConverter (org.apache.camel.TypeConverter)11 FallbackConverter (org.apache.camel.FallbackConverter)10 InputStream (java.io.InputStream)8 ByteBuffer (java.nio.ByteBuffer)7 IOConverter (org.apache.camel.converter.IOConverter)7 InputSource (org.xml.sax.InputSource)6 FileNotFoundException (java.io.FileNotFoundException)5 IOException (java.io.IOException)5 List (java.util.List)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 StringReader (java.io.StringReader)4 ArrayList (java.util.ArrayList)4 FileInputStream (java.io.FileInputStream)3 XMLStreamReader (javax.xml.stream.XMLStreamReader)3 SAXSource (javax.xml.transform.sax.SAXSource)3 MultiSearchRequest (org.elasticsearch.action.search.MultiSearchRequest)3 SearchRequest (org.elasticsearch.action.search.SearchRequest)3 Document (org.w3c.dom.Document)3 Element (org.w3c.dom.Element)3