我需要拿到jedisAgent对象,不知道怎么取
public class AttackProcessor extends AbstractProcessor {
private static final Log log = Logs.get();
protected JedisAgent jedisAgent;
public void init(NutConfig config, ActionInfo ai) throws Throwable {
jedisAgent = config.getIoc().get(JedisAgent.class);
}
@Override
public void process(ActionContext ac) throws Throwable {
String userAgent = Toolkit.userAgent();
if(userAgent.contains("baidu")){
return;
}
String ipStr = Toolkit.ip();
if(StringUtils.isNotBlank(ipStr) && !ipStr.equalsIgnoreCase("-")){
List<String> ips = Splitter.on(",").splitToList(ipStr);
String ip = ips.get(ips.size()-1);
try (Jedis jedis = jedisAgent.getResource()) {
if(jedis.exists(ip)){
long count = jedis.incr(ip);
if(count>=5){
log.infof("ip=%s",ip);
return;
}
}else{
jedis.setex(ip, 86400,"1");
}
}
}
doNext(ac);
}
}
下面是错误日志
12:50:01.464 ERROR (NutLoading.java:125) load - Error happend during start serivce!
org.nutz.ioc.IocException: IocBean[jedisAgent] throw Exception when creating
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:152) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:240) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:270) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:160) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
at net.wendal.nutzbook.yvr.processor.AttackProcessor.init(AttackProcessor.java:29) ~[nutzcn-yvr-3.1.0.jar:3.1.0]
at org.nutz.mvc.impl.NutActionChainMaker.eval(NutActionChainMaker.java:38) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
at org.nutz.mvc.impl.UrlMappingImpl.add(UrlMappingImpl.java:54) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
at org.nutz.plugins.apidoc.ApidocUrlMapping.add(ApidocUrlMapping.java:92) ~[nutzcn-core-3.1.0.jar:3.1.0]
at org.nutz.mvc.impl.NutLoading.evalUrlMapping(NutLoading.java:205) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:108) [nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
at org.nutz.plugins.hotplug.Hotplug.load(Hotplug.java:117) [nutzcn-core-3.1.0.jar:3.1.0]
at org.nutz.mvc.ActionHandler.<init>(ActionHandler.java:19) [nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
at org.nutz.mvc.NutFilter._init(NutFilter.java:91) [nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
at org.nutz.mvc.NutFilter.init(NutFilter.java:69) [nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:139) [jetty-servlet-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:741) [jetty-servlet-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:348) [jetty-servlet-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1515) [jetty-webapp-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.maven.plugin.JettyWebAppContext.startWebapp(JettyWebAppContext.java:360) [jetty-maven-plugin-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1477) [jetty-webapp-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:785) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:261) [jetty-servlet-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:545) [jetty-webapp-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:428) [jetty-maven-plugin-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:115) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:167) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]