diff --git a/pom.xml b/pom.xml index b8098f2be..4090150c8 100644 --- a/pom.xml +++ b/pom.xml @@ -493,7 +493,7 @@ org.apache.qpid qpid-client - 6.3.0 + 6.3.1 provided diff --git a/src/main/java/io/jboot/aop/injector/JbootrpcMembersInjector.java b/src/main/java/io/jboot/aop/injector/JbootrpcMembersInjector.java index a0ee23e2e..930c8137a 100644 --- a/src/main/java/io/jboot/aop/injector/JbootrpcMembersInjector.java +++ b/src/main/java/io/jboot/aop/injector/JbootrpcMembersInjector.java @@ -30,9 +30,10 @@ public class JbootrpcMembersInjector implements MembersInjector { private static Log log = Log.getLog(JbootrpcMembersInjector.class); + private static JbootrpcConfig config = Jboot.config(JbootrpcConfig.class); + private Field field; - private static JbootrpcConfig config = Jboot.config(JbootrpcConfig.class); public JbootrpcMembersInjector(Field field) { this.field = field; @@ -40,25 +41,26 @@ public JbootrpcMembersInjector(Field field) { @Override public void injectMembers(Object instance) { - Object impl = null; - JbootrpcService jbootrpcService = field.getAnnotation(JbootrpcService.class); - String group = StringUtils.isBlank(jbootrpcService.group()) ? config.getDefaultGroup() : jbootrpcService.group(); - String version = StringUtils.isBlank(jbootrpcService.version()) ? config.getDefaultVersion() : jbootrpcService.version(); - + JbootrpcService annotation = field.getAnnotation(JbootrpcService.class); + + String group = StringUtils.isBlank(annotation.group()) ? config.getDefaultGroup() : annotation.group(); + String version = StringUtils.isBlank(annotation.version()) ? config.getDefaultVersion() : annotation.version(); + + Object implObject = null; try { - impl = Jboot.service(field.getType(), group, version); + implObject = Jboot.service(field.getType(), group, version); } catch (Throwable e) { log.error(e.toString(), e); } - if (impl == null) { + if (implObject == null) { return; } try { field.setAccessible(true); - field.set(instance, impl); + field.set(instance, implObject); } catch (Throwable e) { log.error(e.toString(), e); } diff --git a/src/main/java/io/jboot/web/JbootControllerManager.java b/src/main/java/io/jboot/web/JbootControllerManager.java index f6033d0ad..d1a551c77 100644 --- a/src/main/java/io/jboot/web/JbootControllerManager.java +++ b/src/main/java/io/jboot/web/JbootControllerManager.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at *

- * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -21,9 +21,6 @@ import com.jfinal.core.ControllerFactory; import io.jboot.Jboot; -import java.util.HashMap; -import java.util.Map; - /** * @author Michael Yang 杨福海 (fuhai999@gmail.com) * @version V1.0 @@ -40,20 +37,24 @@ public static JbootControllerManager me() { private JbootControllerManager() { } - private ThreadLocal, Controller>> buffers = new ThreadLocal, Controller>>() { - protected Map, Controller> initialValue() { - return new HashMap, Controller>(); - } - }; +// private ThreadLocal, Controller>> buffers = new ThreadLocal, Controller>>() { +// protected Map, Controller> initialValue() { +// return new HashMap, Controller>(); +// } +// }; +// +// public Controller getController(Class controllerClass) throws InstantiationException, IllegalAccessException { +// Controller ret = buffers.get().get(controllerClass); +// if (ret == null) { +// ret = controllerClass.newInstance(); +// Jboot.injectMembers(ret); +// buffers.get().put(controllerClass, ret); +// } +// return ret; +// } public Controller getController(Class controllerClass) throws InstantiationException, IllegalAccessException { - Controller ret = buffers.get().get(controllerClass); - if (ret == null) { - ret = controllerClass.newInstance(); - Jboot.injectMembers(ret); - buffers.get().put(controllerClass, ret); - } - return ret; + return Jboot.bean(controllerClass); }