File |
Line |
net/sf/urlchecker/communication/configurers/MethodsConfigurer.java |
41 |
net/sf/urlchecker/v2/communication/configurers/MethodsConfigurer.java |
42 |
public class MethodsConfigurer implements Configurer<Map<String, HTTPMethods>> {
/*
* (non-Javadoc)
*
* @see
* net.sf.urlchecker.communication.configurers.Configurer#configureWith(org
* .apache.commons.configuration.XMLConfiguration, java.lang.Object)
*/
/** {@inheritDoc} */
public Map<String, HTTPMethods> configureWith(XMLConfiguration config) {
final Map<String, HTTPMethods> methods = new HashMap<String, HTTPMethods>();
if (config.containsKey("methods.method")) {
final List<HierarchicalConfiguration> methodsConfig = config
.configurationsAt("methods.method");
if (null != methodsConfig) {
for (final HierarchicalConfiguration method : methodsConfig) {
if ("*".equals(method.getString("[@source]"))) {
methods.put(null, HTTPMethods.valueOf(method.getString(
"[@type]", "HEAD")));
} else {
methods.put(method.getString("[@source]"), HTTPMethods
.valueOf(method.getString("[@type]", "HEAD")));
}
}
}
}
return methods;
}
}
|
File |
Line |
net/sf/urlchecker/communication/CommunicationFactory.java |
120 |
net/sf/urlchecker/v2/communication/CommunicationFactory.java |
121 |
.setHttpRequestRetryHandler(new RequestRetryHandler());
// ((DefaultHttpClient)client).setHttpConnectionManager(manager);
final RetriesConfigurer current1 = new RetriesConfigurer();
maxretries = current1.configureWith(config);
final MethodsConfigurer current2 = new MethodsConfigurer();
methods = current2.configureWith(config);
final ExceptionHandlersConfigurer current3 = new ExceptionHandlersConfigurer();
exceptionHandlers = current3.configureWith(config);
final ValidCodesConfigurer current4 = new ValidCodesConfigurer();
validCodes = current4.configureWith(config);
final URLPatternConfigurer current5 = new URLPatternConfigurer();
final String pattern = current5.configureWith(config);
urlpattern = null == pattern ? null : Pattern.compile(pattern);
// last statement always
configured = true;
} else {
// in case a new client is requested with a different threading
// scheme than the one that is active, throw a configuration
// exception
if (localThreadSceme != multithreaded) {
throw new ConfigurationException(
"Builder can only return one type of configuration until shutdown");
}
}
return client;
}
}
/*
* (non-Javadoc)
*
* @see
* net.sf.urlchecker.communication.GenericCommunicationFactory#configureClient
* (boolean, java.lang.String)
*/
/** {@inheritDoc} */
@Override
public HttpClient configureClient(boolean localThreadSceme, String FileName)
throws ConfigurationException {
synchronized (this) {
fileName = FileName;
return configureClient(localThreadSceme);
}
}
/*
* (non-Javadoc)
*
* @see
* net.sf.urlchecker.communication.GenericCommunicationFactory#getMethod
* (java.lang.String)
*/
/** {@inheritDoc} */
@Override
public HttpRequestBase getMethod(String source) {
|
File |
Line |
net/sf/urlchecker/communication/CommunicationFactory.java |
96 |
net/sf/urlchecker/v2/communication/CommunicationFactory.java |
93 |
XMLConfiguration config = null;
try {
config = new XMLConfiguration(fileName);
} catch (final ConfigurationException e) {
LOGGER.warn(MessageFormat.format(WARNINGS[0], new Object[] {
fileName, FILE_NOT_FOUND }));
try {
config = new XMLConfiguration(
HTTPCONFIGURATION_FILENAME);
} catch (final ConfigurationException e1) {
LOGGER.warn(MessageFormat.format(WARNINGS[0],
new Object[] { HTTPCONFIGURATION_FILENAME,
NO_CONFIG }));
}
} finally {
if (config == null) {
throw new ConfigurationException("no configuration");
}
}
final ClientConfigurer current = new ClientConfigurer(
|
File |
Line |
net/sf/urlchecker/communication/CommunicationBuilder.java |
35 |
net/sf/urlchecker/v2/communication/CommunicationBuilder.java |
36 |
public class CommunicationBuilder {
/**
* Returns the multithreaded client configured by the default
* httpconfigurations file in the class-path.
*
* @return the multithreaded client
* @throws org.apache.commons.configuration.ConfigurationException
* the configuration exception
*/
public HttpClient getMultithreadedClient() throws ConfigurationException {
return CommunicationFactory.getInstance().configureClient(true);
}
/**
* Returns the multithreaded client configured by the given file if it
* exists in the class path. If the file cannot be found the
* httpconfigurations.xml will be tried and if nothing found the internal
* default configuration will be used.
*
* @param fileName
* the file name
* @return the multithreaded client
* @throws org.apache.commons.configuration.ConfigurationException
* the configuration exception
*/
public HttpClient getMultithreadedClient(String fileName)
throws ConfigurationException {
return CommunicationFactory.getInstance().configureClient(true,
fileName);
}
/**
* Return the singlethreaded client configured by the default
* httpconfigurations file in the class-path.
*
* @return the singlethreaded client
* @throws org.apache.commons.configuration.ConfigurationException
* the configuration exception
*/
public HttpClient getSinglethreadedClient() throws ConfigurationException {
return CommunicationFactory.getInstance().configureClient(false);
}
/**
* Gets the singlethreaded client configured by the given file if it exists
* in the class path. If the file cannot be found the httpconfigurations.xml
* will be tried and if nothing found the internal default configuration
* will be used.
*
* @param fileName
* the file name
* @return the singlethreaded client
* @throws org.apache.commons.configuration.ConfigurationException
* the configuration exception
*/
public HttpClient getSinglethreadedClient(String fileName)
throws ConfigurationException {
return CommunicationFactory.getInstance().configureClient(false,
fileName);
}
/**
* Shutdown communication. Releases any connections opened and forgotten. If
* used, the client is lost and needs to be reconfigured for another use.
*/
public void shutdownCommunication() {
CommunicationFactory.getInstance().shutdown();
}
}
|