23
23
* @author Bela Ban
24
24
*/
25
25
public class ConfiguratorFactory {
26
- public static final String JAXP_MISSING_ERROR_MSG ="the required XML parsing classes are not available; " +
27
- "make sure that JAXP compatible libraries are in the classpath." ;
28
-
29
26
30
27
protected ConfiguratorFactory () {
31
28
}
@@ -38,7 +35,6 @@ protected ConfiguratorFactory() {
38
35
* @throws Exception if problems occur during the configuration of the protocol stack.
39
36
*/
40
37
public static ProtocolStackConfigurator getStackConfigurator (File file ) throws Exception {
41
- checkJAXPAvailability ();
42
38
InputStream input =getConfigStream (file );
43
39
return XmlConfigurator .getInstance (input );
44
40
}
@@ -47,7 +43,6 @@ public static ProtocolStackConfigurator getStackConfigurator(InputStream input)
47
43
return XmlConfigurator .getInstance (input );
48
44
}
49
45
50
-
51
46
/**
52
47
* Returns a protocol stack configurator based on the provided properties string.
53
48
* @param properties a string representing a system resource containing a JGroups XML configuration, a URL pointing
@@ -66,14 +61,10 @@ public static ProtocolStackConfigurator getStackConfigurator(String properties)
66
61
throw new IllegalStateException (String .format ("configuration %s not found or invalid" , properties ));
67
62
}
68
63
69
-
70
-
71
64
public static InputStream getConfigStream (File file ) throws Exception {
72
65
return new FileInputStream (Objects .requireNonNull (file ));
73
66
}
74
67
75
-
76
-
77
68
/**
78
69
* Returns a JGroups XML configuration InputStream based on the provided properties string.
79
70
*
@@ -109,7 +100,6 @@ public static InputStream getConfigStream(String properties) throws IOException
109
100
return configStream ;
110
101
}
111
102
112
-
113
103
public static InputStream getConfigStream (Object properties ) throws IOException {
114
104
InputStream input =null ;
115
105
@@ -148,9 +138,6 @@ public static InputStream getConfigStream(Object properties) throws IOException
148
138
return new ByteArrayInputStream (((String )properties ).getBytes ());
149
139
}
150
140
151
-
152
-
153
-
154
141
/**
155
142
* Returns an XmlConfigurator based on the provided properties string (if possible).
156
143
*
@@ -163,34 +150,14 @@ public static InputStream getConfigStream(Object properties) throws IOException
163
150
* JGroups XML configuration pointed to by the URL can not be parsed.
164
151
*/
165
152
static XmlConfigurator getXmlConfigurator (String properties ) throws IOException {
166
- XmlConfigurator returnValue =null ;
167
153
try (InputStream configStream =getConfigStream (properties )) {
168
154
if (configStream == null && properties .endsWith ("xml" ))
169
155
throw new FileNotFoundException (String .format (Util .getMessage ("FileNotFound" ), properties ));
170
156
171
- if (configStream != null ) {
172
- checkJAXPAvailability ();
173
- returnValue =XmlConfigurator .getInstance (configStream );
174
- }
175
- }
176
- return returnValue ;
177
- }
178
-
179
-
180
-
181
- /**
182
- * Checks the availability of the JAXP classes on the classpath.
183
- * @throws NoClassDefFoundError if the required JAXP classes are not availabile on the classpath.
184
- */
185
- static void checkJAXPAvailability () {
186
- try {
187
- XmlConfigurator .class .getName ();
188
- }
189
- catch (NoClassDefFoundError error ) {
190
- Error tmp =new NoClassDefFoundError (JAXP_MISSING_ERROR_MSG );
191
- tmp .initCause (error );
192
- throw tmp ;
157
+ if (configStream != null )
158
+ return XmlConfigurator .getInstance (configStream );
193
159
}
160
+ return null ;
194
161
}
195
162
196
163
}
0 commit comments