Search in sources :

Example 1 with MessageTypeRule

use of org.apache.axis2.transport.jms.ctype.MessageTypeRule in project wso2-axis2-transports by wso2.

the class ContentTypeRuleFactory method parse.

public static ContentTypeRule parse(OMElement element) throws AxisFault {
    String name = element.getLocalName();
    String value = element.getText();
    if (name.equals("jmsProperty")) {
        return new PropertyRule(value);
    } else if (name.equals("textMessage")) {
        return new MessageTypeRule(TextMessage.class, value);
    } else if (name.equals("bytesMessage")) {
        return new MessageTypeRule(BytesMessage.class, value);
    } else if (name.equals("default")) {
        return new DefaultRule(value);
    } else {
        throw new AxisFault("Unknown content rule type '" + name + "'");
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) TextMessage(javax.jms.TextMessage)

Example 2 with MessageTypeRule

use of org.apache.axis2.transport.jms.ctype.MessageTypeRule 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)

Aggregations

TextMessage (javax.jms.TextMessage)2 AxisFault (org.apache.axis2.AxisFault)2 BytesMessage (javax.jms.BytesMessage)1 AxisService (org.apache.axis2.description.AxisService)1 Parameter (org.apache.axis2.description.Parameter)1 ContentTypeRuleSet (org.apache.axis2.transport.jms.ctype.ContentTypeRuleSet)1 MessageTypeRule (org.apache.axis2.transport.jms.ctype.MessageTypeRule)1 PropertyRule (org.apache.axis2.transport.jms.ctype.PropertyRule)1