Search in sources :

Example 6 with TransportInDescription

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);
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) XMPPServerCredentials(org.apache.axis2.transport.xmpp.util.XMPPServerCredentials) XMPPConnectionFactory(org.apache.axis2.transport.xmpp.util.XMPPConnectionFactory) ParameterIncludeImpl(org.apache.axis2.description.ParameterIncludeImpl) Iterator(java.util.Iterator) Parameter(org.apache.axis2.description.Parameter)

Example 7 with TransportInDescription

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;
}
Also used : TransportInDescription(org.apache.axis2.description.TransportInDescription)

Example 8 with TransportInDescription

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;
}
Also used : AxisFault(org.apache.axis2.AxisFault) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) QName(javax.xml.namespace.QName) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) MessageContext(org.apache.axis2.context.MessageContext) HashMap(java.util.HashMap) Map(java.util.Map)

Example 9 with TransportInDescription

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;
}
Also used : AxisFault(org.apache.axis2.AxisFault) Parameter(org.apache.axis2.description.Parameter)

Example 10 with TransportInDescription

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;
}
Also used : TransportInDescription(org.apache.axis2.description.TransportInDescription)

Aggregations

TransportInDescription (org.apache.axis2.description.TransportInDescription)7 AxisFault (org.apache.axis2.AxisFault)5 TransportOutDescription (org.apache.axis2.description.TransportOutDescription)3 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)3 Map (java.util.Map)2 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)2 MessageContext (org.apache.axis2.context.MessageContext)2 Parameter (org.apache.axis2.description.Parameter)2 CustomAxisConfigurator (org.apache.axis2.transport.CustomAxisConfigurator)2 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 QName (javax.xml.namespace.QName)1 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)1 EndpointReference (org.apache.axis2.addressing.EndpointReference)1 AxisService (org.apache.axis2.description.AxisService)1 ParameterIncludeImpl (org.apache.axis2.description.ParameterIncludeImpl)1 ListenerManager (org.apache.axis2.engine.ListenerManager)1 AxisServiceFilter (org.apache.axis2.transport.base.tracker.AxisServiceFilter)1 AxisServiceTracker (org.apache.axis2.transport.base.tracker.AxisServiceTracker)1