|
@@ -27,6 +27,7 @@ import com.dmdirc.ChannelEventHandler;
|
27
|
27
|
import com.dmdirc.parser.common.CallbackManager;
|
28
|
28
|
import com.dmdirc.parser.common.CallbackNotFoundException;
|
29
|
29
|
import com.dmdirc.parser.common.CallbackObject;
|
|
30
|
+import com.dmdirc.parser.common.ChildImplementations;
|
30
|
31
|
import com.dmdirc.parser.interfaces.Parser;
|
31
|
32
|
import com.dmdirc.parser.interfaces.callbacks.CallbackInterface;
|
32
|
33
|
import com.dmdirc.parser.interfaces.callbacks.ChannelMessageListener;
|
|
@@ -35,6 +36,7 @@ import com.dmdirc.parser.irc.IRCParser;
|
35
|
36
|
|
36
|
37
|
import java.lang.reflect.Field;
|
37
|
38
|
import java.util.Date;
|
|
39
|
+import java.util.HashMap;
|
38
|
40
|
import java.util.Map;
|
39
|
41
|
|
40
|
42
|
/**
|
|
@@ -63,7 +65,7 @@ public class RelayCallbackManager extends CallbackManager implements SocketClose
|
63
|
65
|
* @param parser
|
64
|
66
|
*/
|
65
|
67
|
public RelayCallbackManager(final RelayBotPlugin myPlugin, final IRCParser parser) {
|
66
|
|
- super(parser, IRCParser.IMPL_MAP);
|
|
68
|
+ super(parser, getImplementations());
|
67
|
69
|
|
68
|
70
|
this.myPlugin = myPlugin;
|
69
|
71
|
this.originalCBM = parser.getCallbackManager();
|
|
@@ -71,6 +73,19 @@ public class RelayCallbackManager extends CallbackManager implements SocketClose
|
71
|
73
|
addCallback(SocketCloseListener.class, this);
|
72
|
74
|
}
|
73
|
75
|
|
|
76
|
+ private static Map<Class<?>, Class<?>> getImplementations() {
|
|
77
|
+ final Map<Class<?>, Class<?>> implementations
|
|
78
|
+ = new HashMap<Class<?>, Class<?>>();
|
|
79
|
+
|
|
80
|
+ for (Class<?> child : IRCParser.class.getAnnotation(ChildImplementations.class).value()) {
|
|
81
|
+ for (Class<?> iface : child.getInterfaces()) {
|
|
82
|
+ implementations.put(iface, child);
|
|
83
|
+ }
|
|
84
|
+ }
|
|
85
|
+
|
|
86
|
+ return implementations;
|
|
87
|
+ }
|
|
88
|
+
|
74
|
89
|
/** {@inheritDoc} */
|
75
|
90
|
@Override
|
76
|
91
|
public <S extends CallbackInterface> void addCallback(final Class<S> callback, final S o, final String target) throws CallbackNotFoundException {
|