private static void process(EventTopicSubscriber topicAnnotation, Object obj, Method method) { // Check args String topic = topicAnnotation.topic(); if (topic == null) { throw new IllegalArgumentException( "Topic cannot be null for EventTopicSubscriber annotation"); } // Get event service Class<? extends EventService> eventServiceClass = topicAnnotation.autoCreateEventServiceClass(); String eventServiceName = topicAnnotation.eventServiceName(); EventService eventService = getEventServiceFromAnnotation(eventServiceName, eventServiceClass); // Create proxy and subscribe ProxyTopicSubscriber subscriber = new ProxyTopicSubscriber( obj, method, topicAnnotation.referenceStrength(), eventService, topic); // See Issue #18 // Also note that this post is wrong: // https://eventbus.dev.java.net/servlets/ProjectForumMessageView?messageID=19499&forumID=1834 // Since two WeakReferences are not treated as one. So this always has to be strong and we'll // have to clean up occasionally. eventService.subscribeStrongly(topic, subscriber); }
private static void process(EventSubscriber annotation, Object obj, Method method) { // Check args Class eventClass = annotation.eventClass(); if (eventClass == null) { throw new IllegalArgumentException( "Event class cannot be null for EventSubscriber annotation"); } else if (UseTheClassOfTheAnnotatedMethodsParameter.class.equals(eventClass)) { Class[] params = method.getParameterTypes(); if (params.length < 1) { throw new RuntimeException("Expected annotated method to have one parameter."); } else { eventClass = params[0]; } } // Get event service Class<? extends EventService> eventServiceClass = annotation.autoCreateEventServiceClass(); String eventServiceName = annotation.eventServiceName(); EventService eventService = getEventServiceFromAnnotation(eventServiceName, eventServiceClass); // Create proxy and subscribe // See // https://eventbus.dev.java.net/servlets/ProjectForumMessageView?messageID=19499&forumID=1834 BaseProxySubscriber subscriber = new BaseProxySubscriber( obj, method, annotation.referenceStrength(), eventService, eventClass); if (annotation.exact()) { // See Issue #18 // Also note that this post is wrong: // https://eventbus.dev.java.net/servlets/ProjectForumMessageView?messageID=19499&forumID=1834 // Since two WeakReferences are not treated as one. So this always has to be strong and we'll // have to clean up occasionally. eventService.subscribeExactlyStrongly(eventClass, subscriber); } else { // See Issue #18 // Also note that this post is wrong: // https://eventbus.dev.java.net/servlets/ProjectForumMessageView?messageID=19499&forumID=1834 // Since two WeakReferences are not treated as one. So this always has to be strong and we'll // have to clean up occasionally. eventService.subscribeStrongly(eventClass, subscriber); } }