/** * Returns all subscribers for the given listener grouped by the type of event they subscribe to. */ private Multimap<Class<?>, Subscriber> findAllSubscribers(Object listener) { Multimap<Class<?>, Subscriber> methodsInListener = HashMultimap.create(); Class<?> clazz = listener.getClass(); for (Method method : getAnnotatedMethods(clazz)) { Class<?>[] parameterTypes = method.getParameterTypes(); Class<?> eventType = parameterTypes[0]; methodsInListener.put(eventType, Subscriber.create(bus, listener, method)); } return methodsInListener; }
/** * * 新增方法,sessionId为用户id * * @param anId * @param anEvent * @return * @throws PushletException */ public static Session create(String anId, Event anEvent) throws PushletException { Session session; try { session = (Session) Config.getClass(SESSION_CLASS, "nl.justobjects.pushlet.core.Session").newInstance(); } catch (Throwable t) { throw new PushletException("Cannot instantiate Session from config", t); } // Init session session.id = anEvent.getField("id"); // sessionId为有意义的用户id</span><span> session.controller = Controller.create(session); session.subscriber = Subscriber.create(session); return session; }