use of org.apache.axis2.description.TransportInDescription 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);
}
}
use of org.apache.axis2.description.TransportInDescription in project wso2-axis2-transports by wso2.
the class JMSTransportDescriptionFactory method createTransportInDescription.
public TransportInDescription createTransportInDescription() throws Exception {
TransportInDescription trpInDesc = new TransportInDescription(JMSListener.TRANSPORT_NAME);
setupTransport(trpInDesc);
trpInDesc.setReceiver(new JMSListener());
return trpInDesc;
}
use of org.apache.axis2.description.TransportInDescription in project wso2-axis2-transports by wso2.
the class DefaultSMSMessageBuilderImpl method buildMessaage.
public MessageContext buildMessaage(SMSMessage msg, ConfigurationContext configurationContext) throws InvalidMessageFormatException {
String message = msg.getContent();
String sender = msg.getSender();
String receiver = msg.getReceiver();
String[] parts = message.split(":");
// may be can add feature to send message format for a request like ????
if (parts.length < 2) {
throw new InvalidMessageFormatException("format must be \"service_name \" : \"opration_name\" : " + "\"parm_1=val_1\" :..:\"param_n = val_n\"");
} else {
AxisConfiguration repo = configurationContext.getAxisConfiguration();
MessageContext messageContext = configurationContext.createMessageContext();
parts = trimSplited(parts);
try {
AxisService axisService = repo.getService(parts[0]);
if (axisService == null) {
throw new InvalidMessageFormatException("Service : " + parts[0] + "does not exsist");
} else {
messageContext.setAxisService(axisService);
AxisOperation axisOperation = axisService.getOperation(new QName(parts[1]));
if (axisOperation == null) {
throw new InvalidMessageFormatException("Operation: " + parts[1] + " does not exsist");
}
messageContext.setAxisOperation(axisOperation);
messageContext.setAxisMessage(axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE));
Map params = getParams(parts, 2);
SOAPEnvelope soapEnvelope = createSoapEnvelope(messageContext, params);
messageContext.setServerSide(true);
messageContext.setEnvelope(soapEnvelope);
TransportInDescription in = configurationContext.getAxisConfiguration().getTransportIn("sms");
TransportOutDescription out = configurationContext.getAxisConfiguration().getTransportOut("sms");
messageContext.setIncomingTransportName("sms");
messageContext.setProperty(SMSTransportConstents.SEND_TO, sender);
messageContext.setProperty(SMSTransportConstents.DESTINATION, receiver);
messageContext.setTransportIn(in);
messageContext.setTransportOut(out);
handleSMSProperties(msg, messageContext);
return messageContext;
}
} catch (AxisFault axisFault) {
log.debug("[DefaultSMSMessageBuilderImpl] Error while extracting the axis2Service \n" + axisFault);
}
}
return null;
}
use of org.apache.axis2.description.TransportInDescription in project wso2-axis2-transports by wso2.
the class SMSManager method init.
/**
* initialize the SMS manager with TransportinDiscription
* if Manager is already inited it will only set the TransportInDiscription
* in the current Implimentation manager
* @param transportInDescription
* @param configurationContext
* @throws AxisFault
*/
public void init(TransportInDescription transportInDescription, ConfigurationContext configurationContext) throws AxisFault {
if (!inited) {
basicInit(transportInDescription, configurationContext);
}
Parameter builderClass = transportInDescription.getParameter(SMSTransportConstents.BUILDER_CLASS);
if (builderClass == null) {
messageBuilder = new DefaultSMSMessageBuilderImpl();
} else {
try {
messageBuilder = (SMSMessageBuilder) Class.forName((String) builderClass.getValue()).newInstance();
} catch (Exception e) {
throw new AxisFault("Error while instentiating class " + builderClass.getValue(), e);
}
}
currentImplimentation.setTransportInDetails(transportInDescription);
// get the Axis phone number form the configuration file
Parameter phoneNum = transportInDescription.getParameter(SMSTransportConstents.PHONE_NUMBER);
if (phoneNum != null) {
this.phoneNumber = (String) phoneNum.getValue();
}
inited = true;
}
use of org.apache.axis2.description.TransportInDescription in project wso2-axis2-transports by wso2.
the class MailTestEnvironment method createTransportInDescription.
public TransportInDescription createTransportInDescription() throws Exception {
TransportInDescription trpInDesc = new TransportInDescription(MailConstants.TRANSPORT_NAME);
trpInDesc.setReceiver(new MailTransportListener());
return trpInDesc;
}
Aggregations