use of org.apache.axis2.description.TransportOutDescription in project wso2-axis2-transports by wso2.
the class SMSManager method init.
/**
* Initialize the SMS Maneger with TransportOutDiscription
* if the Maneger is already inited it will set the Transport Outdetails
* in the Current Implimentation Manage
* @param transportOutDescription
* @param configurationContext
*/
public void init(TransportOutDescription transportOutDescription, ConfigurationContext configurationContext) throws AxisFault {
if (!inited) {
basicInit(transportOutDescription, configurationContext);
}
Parameter formatterClass = transportOutDescription.getParameter(SMSTransportConstents.FORMATTER_CLASS);
if (formatterClass == null) {
messageFormatter = new DefaultSMSMessageFormatterImpl();
} else {
try {
messageFormatter = (SMSMessageFormatter) Class.forName((String) formatterClass.getValue()).newInstance();
} catch (Exception e) {
throw new AxisFault("Error while instentiating the Class: " + formatterClass.getValue(), e);
}
}
currentImplimentation.setTransportOutDetails(transportOutDescription);
Parameter invertS_n_D = transportOutDescription.getParameter(SMSTransportConstents.INVERT_SOURCE_AND_DESTINATION);
if (invertS_n_D != null) {
String val = (String) invertS_n_D.getValue();
if ("false".equals(val)) {
invertSourceAndDestination = false;
} else if ("true".equals(val)) {
invertSourceAndDestination = true;
} else {
log.warn("Invalid parameter value set to the parameter invert_source_and_destination," + "setting the default value :true ");
invertSourceAndDestination = true;
}
}
inited = true;
}
use of org.apache.axis2.description.TransportOutDescription in project wso2-axis2-transports by wso2.
the class MailTestEnvironment method createTransportOutDescription.
public TransportOutDescription createTransportOutDescription() throws Exception {
TransportOutDescription trpOutDesc = new TransportOutDescription(MailConstants.TRANSPORT_NAME);
trpOutDesc.setSender(new MailTransportSender());
trpOutDesc.addParameter(new Parameter(MailConstants.TRANSPORT_MAIL_DEBUG, "true"));
for (Map.Entry<String, String> prop : getOutProperties().entrySet()) {
trpOutDesc.addParameter(new Parameter(prop.getKey(), prop.getValue()));
}
return trpOutDesc;
}
use of org.apache.axis2.description.TransportOutDescription in project wso2-synapse by wso2.
the class ProxyConfigBuilder method getProxyProfiles.
/**
* Looks for a transport parameter named proxyProfiles and initializes a map of ProxyProfileConfig.
* The syntax for defining a proxy profiles is as follows.
* {@code
* <parameter name="proxyProfiles">
* <profile>
* <targetHosts>example.com, *.sample.com</targetHosts>
* <proxyHost>localhost</proxyHost>
* <proxyPort>3128</proxyPort>
* <proxyUserName>squidUser</proxyUserName>
* <proxyPassword>password</proxyPassword>
* <bypass>xxx.sample.com</bypass>
* </profile>
* <profile>
* <targetHosts>localhost</targetHosts>
* <proxyHost>localhost</proxyHost>
* <proxyPort>7443</proxyPort>
* </profile>
* <profile>
* <targetHosts>*</targetHosts>
* <proxyHost>localhost</proxyHost>
* <proxyPort>7443</proxyPort>
* <bypass>test.com, direct.com</bypass>
* </profile>
* </parameter>
* }
*
* @param transportOut transport out description
* @return map of <code>ProxyProfileConfig<code/> if configured in axis2.xml; otherwise null
* @throws AxisFault if proxy profile is not properly configured
*/
private Map<String, ProxyProfileConfig> getProxyProfiles(TransportOutDescription transportOut) throws AxisFault {
Parameter proxyProfilesParam = transportOut.getParameter("proxyProfiles");
if (proxyProfilesParam == null) {
return null;
}
if (log.isDebugEnabled()) {
log.debug(name + " Loading proxy profiles for the HTTP/S sender");
}
OMElement proxyProfilesParamEle = proxyProfilesParam.getParameterElement();
Iterator<?> profiles = proxyProfilesParamEle.getChildrenWithName(Q_PROFILE);
Map<String, ProxyProfileConfig> proxyProfileMap = new HashMap<String, ProxyProfileConfig>();
while (profiles.hasNext()) {
OMElement profile = (OMElement) profiles.next();
OMElement targetHostsEle = profile.getFirstChildWithName(Q_TARGET_HOSTS);
if (targetHostsEle == null || targetHostsEle.getText().isEmpty()) {
String msg = "Each proxy profile must define at least one host " + "or a wildcard matcher under the targetHosts element";
log.error(name + " " + msg);
throw new AxisFault(msg);
}
HttpHost proxy = getHttpProxy(profile, targetHostsEle.getText());
UsernamePasswordCredentials proxyCredentials = getUsernamePasswordCredentials(profile);
Set<String> proxyBypass = getProxyBypass(profile);
ProxyProfileConfig proxyProfileConfig = new ProxyProfileConfig(proxy, proxyCredentials, proxyBypass);
String[] targetHosts = targetHostsEle.getText().split(",");
for (String endpoint : targetHosts) {
endpoint = endpoint.trim();
if (!proxyProfileMap.containsKey(endpoint)) {
proxyProfileMap.put(endpoint, proxyProfileConfig);
} else {
log.warn(name + " Multiple proxy profiles were found for the endpoint: " + endpoint + ". Ignoring the excessive profiles.");
}
}
}
if (proxyProfileMap.size() > 0) {
log.info(name + " Proxy profiles initialized for " + proxyProfileMap.size() + " targetHosts");
return proxyProfileMap;
}
return null;
}
use of org.apache.axis2.description.TransportOutDescription in project wso2-synapse by wso2.
the class DynamicProfileReloader method extractConfigurationFilePath.
/**
* Set the configuration file path from custom SSL config
*
* @param transportOut TransportOutDescription of the configuration
* @return File Path String
*/
protected String extractConfigurationFilePath(ParameterInclude transportOut) {
String path = null;
Parameter profileParam = transportOut.getParameter(PROFILE_CONFIG_NAME);
// No Separate configuration file configured. Therefore using Axis2 Configuration
if (profileParam != null) {
OMElement profileParamElem = profileParam.getParameterElement();
path = profileParamElem.getFirstChildWithName(new QName(PATH_CONFIG_NAME)).getText();
}
return path;
}
use of org.apache.axis2.description.TransportOutDescription in project wso2-synapse by wso2.
the class Axis2TransportHelper method getPendingSenderThreadCount.
/**
* Determines the total number of pending sender threads (active + queued).
*
* @return the total number of pending sender threads (active + queued).
*/
public int getPendingSenderThreadCount() {
int pendingThreads = 0;
Map<String, TransportOutDescription> trpOuts = configurationContext.getAxisConfiguration().getTransportsOut();
for (TransportOutDescription trpOut : trpOuts.values()) {
TransportSender trpSnd = trpOut.getSender();
if (trpSnd instanceof ManagementSupport) {
int inUse = ((ManagementSupport) trpSnd).getActiveThreadCount();
int inQue = ((ManagementSupport) trpSnd).getQueueSize();
if ((inUse + inQue) > 0) {
if (log.isDebugEnabled()) {
log.debug(new StringBuilder("Transport Sender : ").append(trpSnd.getName()).append(" currently using : ").append(inUse).append(" threads with ").append(inQue).append(" requests already queued...").toString());
}
pendingThreads += (inUse + inQue);
}
}
}
return pendingThreads;
}
Aggregations