首页 \ 问答 \ Spring批处理:有条件地执行步骤(Spring batch: conditional execution of steps)

Spring批处理:有条件地执行步骤(Spring batch: conditional execution of steps)

我正在研究包含多个步骤(超过10个)的Spring Batch作业。

我有一个属性文件,指出是否应该执行一个步骤。

例如,在我的属性文件中:EXECUTE_STEP1 = 0 EXECUTE_STEP2 = 1

表示应执行第2步,而不应执行第1步。

我怎样才能在我的Spring Batch配置中翻译这个? 可能吗?

感谢您的回答。


I am working on a Spring Batch job which contains several steps (more than 10).

I have a properties file which indicates if one step should be executed or not.

For instance, in my properties file : EXECUTE_STEP1=0 EXECUTE_STEP2=1

indicates that step2 should be executed and step1 should not.

How can I translate this in my Spring Batch configuration? Is it possible?

Thanks for your answers.


原文:https://stackoverflow.com/questions/37745553
更新时间:2022-09-04 11:09

最满意答案

有两个常用选项。

你可以把this变成象that的对象或者self然后调用它。

render: function () {
    var that = this;
    $('#slider').slider({
        min:0,
        max:100,
        slide: function(event, ui) {
           //HOW DO I CALL THE custom_function from here????
           that.custom_function();
        },

    });
},

或者你可以绑定该函数的上下文。

render: function () {
    $('#slider').slider({
        min:0,
        max:100,
        slide: (function(event, ui) {
           //HOW DO I CALL THE custom_function from here????
           this.custom_function();
        }).bind(this),

    });
}, 

Function.prototype.bind仅$.proxy于ES5,所以使用_.bind$.proxy作为跨浏览器支持


There are two common options.

You can either this into an object like that or self then call it.

render: function () {
    var that = this;
    $('#slider').slider({
        min:0,
        max:100,
        slide: function(event, ui) {
           //HOW DO I CALL THE custom_function from here????
           that.custom_function();
        },

    });
},

Or you can bind the context of the function.

render: function () {
    $('#slider').slider({
        min:0,
        max:100,
        slide: (function(event, ui) {
           //HOW DO I CALL THE custom_function from here????
           this.custom_function();
        }).bind(this),

    });
}, 

Function.prototype.bind is ES5 only so use _.bind or $.proxy for cross browser support

相关问答

