StackAsk is a community where developers ask questions, share answers and learn from each others real-world experience, so every solved problem helps the next person who runs into it.
@Setter @EzyPrototype @EzyObjectBinding(write = false) @EzyRequestListener(GREET) public class GreetRequestHandler extends ClientRequestHandler implements EzyDataBinding { private String who; @EzyAutoBind private Greeting greeting; @Override protected void execute() throws EzyBadRequestException { responseFactory.newObjectResponse() .command(GREET) .param("message", greeting.greet(who)) .session(session) .execute(); } }
singletonSet
EzySimpleFactoryClass
EzyUserRequestSingletonController
private Map<String, EzyUserRequestHandlerProxy> extractRequestHandlersFromListener() { List<Object> clientRequestHandlers = getClientRequestHandlers(); Map<String, EzyUserRequestHandlerProxy> handlers = new HashMap<>(); for (Object handler : clientRequestHandlers) { Class<?> handleType = handler.getClass(); EzyRequestListener annotation = handleType.getAnnotation(EzyRequestListener.class); String command = EzyRequestListenerAnnotations.getCommand(annotation); handlers.put(command, new EzyUserRequestHandlerProxy((EzyUserRequestHandler) handler)); logger.debug("add command {} and request handler {}", command, handler); } return handlers; } private List<Object> getClientRequestHandlers() { return singletonFactory.getSingletons(EzyRequestListener.class); }
getSingletons
EzyRequestListener
public List getSingletons(Class... annotationClasses) { return this.getSingletons((o) -> { Class[] var2 = annotationClasses; int var3 = annotationClasses.length; for(int var4 = 0; var4 < var3; ++var4) { Class annotationClass = var2[var4]; if (o.getClass().isAnnotationPresent(annotationClass)) { return true; } } return false; }); } public List getSingletons(Predicate filter) { List list = new ArrayList(); Iterator var3 = this.singletonSet.iterator(); while(var3.hasNext()) { Object object = var3.next(); if (filter.test(object)) { list.add(object); } } return list; }
1. Lấy ra danh sách bean có `@EzyRequestListener`. 2. Lấy ra command từ `@EzyRequestListener`. 3. Đưa vào map command và bean handler.
@EzyPrototype
@EzySingleton
@EzyEventHandler
@Service
GreetRequestHandler
who
EzySimpleBeanContext
private void doScanPackages(Set<String> packages) { if (packages.size() > 0) { EzyReflection reflection = EzyPackages.scanPackages(packages); addAllClassesByReflection(reflection); } }
2.2K Point(s)
1.2K Point(s)
313 Point(s)
178 Point(s)
138 Point(s)
Your account is signed in on the device(s) below. Sign out of at least one of them to continue signing in on this device.
Your account is signed in on the device(s) below. Sign out directly on one of those devices, or wait until the sign-in again time shown below.
If you cant access those devices, please contact the administrator to sign them out for you.
Input your email to receive reset password link, or if you remember your password, you can click