We want to connect the people who have knowledge to the people who need it, to bring together people with different perspectives so they can understand each other better, and to empower everyone to share their knowledge.
@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)
Input your email to receive reset password link, or if you remember your password, you can click