|
@@ -25,13 +25,13 @@ package com.dmdirc;
|
25
|
25
|
import com.dmdirc.logger.ErrorLevel;
|
26
|
26
|
import com.dmdirc.logger.Logger;
|
27
|
27
|
import com.dmdirc.parser.interfaces.Parser;
|
28
|
|
-import com.dmdirc.parser.irc.IRCParser;
|
29
|
28
|
import com.dmdirc.parser.common.MyInfo;
|
30
|
29
|
import com.dmdirc.plugins.ExportedService;
|
31
|
30
|
import com.dmdirc.plugins.NoSuchProviderException;
|
32
|
31
|
import com.dmdirc.plugins.PluginManager;
|
33
|
32
|
import com.dmdirc.plugins.Service;
|
34
|
33
|
import com.dmdirc.plugins.ServiceProvider;
|
|
34
|
+
|
35
|
35
|
import java.net.URI;
|
36
|
36
|
|
37
|
37
|
/**
|
|
@@ -41,10 +41,10 @@ import java.net.URI;
|
41
|
41
|
* @author chris
|
42
|
42
|
*/
|
43
|
43
|
public class ParserFactory {
|
44
|
|
-
|
|
44
|
+
|
45
|
45
|
/**
|
46
|
46
|
* Retrieves a parser instance.
|
47
|
|
- *
|
|
47
|
+ *
|
48
|
48
|
* @param myInfo The client information to use
|
49
|
49
|
* @param address The address of the server to connect to
|
50
|
50
|
* @return An appropriately configured parser
|
|
@@ -62,38 +62,34 @@ public class ParserFactory {
|
62
|
62
|
}
|
63
|
63
|
}
|
64
|
64
|
|
65
|
|
- if (address.getScheme() == null || "irc".equals(address.getScheme())
|
66
|
|
- || "ircs".equals(address.getScheme())) {
|
67
|
|
- return new IRCParser(myInfo, address);
|
68
|
|
- } else {
|
69
|
|
- try {
|
70
|
|
- final Service service = PluginManager.getPluginManager()
|
71
|
|
- .getService("parser", address.getScheme());
|
|
65
|
+ // TODO: Move default scheme to a setting
|
|
66
|
+ final String scheme = address.getScheme() == null ? "irc" : address.getScheme();
|
72
|
67
|
|
73
|
|
- if (service != null && !service.getProviders().isEmpty()) {
|
74
|
|
- final ServiceProvider provider = service.getProviders().get(0);
|
|
68
|
+ try {
|
|
69
|
+ final Service service = PluginManager.getPluginManager().getService("parser", scheme);
|
75
|
70
|
|
76
|
|
- if (provider != null) {
|
77
|
|
- provider.activateServices();
|
|
71
|
+ if (service != null && !service.getProviders().isEmpty()) {
|
|
72
|
+ final ServiceProvider provider = service.getProviders().get(0);
|
78
|
73
|
|
79
|
|
- final ExportedService exportService = provider
|
80
|
|
- .getExportedService("getParser");
|
81
|
|
- final Object obj = exportService.execute(myInfo, address);
|
82
|
|
- if (obj != null && obj instanceof Parser) {
|
83
|
|
- return (Parser)obj;
|
84
|
|
- } else {
|
85
|
|
- Logger.userError(ErrorLevel.MEDIUM,
|
86
|
|
- "Unable to create parser for: " + address.getScheme());
|
87
|
|
- }
|
|
74
|
+ if (provider != null) {
|
|
75
|
+ provider.activateServices();
|
|
76
|
+
|
|
77
|
+ final ExportedService exportService = provider.getExportedService("getParser");
|
|
78
|
+ final Object obj = exportService.execute(myInfo, address);
|
|
79
|
+ if (obj != null && obj instanceof Parser) {
|
|
80
|
+ return (Parser) obj;
|
|
81
|
+ } else {
|
|
82
|
+ Logger.userError(ErrorLevel.MEDIUM,
|
|
83
|
+ "Unable to create parser for: " + address.getScheme());
|
88
|
84
|
}
|
89
|
85
|
}
|
90
|
|
- } catch (NoSuchProviderException nspe) {
|
91
|
|
- Logger.userError(ErrorLevel.MEDIUM,
|
92
|
|
- "No parser found for: " + address.getScheme(), nspe);
|
93
|
86
|
}
|
94
|
|
-
|
95
|
|
- return null;
|
|
87
|
+ } catch (NoSuchProviderException nspe) {
|
|
88
|
+ Logger.userError(ErrorLevel.MEDIUM,
|
|
89
|
+ "No parser found for: " + address.getScheme(), nspe);
|
96
|
90
|
}
|
|
91
|
+
|
|
92
|
+ return null;
|
97
|
93
|
}
|
98
|
94
|
|
99
|
95
|
}
|