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;
}
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;
}
Aggregations