{
String id = attrs.getValue("id");
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "producer identifier", "Configuring a producer");
// check that the consumer doesn't exist in the database first
WSRPConsumer consumer = consumerRegistry.getConsumer(id);
if (consumer != null)
{
String message = "Added consumer for producer '" + id + "' with status: ";
// if consumer is active, add it to the list of services
if (consumer.getProducerInfo().isActive())
{
consumers.put(id, consumer);
message += "active";
}
else
{
message += "inactive";
}
log.info(message + " (loaded from database).");
// consumer already exists, do not further process this producer and use the DB configuration instead
return null;
}
String expirationCache = attrs.getValue("expiration-cache");
Integer expirationCacheSeconds = ProducerInfo.DEFAULT_CACHE_VALUE;
if (!ParameterValidation.isNullOrEmpty(expirationCache))
{
try
{
expirationCacheSeconds = new Integer(expirationCache);
}
catch (NumberFormatException e)
{
log.info("Ignoring bad expiration cache value " + expirationCache + " for producer '" + id + "'. Using default value instead.");
}
}
String wsTimeout = attrs.getValue("ws-timeout");
Integer wsTimeoutMS = ServiceFactory.DEFAULT_TIMEOUT_MS;
if (!ParameterValidation.isNullOrEmpty(wsTimeout))
{
try
{
wsTimeoutMS = new Integer(wsTimeout);
}
catch (NumberFormatException e)
{
log.info("Ignoring bad WS timeout value " + wsTimeout + " for producer '" + id + "'");
}
}
final String useWSS = attrs.getValue("use-wss");
boolean enableWSS = false;
if (!ParameterValidation.isNullOrEmpty(useWSS))
{
enableWSS = Boolean.parseBoolean(useWSS);
}
// consumer didn't exist in the database, so create one and configure it
consumer = consumerRegistry.createConsumer(id, expirationCacheSeconds, null);
final EndpointConfigurationInfo endpoint = consumer.getProducerInfo().getEndpointConfigurationInfo();
endpoint.setWSOperationTimeOut(wsTimeoutMS);
endpoint.setWSSEnabled(enableWSS);
return consumer;
}