48.15. 使用 Java DSL

下一步包含与这个记录类型关联的 DataFormat bindy 类,并提供 Java 软件包名称作为参数。

例如,以下使用类 BindyCsvDataFormat (与 CSV 记录类型关联的类对应),该类使用 com.acme.model 软件包名称来初始化在这个软件包中配置的模型对象。

// Camel 2.15 or older (configure by package name)
DataFormat bindy = new BindyCsvDataFormat("com.acme.model");

 
// Camel 2.16 onwards (configure by class name)
DataFormat bindy = new BindyCsvDataFormat(com.acme.model.MyModel.class);

48.15.1. 设置区域设置

Bindy 支持在 dataformat 上配置区域设置,例如 

// Camel 2.15 or older (configure by package name)
BindyCsvDataFormat bindy = new BindyCsvDataFormat("com.acme.model");
// Camel 2.16 onwards (configure by class name)
BindyCsvDataFormat bindy = new BindyCsvDataFormat(com.acme.model.MyModel.class);

bindy.setLocale("us");

或者使用平台默认区域设置,然后使用 "default" 作为区域设置。请注意,这需要 Camel 2.14/2.13.3/2.12.5。

// Camel 2.15 or older (configure by package name)
BindyCsvDataFormat bindy = new BindyCsvDataFormat("com.acme.model");
// Camel 2.16 onwards (configure by class name)
BindyCsvDataFormat bindy = new BindyCsvDataFormat(com.acme.model.MyModel.class);

bindy.setLocale("default");

对于旧版本的版本,您可以按照如下所示使用 Java 代码来设置它

// Camel 2.15 or older (configure by package name)
BindyCsvDataFormat bindy = new BindyCsvDataFormat("com.acme.model");
// Camel 2.16 onwards (configure by class name)
BindyCsvDataFormat bindy = new BindyCsvDataFormat(com.acme.model.MyModel.class);

bindy.setLocale(Locale.getDefault().getISO3Country());