====IocBy
@IocBy(type = ComboIocProvider.class, init={"jedisBean"}, args = {
"*anno", "club.zhcs", "com.syl", "*tx", "*js", "ioc", "*async", "128", "*quartz", "quartz", "*jedis"
})
====IocBean
@IocBean(create="init")
public class JedisBean {
Log log = Logs.get();
@Inject
private OrderService orderService;
public void init() {
log.info("jedis======订阅进入了");
RedisInterceptor.jedis().subscribe(new JedisPubSub() {
@Override
public void onMessage(String channel, String message) {
if (Strings.equals(channel, Constant.PAY_RESULT_PUB_CHANEL) && Strings.isNotBlank(message)) {
Message m = Json.fromJson(Message.class, message);
try {
orderService.dealPayResult(m.getContent());
} catch (Exception e) {
e.printStackTrace();
}
}
}
}, Constant.PAY_RESULT_PUB_CHANEL);
}
}
=======错误信息
02-05 18:46:30.656 DEBUG - [LoggingMethodInterceptor.localhost-startStop-1] [afterInvoke] Obj = [com.syl.platform.customer.module.JedisBean$$NUTZAOP] , Return = null , Method = public void com.syl.platform.customer.module.JedisBean.init() , args = []
02-05 18:46:30.656 DEBUG - [ScopeContext.localhost-startStop-1] Remove object 'jedisBean' from [app]
02-05 18:46:30.661 ERROR - [NutLoading.localhost-startStop-1] Error happend during start serivce!
org.nutz.ioc.IocException: IocBean[jedisBean] throw Exception when creating
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:149)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:210)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:239)
at org.nutz.mvc.impl.NutLoading.createIoc(NutLoading.java:389)
at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:103)
at org.nutz.mvc.ActionHandler.<init>(ActionHandler.java:19)
at org.nutz.mvc.NutFilter._init(NutFilter.java:91)
at org.nutz.mvc.NutFilter.init(NutFilter.java:69)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:285)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:266)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4590)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5233)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
at club.zhcs.titans.nutz.interceptor.UserAgentInterceptor.filter(UserAgentInterceptor.java:37)
at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:60)
at org.nutz.aop.interceptor.LoggingMethodInterceptor.filter(LoggingMethodInterceptor.java:48)
at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:60)
at com.syl.platform.customer.module.JedisBean$$NUTZAOP.init(JedisBean.java:1)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.nutz.ioc.trigger.MethodEventTrigger.trigger(MethodEventTrigger.java:18)
at org.nutz.ioc.weaver.DefaultWeaver.onCreate(DefaultWeaver.java:72)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:138)
... 19 more
10 回复
@IocBean(name = "uaDebug")
public class UserAgentInterceptor implements MethodInterceptor {
Log log = Logs.getLog(UserAgentInterceptor.class);
/*
* (non-Javadoc)
*
* @see org.nutz.aop.MethodInterceptor#filter(org.nutz.aop.InterceptorChain)
*/
@Override
public void filter(InterceptorChain chain) throws Throwable {
UserAgent ua = new UserAgent(Mvcs.getReq().getHeader("user-agent"));
String uaInfo = "ip地址: " + Mvcs.getReq().getRemoteAddr() + " userAgent信息:" + Json.toJson(ua);
log.debug(uaInfo);
chain.doChain();
}
}
添加回复
请先登陆