Java 类org.apache.camel.converter.ObjectConverter 实例源码

项目:Camel    文件:CorePackageScanClassResolver.java   
public CorePackageScanClassResolver() {
    converters.add(ObjectConverter.class);
    converters.add(CollectionConverter.class);
    converters.add(DateTimeConverter.class);
    converters.add(SQLConverter.class);
    converters.add(IOConverter.class);
    converters.add(NIOConverter.class);
    converters.add(StaxConverter.class);
    converters.add(DomConverter.class);
    converters.add(StreamSourceConverter.class);
    converters.add(XmlConverter.class);
    converters.add(CamelConverter.class);
    converters.add(StreamCacheConverter.class);
    converters.add(TimePatternConverter.class);
    converters.add(FutureTypeConverter.class);
    converters.add(BeanConverter.class);
    converters.add(GenericFileConverter.class);
    converters.add(DurationConverter.class);
}
项目:Camel    文件:MailBinding.java   
private void setRecipientFromCamelMessage(MimeMessage mimeMessage, MailConfiguration configuration, Exchange exchange) throws MessagingException, IOException {
    for (Map.Entry<String, Object> entry : exchange.getIn().getHeaders().entrySet()) {
        String headerName = entry.getKey();
        Object headerValue = entry.getValue();
        if (headerValue != null && isRecipientHeader(headerName)) {
            // special handling of recipients
            if (ObjectConverter.isCollection(headerValue)) {
                Iterator<?> iter = ObjectHelper.createIterator(headerValue);
                while (iter.hasNext()) {
                    Object recipient = iter.next();
                    appendRecipientToMimeMessage(mimeMessage, configuration, exchange, headerName, asString(exchange, recipient));
                }
            } else {
                appendRecipientToMimeMessage(mimeMessage, configuration, exchange, headerName, asString(exchange, headerValue));
            }
        }
    }
}
项目:camel-agent    文件:MailBinding.java   
private void setRecipientFromCamelMessage(MimeMessage mimeMessage, MailConfiguration configuration, Exchange exchange) throws MessagingException, IOException {
    for (Map.Entry<String, Object> entry : exchange.getIn().getHeaders().entrySet()) {
        String headerName = entry.getKey();
        Object headerValue = entry.getValue();
        if (headerValue != null && isRecipientHeader(headerName)) {
            // special handling of recipients
            if (ObjectConverter.isCollection(headerValue)) {
                Iterator<?> iter = ObjectHelper.createIterator(headerValue);
                while (iter.hasNext()) {
                    Object recipient = iter.next();
                    appendRecipientToMimeMessage(mimeMessage, configuration, exchange, headerName, asString(exchange, recipient));
                }
            } else {
                appendRecipientToMimeMessage(mimeMessage, configuration, exchange, headerName, asString(exchange, headerValue));
            }
        }
    }
}
项目:Camel    文件:MailBinding.java   
/**
 * Appends the Mail headers from the Camel {@link MailMessage}
 */
