|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| package org.jconfig.handler; |
|
8 |
| |
|
9 |
| import org.jconfig.Configuration; |
|
10 |
| import org.jconfig.ConfigurationManagerException; |
|
11 |
| import org.jconfig.error.ErrorReporter; |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| public class ConfigServerHandler extends URLHandler { |
|
17 |
| |
|
18 |
| |
|
19 |
0
| public ConfigServerHandler() {
|
|
20 |
| } |
|
21 |
| |
|
22 |
0
| public synchronized Configuration load() throws ConfigurationManagerException {
|
|
23 |
0
| String myURL = getURL();
|
|
24 |
0
| if ( !myURL.startsWith("jconfig://" ) ) {
|
|
25 |
0
| ErrorReporter.getErrorHandler().reportError("Wrong URL. Must start with jconfig://. Syntax: jconfig://server:port/configname");
|
|
26 |
0
| throw new ConfigurationManagerException("Wrong URL. Must start with jconfig://. Syntax: jconfig://server:port/configname");
|
|
27 |
| } |
|
28 |
0
| myURL = myURL.substring(10);
|
|
29 |
0
| if ( myURL.indexOf("/") == -1 ) {
|
|
30 |
0
| ErrorReporter.getErrorHandler().reportError("Wrong URL. The configname is missing. Syntax: jconfig://server:port/configname");
|
|
31 |
0
| throw new ConfigurationManagerException("Wrong URL. The configname is missing. Syntax: jconfig://server:port/configname");
|
|
32 |
| } |
|
33 |
| |
|
34 |
0
| int pos = myURL.indexOf("/");
|
|
35 |
0
| if ( (pos +1 ) > myURL.length() ) {
|
|
36 |
0
| ErrorReporter.getErrorHandler().reportError("Wrong URL. The configname is missing. Syntax: jconfig://server:port/configname");
|
|
37 |
0
| throw new ConfigurationManagerException("Wrong URL. The configname is missing. Syntax: jconfig://server:port/configname");
|
|
38 |
| } |
|
39 |
0
| String name = myURL.substring(pos+1);
|
|
40 |
0
| myURL = "http://"+myURL;
|
|
41 |
0
| return load( myURL,name );
|
|
42 |
| } |
|
43 |
| |
|
44 |
0
| public synchronized Configuration load(String configName) throws ConfigurationManagerException {
|
|
45 |
0
| String myURL = getURL();
|
|
46 |
0
| if ( !myURL.startsWith("jconfig://" ) ) {
|
|
47 |
0
| ErrorReporter.getErrorHandler().reportError("Wrong URL. Must start with jconfig://. Syntax: jconfig://server:port/configname");
|
|
48 |
0
| throw new ConfigurationManagerException("Wrong URL. Must start with jconfig://. Syntax: jconfig://server:port/configname");
|
|
49 |
| } |
|
50 |
0
| myURL = myURL.substring(10);
|
|
51 |
0
| if ( myURL.indexOf("/") == -1 ) {
|
|
52 |
0
| ErrorReporter.getErrorHandler().reportError("Wrong URL. The configname is missing. Syntax: jconfig://server:port/configname");
|
|
53 |
0
| throw new ConfigurationManagerException("Wrong URL. The configname is missing. Syntax: jconfig://server:port/configname");
|
|
54 |
| } |
|
55 |
| |
|
56 |
0
| int pos = myURL.indexOf("/");
|
|
57 |
0
| if ( (pos +1 ) > myURL.length() ) {
|
|
58 |
0
| ErrorReporter.getErrorHandler().reportError("Wrong URL. The configname is missing. Syntax: jconfig://server:port/configname");
|
|
59 |
0
| throw new ConfigurationManagerException("Wrong URL. The configname is missing. Syntax: jconfig://server:port/configname");
|
|
60 |
| } |
|
61 |
0
| String name = myURL.substring(pos+1);
|
|
62 |
0
| myURL = "http://"+myURL;
|
|
63 |
0
| return load( myURL,name );
|
|
64 |
| } |
|
65 |
| |
|
66 |
| } |