如何在Camel中获取自定义组件中的uri参数?

qhhrdooz  于 2022-11-07  发布在  Apache
关注(0)|答案(1)|浏览(129)

如果我想在apache-camel中有一个ftp自定义组件,如何将ftp uri参数设置为ftpConfiguration?我尝试使用Uri param注解来获取uri参数,但是失败了。有人知道吗?下面是我的示例代码:

public class FtpConfigurationExt extends FtpConfiguration {
    private static final Logger LOGGER = LoggerFactory.getLogger(FtpConfigurationExt.class);

    @UriParam(name = "ftpCommands")
    private String ftpCommands;

    public FtpConfigurationExt() {
        super();
    }

    public FtpConfigurationExt(URI uri) {
        super(uri);
        setProtocol("ftp"); 
    }

    public String getFtpCommands() {
        return ftpCommands;
    }

    public void setFtpCommands(String ftpCommands) {
        LOGGER.info(" FtpConfigurationExt ftpCommands : " + ftpCommands);
        this.ftpCommands = ftpCommands;
    }
}
goucqfw6

goucqfw61#

正如Claus Ibsen所写,您应该将代码更改为:

@UriParams
public class FtpConfigurationExt extends FtpConfiguration {
  // ...
}

相关问题