protected void appendHeadersFromCamelMessage(MimeMessage mimeMessage, MailConfiguration configuration, Exchange exchange)
    throws MessagingException, IOException {

    for (Map.Entry<String, Object> entry : exchange.getIn().getHeaders().entrySet()) {
        String headerName = entry.getKey();
        Object headerValue = entry.getValue();
        if (headerValue != null) {
            if (headerFilterStrategy != null
                    && !headerFilterStrategy.applyFilterToCamelHeaders(headerName, headerValue, exchange)) {
                if (headerName.equalsIgnoreCase("subject")) {
                    mimeMessage.setSubject(asString(exchange, headerValue), determineCharSet(configuration, exchange));
                    continue;
                }
                if (headerName.equalsIgnoreCase("from")) {
                    mimeMessage.setFrom(asEncodedInternetAddress(asString(exchange, headerValue), determineCharSet(configuration, exchange)));
                    continue;
                }
                if (headerName.equalsIgnoreCase("sender")) {
                    mimeMessage.setSender(asEncodedInternetAddress(asString(exchange, headerValue), determineCharSet(configuration, exchange)));
                    continue;
                }
                if (isRecipientHeader(headerName)) {
                    // skip any recipients as they are handled specially
                    continue;
                }

                // alternative body should also be skipped
                if (headerName.equalsIgnoreCase(configuration.getAlternativeBodyHeader())) {
                    // skip alternative body
                    continue;
                }

                // Mail messages can repeat the same header...
                if (ObjectConverter.isCollection(headerValue)) {
                    Iterator<?> iter = ObjectHelper.createIterator(headerValue);
                    while (iter.hasNext()) {
                        Object value = iter.next();
                        mimeMessage.addHeader(headerName, asString(exchange, value));
                    }
                } else {
                    mimeMessage.setHeader(headerName, asString(exchange, headerValue));
                }
            }
        }
    }
}
项目:Camel    文件:TypeConverter.java   
@Converter
public static char toChar(GString value) {
    return ObjectConverter.toChar(value.toString());
}
项目:Camel    文件:TypeConverter.java   
@Converter
public static Integer toInteger(GString value) {
    return ObjectConverter.toInteger(value.toString());
}
项目:Camel    文件:TypeConverter.java   
@Converter
public static Long toLong(GString value) {
    return ObjectConverter.toLong(value.toString());
}
项目:Camel    文件:TypeConverter.java   
@Converter
public static Float toFloat(GString value) {
    return ObjectConverter.toFloat(value.toString());
}
项目:Camel    文件:TypeConverter.java   
@Converter
public static Double toDouble(GString value) {
    return ObjectConverter.toDouble(value.toString());
}
项目:Camel    文件:TypeConverter.java   
@Converter
public static Boolean toBoolean(GString value) {
    return ObjectConverter.toBoolean(value.toString());
}
项目:camel-agent    文件:MailBinding.java   
/**
 * Appends the Mail headers from the Camel {@link MailMessage}
 */
protected void appendHeadersFromCamelMessage(MimeMessage mimeMessage, MailConfiguration configuration, Exchange exchange)
    throws MessagingException, IOException {

    for (Map.Entry<String, Object> entry : exchange.getIn().getHeaders().entrySet()) {
        String headerName = entry.getKey();
        Object headerValue = entry.getValue();
        if (headerValue != null) {
            if (headerFilterStrategy != null
                    && !headerFilterStrategy.applyFilterToCamelHeaders(headerName, headerValue, exchange)) {
                if (headerName.equalsIgnoreCase("subject")) {
                    mimeMessage.setSubject(asString(exchange, headerValue), determineCharSet(configuration, exchange));
                    continue;
                }
                if (headerName.equalsIgnoreCase("from")) {
                    mimeMessage.setFrom(asEncodedInternetAddress(asString(exchange, headerValue), determineCharSet(configuration, exchange)));
                    continue;
                }
                if (headerName.equalsIgnoreCase("sender")) {
                    mimeMessage.setSender(asEncodedInternetAddress(asString(exchange, headerValue), determineCharSet(configuration, exchange)));
                    continue;
                }
                if (isRecipientHeader(headerName)) {
                    // skip any recipients as they are handled specially
                    continue;
                }

                // alternative body should also be skipped
                if (headerName.equalsIgnoreCase(configuration.getAlternativeBodyHeader())) {
                    // skip alternative body
                    continue;
                }

                // Mail messages can repeat the same header...
                if (ObjectConverter.isCollection(headerValue)) {
                    Iterator<?> iter = ObjectHelper.createIterator(headerValue);
                    while (iter.hasNext()) {
                        Object value = iter.next();
                        mimeMessage.addHeader(headerName, asString(exchange, value));
                    }
                } else {
                    mimeMessage.setHeader(headerName, asString(exchange, headerValue));
                }
            }
        }
    }
}