use of org.apache.axis2.description.ParameterIncludeImpl in project wso2-axis2-transports by wso2.
the class RabbitMQUtils method resolveTransportDescription.
/**
* Resolve transport parameters
*
* @param trpDesc axis2 transport parameters
* @param secretResolver secure vault encryption resolver
* @param rabbitMQConnectionFactory a rabbitmq connection factory
* @return pool size for connection and channel pooling
*/
public static int resolveTransportDescription(ParameterInclude trpDesc, SecretResolver secretResolver, RabbitMQConnectionFactory rabbitMQConnectionFactory) throws AxisRabbitMQException {
int poolSize = RabbitMQConstants.DEFAULT_POOL_SIZE;
for (Parameter parameter : trpDesc.getParameters()) {
String name = parameter.getName();
if (StringUtils.equals(name, RabbitMQConstants.PARAM_POOL_SIZE)) {
try {
poolSize = Integer.parseInt((String) parameter.getValue());
} catch (NumberFormatException e) {
throw new AxisRabbitMQException("Pool size must be an integer value.");
}
} else {
Map<String, String> parameters = new HashMap<>();
ParameterIncludeImpl pi = new ParameterIncludeImpl();
try {
pi.deserializeParameters((OMElement) parameter.getValue());
} catch (AxisFault axisFault) {
throw new AxisRabbitMQException("Error reading parameters for RabbitMQ connection factory " + name, axisFault);
}
for (Parameter p : pi.getParameters()) {
OMElement paramElement = p.getParameterElement();
String propertyValue = p.getValue().toString();
if (paramElement != null) {
OMAttribute attribute = paramElement.getAttribute(new QName(RabbitMQConstants.SECURE_VAULT_NAMESPACE, RabbitMQConstants.SECRET_ALIAS_ATTRIBUTE));
if (attribute != null && attribute.getAttributeValue() != null && !attribute.getAttributeValue().isEmpty()) {
if (secretResolver == null) {
throw new SecureVaultException("Axis2 Secret Resolver is null. Cannot resolve " + "encrypted entry for " + p.getName());
}
if (secretResolver.isTokenProtected(attribute.getAttributeValue())) {
propertyValue = secretResolver.resolve(attribute.getAttributeValue());
}
}
}
parameters.put(p.getName(), propertyValue);
}
rabbitMQConnectionFactory.addConnectionFactoryConfiguration(name, parameters);
}
}
return poolSize;
}
use of org.apache.axis2.description.ParameterIncludeImpl in project wso2-axis2-transports by wso2.
the class XMPPListener method initializeConnectionFactories.
/**
* Extract connection details & connect to those xmpp servers.
* @param transportIn TransportInDescription
*/
private void initializeConnectionFactories(TransportInDescription transportIn) throws AxisFault {
Iterator serversToListenOn = transportIn.getParameters().iterator();
while (serversToListenOn.hasNext()) {
Parameter connection = (Parameter) serversToListenOn.next();
log.info("Trying to establish connection for : " + connection.getName());
ParameterIncludeImpl pi = new ParameterIncludeImpl();
try {
pi.deserializeParameters((OMElement) connection.getValue());
} catch (AxisFault axisFault) {
log.error("Error reading parameters");
}
Iterator params = pi.getParameters().iterator();
serverCredentials = new XMPPServerCredentials();
while (params.hasNext()) {
Parameter param = (Parameter) params.next();
if (XMPPConstants.XMPP_SERVER_URL.equals(param.getName())) {
serverCredentials.setServerUrl((String) param.getValue());
} else if (XMPPConstants.XMPP_SERVER_USERNAME.equals(param.getName())) {
serverCredentials.setAccountName((String) param.getValue());
} else if (XMPPConstants.XMPP_SERVER_PASSWORD.equals(param.getName())) {
serverCredentials.setPassword((String) param.getValue());
} else if (XMPPConstants.XMPP_SERVER_TYPE.equals(param.getName())) {
serverCredentials.setServerType((String) param.getValue());
} else if (XMPPConstants.XMPP_DOMAIN_NAME.equals(param.getName())) {
serverCredentials.setDomainName((String) param.getValue());
}
}
XMPPConnectionFactory xmppConnectionFactory = new XMPPConnectionFactory();
xmppConnectionFactory.connect(serverCredentials);
connectionFactories.put(serverCredentials.getAccountName() + "@" + serverCredentials.getServerUrl(), xmppConnectionFactory);
}
}
Aggregations