ISORequestListener 中的并发问题
Concurrency Issue in ISORequestListener
我正在使用 jpos
库进行事务管理(Spring 引导项目)。我正在实施 ISORequestListener
如下。
@Component
public class MyRequestListner implements ISORequestListener, Configurable {
protected String var1;
protected String var2;
@Override
public void setConfiguration(Configuration cfg) throws ConfigurationException {
var1 = cfg.get("var1");
var2 = cfg.get("var2");
}
@Override
public boolean process(ISOSource source, ISOMsg m) {
Context ctx = new Context();
ctx.put("ctx1", var1);
ctx.put("ctx2", var2);
return true;
}
}
在运行 SonarQube
(代码分析工具)上,我得到的错误信息是:
Annotate global variables with "@Autowired", "@Resource", "@Inject", or "@Value", or don’t use on Spring @Component, @Controller, @Service, and @Repository classes.
Spring @Component, @Controller, @Service, and @Repository classes are singletons by default, meaning only one instance of the class is ever instantiated in the application.
Such a class might have a few static members, such as a logger, but all non-static members should be managed by Spring. That is, they should have one of these annotations: @Resource, @Inject, @Autowired or @Value.
这是否会导致任何并发问题(或线程问题)或由 jpos
内部处理?如果真的导致问题,正确的实施方式可能是什么?
如果您 运行 在其自己的 Q2 micro-kernel 内使用 jPOS,那不是问题。如果不是这样,恐怕你主要是靠自己。 运行 Q2 内部非常简单,它是一行代码:new Q2().start();
,您可以从任何其他框架 运行,然后让 Q2 配置您的 jPOS 组件。
我正在使用 jpos
库进行事务管理(Spring 引导项目)。我正在实施 ISORequestListener
如下。
@Component
public class MyRequestListner implements ISORequestListener, Configurable {
protected String var1;
protected String var2;
@Override
public void setConfiguration(Configuration cfg) throws ConfigurationException {
var1 = cfg.get("var1");
var2 = cfg.get("var2");
}
@Override
public boolean process(ISOSource source, ISOMsg m) {
Context ctx = new Context();
ctx.put("ctx1", var1);
ctx.put("ctx2", var2);
return true;
}
}
在运行 SonarQube
(代码分析工具)上,我得到的错误信息是:
Annotate global variables with "@Autowired", "@Resource", "@Inject", or "@Value", or don’t use on Spring @Component, @Controller, @Service, and @Repository classes.
Spring @Component, @Controller, @Service, and @Repository classes are singletons by default, meaning only one instance of the class is ever instantiated in the application.
Such a class might have a few static members, such as a logger, but all non-static members should be managed by Spring. That is, they should have one of these annotations: @Resource, @Inject, @Autowired or @Value.
这是否会导致任何并发问题(或线程问题)或由 jpos
内部处理?如果真的导致问题,正确的实施方式可能是什么?
如果您 运行 在其自己的 Q2 micro-kernel 内使用 jPOS,那不是问题。如果不是这样,恐怕你主要是靠自己。 运行 Q2 内部非常简单,它是一行代码:new Q2().start();
,您可以从任何其他框架 运行,然后让 Q2 配置您的 jPOS 组件。