更多
  • Backbone文档有一个关于绑定“this”的有用部分。 基本上, Underscore提供了一些非常有用的函数, _. bind和_.bindAll ,它们可以帮助您更轻松地管理这个上下文。 ... initialize: function() { _.bindAll(this, 'countDownOnce' //, and whatever other functions you want bound) }), ... 这将确保无论从哪个上下文调用它,countDownOnce中的'thi ...
  • TLDR / CLIFFS: 下面奇怪的小行用于确定天气,错误回调是由模型级别的验证失败,或者来自fetch,save或destroy方法(全部调用Backbone.sync)的失败的AJAX调用触发的。 如果失败来自验证,则它不会更改resp变量,因为resp应该已经包含validate返回的有用信息(例如错误数组或有关错误的字符串)。 如果失败来自错误的AJAX请求,则XHR对象将存储到resp中,因为XHR是可用信息量最大的项目。 不幸的是,XHR作为模型传递给了这个函数,Backbone文档没有指出 ...
  • Backbone将许多下划线方法扩展到Collection类中,因此您可以摆脱其中的一些内容。 真的,你可能想在集合本身作为一种方法来实现这个,然后我可能会使用一个很好的老式for循环看看那些键,特别是如果我想要突破它。 // in Backbone.Collection.extend search: function( query, callback ){ var pattern = new RegExp( $.trim( query ).replace( / /gi, '|' ), "i"); ...
  • 虽然this.model.get("obj1").myAttribute1是好的,这是一个有点问题,因为那么你可能会试图做同样的事情集合,即 this.model.get("obj1").myAttribute1 = true; 但是,如果这样做,您将无法获得myAttribute1的Backbone模型的优点,例如更改事件或验证。 更好的解决方案是永远不会在您的模型中嵌套POJSO(“简单的旧对象”),而是嵌套自定义模型类。 所以看起来像这样: var Obj = Backbone.Model.exte ...
  • 有两个常用选项。 你可以把this变成象that的对象或者self然后调用它。 render: function () { var that = this; $('#slider').slider({ min:0, max:100, slide: function(event, ui) { //HOW DO I CALL THE custom_function from here???? that.c ...
  • Backbone.js,underscore.js和jQuery(它们都是相互依赖的)是一个实用的抽象层和javascript工具集,允许您组织业务逻辑,模板和模型。 这样做的主要好处是代码可读性(适用于具有多个成员的长期项目/项目),围绕离散部件组织的一般良好实践(例如,保持HTML不受业务逻辑影响),提供时间来处理硬件/项目的有趣部分,而不是重新发明不同的浏览器兼容性问题,以及(在下划线的情况下)一个伟大的工具集,以帮助您管理javascript对象,数组,函数等安全和理智的编程。 基本上,如果您选择不 ...
  • 设置嵌套视图时,必须考虑事件将冒出DOM树并且Backbone处理view.el级别的DOM事件这一事实。 这意味着在您的方案中,如果让事件在层次结构中上升,嵌套节点也将触发父节点中的事件。 有关演示,请参见http://jsfiddle.net/PX2PL/ 一个简单的解决方案是在回调中停止事件传播 var CategoriesOuterView = Backbone.View.extend({ events: { 'click .edit':'edit', ...
  • 好的 我得到了什么问题.....正在发生的事情是,我正在调用JSON对象的Java_Servlet以文本格式而不是JSON返回数据...(但它是一个有效的JSON字符串)...并且在调用ajax方法时我将类型设置为'json',因此它失败了。 感谢所有阅读我的问题并想出解决方案的人。 但我观察到一个奇怪的事情,相同的代码是在生产而不是在我的本地机器上工作??? 有没有人知道为什么它会表现得那样...... ??? 谢谢:)现在我可以睡得好!! Okay I got what was the issue... ...
  • Underscore的has是这样的: 有 _.has(object, key) 对象是否包含给定的键? 与object.hasOwnProperty(key)相同,但使用对hasOwnProperty函数的安全引用,以防它被意外覆盖。 但是你的value不会有toJSON属性,因为toJSON来自原型(参见http://jsfiddle.net/ambiguous/x6577/ )。 您应该使用_(value.toJSON).isFunction()代替: if(_(value.toJSON).isFun ...
  • 您可能需要提及其他解决方案 ,除非事件对象本身在event.stopPropagation()执行.stopPropagation() event.stopPropagation() 。 我不知道通过delegateEvents绑定的事件处理程序是否传递了任何相关的事件对象,但它没有记录在帮助页面AFAIK上。 Your mention of other solutions is probably what you would need to do, except on the event object i ...

相关文章

更多

最新问答

更多
  • 如何在Laravel 5.2中使用paginate与关系?(How to use paginate with relationships in Laravel 5.2?)
  • linux的常用命令干什么用的
  • 由于有四个新控制器,Auth刀片是否有任何变化?(Are there any changes in Auth blades due to four new controllers?)
  • 如何交换返回集中的行?(How to swap rows in a return set?)
  • 在ios 7中的UITableView部分周围绘制边界线(draw borderline around UITableView section in ios 7)
  • 使用Boost.Spirit Qi和Lex时的空白队长(Whitespace skipper when using Boost.Spirit Qi and Lex)
  • Java中的不可变类(Immutable class in Java)
  • WordPress发布查询(WordPress post query)
  • 如何在关系数据库中存储与IPv6兼容的地址(How to store IPv6-compatible address in a relational database)
  • 是否可以检查对象值的条件并返回密钥?(Is it possible to check the condition of a value of an object and JUST return the key?)
  • GEP分段错误LLVM C ++ API(GEP segmentation fault LLVM C++ API)
  • 绑定属性设置器未被调用(Bound Property Setter not getting Called)
  • linux ubuntu14.04版没有那个文件或目录
  • 如何使用JSF EL表达式在param中迭代变量(How to iterate over variable in param using JSF EL expression)
  • 是否有可能在WPF中的一个单独的进程中隔离一些控件?(Is it possible to isolate some controls in a separate process in WPF?)
  • 使用Python 2.7的MSI安装的默认安装目录是什么?(What is the default installation directory with an MSI install of Python 2.7?)
  • 寻求多次出现的表达式(Seeking for more than one occurrence of an expression)
  • ckeditor config.protectedSource不适用于editor.insertHtml上的html元素属性(ckeditor config.protectedSource dont work for html element attributes on editor.insertHtml)
  • linux只知道文件名,不知道在哪个目录,怎么找到文件所在目录
  • Actionscript:检查字符串是否包含域或子域(Actionscript: check if string contains domain or subdomain)
  • 将CouchDB与AJAX一起使用是否安全?(Is it safe to use CouchDB with AJAX?)
  • 懒惰地初始化AutoMapper(Lazily initializing AutoMapper)
  • 使用hasclass为多个div与一个按钮问题(using hasclass for multiple divs with one button Problems)
  • Windows Phone 7:检查资源是否存在(Windows Phone 7: Check If Resource Exists)
  • 无法在新线程中从FREContext调用getActivity()?(Can't call getActivity() from FREContext in a new thread?)
  • 在Alpine上升级到postgres96(/ usr / bin / pg_dump:没有这样的文件或目录)(Upgrade to postgres96 on Alpine (/usr/bin/pg_dump: No such file or directory))
  • 如何按部门显示报告(How to display a report by Department wise)
  • Facebook墙贴在需要访问令牌密钥后无法正常工作(Facebook wall post not working after access token key required)
  • Javascript - 如何在不擦除输入的情况下更改标签的innerText(Javascript - how to change innerText of label while not wiping out the input)
  • WooCommerce / WordPress - 不显示具有特定标题的产品(WooCommerce/WordPress - Products with specific titles are not displayed)