Search in sources :

Example 1 with ContentTypeRuleSet

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

the class ContentTypeRuleFactory method parse.

public static ContentTypeRuleSet parse(Parameter param) throws AxisFault {
    ContentTypeRuleSet ruleSet = new ContentTypeRuleSet();
    Object value = param.getValue();
    if (value instanceof OMElement) {
        OMElement element = (OMElement) value;
        // TODO: seems like a bug in Axis2 and is inconsistent with Synapse's way of parsing parameter in proxy definitions
        if (element == param.getParameterElement()) {
            element = element.getFirstElement();
        }
        if (element.getLocalName().equals("rules")) {
            for (Iterator it = element.getChildElements(); it.hasNext(); ) {
                ruleSet.addRule(parse((OMElement) it.next()));
            }
        } else {
            throw new AxisFault("Expected <rules> element");
        }
    } else {
        ruleSet.addRule(new DefaultRule((String) value));
    }
    return ruleSet;
}
Also used : AxisFault(org.apache.axis2.AxisFault) Iterator(java.util.Iterator) OMElement(org.apache.axiom.om.OMElement)

Example 2 with ContentTypeRuleSet

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

AxisFault (org.apache.axis2.AxisFault)2 Iterator (java.util.Iterator)1 BytesMessage (javax.jms.BytesMessage)1 TextMessage (javax.jms.TextMessage)1 OMElement (org.apache.axiom.om.OMElement)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