Search in sources :

Example 16 with Parameter

use of org.apache.axis2.description.Parameter in project wso2-axis2-transports by wso2.

the class ProtocolEndpoint method createMessageContext.

public MessageContext createMessageContext() throws AxisFault {
    MessageContext msgContext = listener.createMessageContext();
    if (service != null) {
        msgContext.setAxisService(service);
        // find the operation for the message, or default to one
        Parameter operationParam = service.getParameter(BaseConstants.OPERATION_PARAM);
        QName operationQName = (operationParam != null ? BaseUtils.getQNameFromString(operationParam.getValue()) : BaseConstants.DEFAULT_OPERATION);
        AxisOperation operation = service.getOperation(operationQName);
        if (operation != null) {
            msgContext.setAxisOperation(operation);
            msgContext.setAxisMessage(operation.getMessage(WSDL2Constants.MESSAGE_LABEL_IN));
            msgContext.setSoapAction("urn:" + operation.getName().getLocalPart());
        }
    }
    return msgContext;
}
Also used : AxisOperation(org.apache.axis2.description.AxisOperation) QName(javax.xml.namespace.QName) Parameter(org.apache.axis2.description.Parameter) MessageContext(org.apache.axis2.context.MessageContext)

Example 17 with Parameter

use of org.apache.axis2.description.Parameter in project wso2-axis2-transports by wso2.

the class JMSConnectionFactoryManager method loadConnectionFactoryDefinitions.

/**
 * Create JMSConnectionFactory instances for the definitions in the transport configuration,
 * and add these into our collection of connectionFactories map keyed by name
 *
 * @param trpDesc the transport description for JMS
 */
@Deprecated
private void loadConnectionFactoryDefinitions(ParameterInclude trpDesc) {
    for (Parameter p : trpDesc.getParameters()) {
        try {
            JMSConnectionFactory jmsConFactory = new JMSConnectionFactory(p);
            connectionFactories.put(jmsConFactory.getName(), jmsConFactory);
        } catch (AxisJMSException e) {
            log.error("Error setting up connection factory : " + p.getName(), e);
        }
    }
}
Also used : Parameter(org.apache.axis2.description.Parameter)

Example 18 with Parameter

use of org.apache.axis2.description.Parameter in project wso2-axis2-transports by wso2.

the class JMSConnectionFactoryManager method loadConnectionFactoryDefinitions.

/**
 * Create JMSConnectionFactory instances for the definitions in the transport configuration,
 * and add these into our collection of connectionFactories map keyed by name.
 *
 * @param trpDesc the transport description for JMS
 * @param secretResolver the SecretResolver to use to resolve secrets such as passwords
 */
private void loadConnectionFactoryDefinitions(ParameterInclude trpDesc, SecretResolver secretResolver) {
    for (Parameter parameter : trpDesc.getParameters()) {
        try {
            JMSConnectionFactory jmsConFactory = new JMSConnectionFactory(parameter, secretResolver);
            connectionFactories.put(jmsConFactory.getName(), jmsConFactory);
        } catch (AxisJMSException e) {
            log.error("Error setting up connection factory : " + parameter.getName(), e);
        }
    }
}
Also used : Parameter(org.apache.axis2.description.Parameter)

Example 19 with Parameter

use of org.apache.axis2.description.Parameter in project wso2-axis2-transports by wso2.

the class JMSEndpoint method loadConfiguration.

@Override
public boolean loadConfiguration(ParameterInclude params) throws AxisFault {
    // We only support endpoints configured at service level
    if (!(params instanceof AxisService)) {
        return false;
    }
    AxisService service = (AxisService) params;
    cf = listener.getConnectionFactory(service);
    if (cf == null) {
        return false;
    }
    Parameter destParam = service.getParameter(JMSConstants.PARAM_DESTINATION);
    if (destParam != null) {
        jndiDestinationName = (String) destParam.getValue();
    } else {
        // Assume that the JNDI destination name is the same as the service name
        jndiDestinationName = service.getName();
    }
    Parameter destTypeParam = service.getParameter(JMSConstants.PARAM_DEST_TYPE);
    if (destTypeParam != null) {
        String paramValue = (String) destTypeParam.getValue();
        if (JMSConstants.DESTINATION_TYPE_QUEUE.equals(paramValue) || JMSConstants.DESTINATION_TYPE_TOPIC.equals(paramValue)) {
            setDestinationType(paramValue);
        } else {
            throw new AxisFault("Invalid destinaton type value " + paramValue);
        }
    } else {
        log.debug("JMS destination type not given. default queue");
        destinationType = JMSConstants.QUEUE;
    }
    Parameter replyDestTypeParam = service.getParameter(JMSConstants.PARAM_REPLY_DEST_TYPE);
    if (replyDestTypeParam != null) {
        String paramValue = (String) replyDestTypeParam.getValue();
        if (JMSConstants.DESTINATION_TYPE_QUEUE.equals(paramValue) || JMSConstants.DESTINATION_TYPE_TOPIC.equals(paramValue)) {
            setReplyDestinationType(paramValue);
        } else {
            throw new AxisFault("Invalid destination type value " + paramValue);
        }
    } else {
        log.debug("JMS reply destination type not given. default queue");
        replyDestinationType = JMSConstants.DESTINATION_TYPE_QUEUE;
    }
    jndiReplyDestinationName = ParamUtils.getOptionalParam(service, JMSConstants.PARAM_REPLY_DESTINATION);
    Parameter contentTypeParam = service.getParameter(JMSConstants.CONTENT_TYPE_PARAM);
    if (contentTypeParam == null) {
        contentTypeRuleSet = new ContentTypeRuleSet();
        contentTypeRuleSet.addRule(new PropertyRule(BaseConstants.CONTENT_TYPE));
        contentTypeRuleSet.addRule(new MessageTypeRule(BytesMessage.class, "application/octet-stream"));
        contentTypeRuleSet.addRule(new MessageTypeRule(TextMessage.class, "text/plain"));
    } else {
        contentTypeRuleSet = ContentTypeRuleFactory.parse(contentTypeParam);
    }
    // compute service EPR and keep for later use
    computeEPRs();
    serviceTaskManager = ServiceTaskManagerFactory.createTaskManagerForService(cf, service, workerPool);
    serviceTaskManager.setJmsMessageReceiver(new JMSMessageReceiver(listener, cf, this));
    // Fix for ESBJAVA-3687, retrieve JMS transport property transport.jms.MessagePropertyHyphens and set this
    // into the msgCtx
    Parameter paramHyphenSupport = service.getParameter(JMSConstants.PARAM_JMS_HYPHEN_MODE);
    if (paramHyphenSupport != null) {
        if (((String) paramHyphenSupport.getValue()).equals(JMSConstants.HYPHEN_MODE_REPLACE)) {
            hyphenSupport = JMSConstants.HYPHEN_MODE_REPLACE;
        } else if (((String) paramHyphenSupport.getValue()).equals(JMSConstants.HYPHEN_MODE_DELETE)) {
            hyphenSupport = JMSConstants.HYPHEN_MODE_DELETE;
        }
    }
    return true;
}
Also used : AxisFault(org.apache.axis2.AxisFault) PropertyRule(org.apache.axis2.transport.jms.ctype.PropertyRule) AxisService(org.apache.axis2.description.AxisService) Parameter(org.apache.axis2.description.Parameter) ContentTypeRuleSet(org.apache.axis2.transport.jms.ctype.ContentTypeRuleSet) BytesMessage(javax.jms.BytesMessage) MessageTypeRule(org.apache.axis2.transport.jms.ctype.MessageTypeRule) TextMessage(javax.jms.TextMessage)

Example 20 with Parameter

use of org.apache.axis2.description.Parameter 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)

Aggregations

Parameter (org.apache.axis2.description.Parameter)23 AxisFault (org.apache.axis2.AxisFault)10 AxisService (org.apache.axis2.description.AxisService)6 QName (javax.xml.namespace.QName)4 MessageContext (org.apache.axis2.context.MessageContext)4 Iterator (java.util.Iterator)3 OMElement (org.apache.axiom.om.OMElement)3 AxisOperation (org.apache.axis2.description.AxisOperation)3 AMQP (com.rabbitmq.client.AMQP)2 List (java.util.List)2 Map (java.util.Map)2 TransportOutDescription (org.apache.axis2.description.TransportOutDescription)2 ConsumerCancelledException (com.rabbitmq.client.ConsumerCancelledException)1 QueueingConsumer (com.rabbitmq.client.QueueingConsumer)1 ShutdownSignalException (com.rabbitmq.client.ShutdownSignalException)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 PrintWriter (java.io.PrintWriter)1