protected void populateMessageProperties(NormalizedMessage message, Map properties) { if (properties != null) { for (Iterator iter = properties.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); message.setProperty((String) entry.getKey(), entry.getValue()); } } }
protected void populateMessageProperties(NormalizedMessage message, Map properties) { if (properties != null) { for (Iterator iter = properties.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); message.setProperty((String) entry.getKey(), entry.getValue()); } } } }
public void buildAggregate(Object aggregation, NormalizedMessage message, MessageExchange exchange, boolean timeout) throws Exception { super.buildAggregate(aggregation, message, exchange, timeout); Object correlationId = message.getProperty(AbstractSplitter.SPLITTER_CORRID); message.setProperty(AbstractSplitter.SPLITTER_CORRID, null); message.setProperty(StaticRecipientList.RECIPIENT_LIST_CORRID, correlationId); }
/** * Convert SoapMessage headers to NormalizedMessage headers */ private void toNMSHeaders(NormalizedMessage normalizedMessage, Message soapMessage) { Map<String, Object> headers = new HashMap<String, Object>(); for (Map.Entry<QName, DocumentFragment> entry : soapMessage.getSoapHeaders().entrySet()) { headers.put(QNameUtil.toString(entry.getKey()), entry.getValue()); } headers.putAll(soapMessage.getTransportHeaders()); normalizedMessage.setProperty(JbiConstants.PROTOCOL_HEADERS, headers); }
/** * Copies all of the properties from one message to another * * @param from the message containing the properties * @param to the destination messages where the properties are set */ public static void copyProperties(NormalizedMessage from, NormalizedMessage to) { for (Iterator iter = from.getPropertyNames().iterator(); iter.hasNext();) { String name = (String) iter.next(); // Do not copy transient properties if (!PojoMarshaler.BODY.equals(name)) { Object value = from.getProperty(name); to.setProperty(name, value); } } }
/** * Transfer message properties from the ODE message exchange to the JBI message exchange object. * * @param jbiMex destination JBI message-exchange * @param odeMex source ODE message-exchange */ protected void copyMexProperties(javax.jbi.messaging.MessageExchange jbiMex, PartnerRoleMessageExchange odeMex) { __log.debug(odeMex + ": pmex copyProperties"); NormalizedMessage in = jbiMex.getMessage("in"); for (String propName : odeMex.getPropertyNames()) { String val = odeMex.getProperty(propName); if (val != null) { in.setProperty(propName, val); __log.debug(jbiMex + ": set pmex property " + propName + " = " + val); } } in.setProperty(MessageExchange.PROPERTY_SEP_MYROLE_SESSIONID, odeMex.getProperty(MessageExchange.PROPERTY_SEP_PARTNERROLE_SESSIONID)); in.setProperty(MessageExchange.PROPERTY_SEP_PARTNERROLE_SESSIONID, odeMex.getProperty(MessageExchange.PROPERTY_SEP_MYROLE_SESSIONID)); }
private static void copyProperties(NormalizedMessage from, NormalizedMessage to) { for (Object name : from.getPropertyNames()) { to.setProperty((String)name, from.getProperty((String)name)); } }
protected MessageExchange[] createParts(MessageExchange exchange) throws Exception { NormalizedMessage in = MessageUtil.copyIn(exchange); Source[] srcParts = split(in.getContent()); MessageExchange[] parts = new MessageExchange[srcParts.length]; for (int i = 0; i < srcParts.length; i++) { parts[i] = createPart(exchange.getPattern(), in, srcParts[i]); NormalizedMessage msg = parts[i].getMessage("in"); msg.setProperty(SPLITTER_COUNT, new Integer(srcParts.length)); msg.setProperty(SPLITTER_INDEX, new Integer(i)); msg.setProperty(SPLITTER_CORRID, exchange.getExchangeId()); } return parts; }
protected boolean transform(MessageExchange exchange, NormalizedMessage in, NormalizedMessage out) throws MessagingException { getMessageTransformer().transform(exchange, in, out); out.setContent(getResponseContent()); Map map = getResponseProperties(); if (map != null) { for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Object value = entry.getValue(); out.setProperty(name, value); } } return true; } }
/** * Extract the content as a jaxp Source */ private void getContent(NormalizedMessage nm, Message message) throws MessagingException { Exception e = message.getContent(Exception.class); if (e == null) { nm.setContent(message.getContent(Source.class)); } else if (e instanceof SoapFault) { SoapFault fault = (SoapFault) e; nm.setContent(fault.getDetails()); nm.setProperty(JbiConstants.SOAP_FAULT_CODE, fault.getCode()); nm.setProperty(JbiConstants.SOAP_FAULT_NODE, fault.getNode()); nm.setProperty(JbiConstants.SOAP_FAULT_REASON, fault.getReason()); nm.setProperty(JbiConstants.SOAP_FAULT_ROLE, fault.getRole()); nm.setProperty(JbiConstants.SOAP_FAULT_SUBCODE, fault.getSubcode()); } }
/** * Copies properties from one message to another that do not already exist * * @param from the message containing the properties * @param to the destination message where the properties are set */ protected void copyProperties(NormalizedMessage from, NormalizedMessage to) { for (String propertyName : (Set<String>) from.getPropertyNames()) { // Do not copy existing properties or transient properties if (to.getProperty(propertyName) == null && !PojoMarshaler.BODY.equals(propertyName)) { Object value = from.getProperty(propertyName); to.setProperty(propertyName, value); } } }
/** * Copy properties from JMS message to JBI message. * * @param message Received JMS message. * @param inMessage Created JBI message. * @throws JMSException If there is any problems with accessing to message * properties. */ @SuppressWarnings("unchecked") protected void copyPropertiesFromJMS(Message message, NormalizedMessage inMessage) throws JMSException { Enumeration<String> names = message.getPropertyNames(); while (names.hasMoreElements()) { String name = names.nextElement(); Object value = message.getObjectProperty(name); if (!isBlackListed(name)) { inMessage.setProperty(name, value); } } }
/** * Copies properties from one message to another that do not already exist * * @param from the message containing the properties * @param to the destination message where the properties are set */ protected void copyProperties(NormalizedMessage from, NormalizedMessage to) { for (String propertyName : (Set<String>) from.getPropertyNames()) { // Do not copy existing properties or transient properties if (to.getProperty(propertyName) == null && !PojoMarshaler.BODY.equals(propertyName)) { Object value = from.getProperty(propertyName); to.setProperty(propertyName, value); } } }
protected MessageExchange createExchange(HttpServletRequest request) throws Exception { Context ctx = createContext(request); request.setAttribute(Context.class.getName(), ctx); MessageExchange exchange = soapHelper.onReceive(ctx); NormalizedMessage inMessage = exchange.getMessage("in"); if (getConfiguration().isWantHeadersFromHttpIntoExchange()) { Map<String, String> requestMessageHeaders = getHeaders(request); if (supportAllHttpMethods){ requestMessageHeaders.put(HTTP_METHOD, request.getMethod()); } inMessage.setProperty(JbiConstants.PROTOCOL_HEADERS, requestMessageHeaders); } return exchange; }
public static void transfer(NormalizedMessage source, NormalizedMessage dest) throws MessagingException { dest.setContent(source.getContent()); for (Iterator it = source.getPropertyNames().iterator(); it.hasNext();) { String name = (String) it.next(); dest.setProperty(name, source.getProperty(name)); } for (Iterator it = source.getAttachmentNames().iterator(); it.hasNext();) { String name = (String) it.next(); dest.addAttachment(name, source.getAttachment(name)); } dest.setSecuritySubject(source.getSecuritySubject()); }
public static void transfer(NormalizedMessage source, NormalizedMessage dest) throws MessagingException { dest.setContent(source.getContent()); for (Iterator it = source.getPropertyNames().iterator(); it.hasNext();) { String name = (String) it.next(); dest.setProperty(name, source.getProperty(name)); } for (Iterator it = source.getAttachmentNames().iterator(); it.hasNext();) { String name = (String) it.next(); dest.addAttachment(name, source.getAttachment(name)); } dest.setSecuritySubject(source.getSecuritySubject()); }
private void toNMSWSAHeaders(NormalizedMessage normalizedMessage, Message soapMessage) { SoapMessage message = null; if (!(soapMessage instanceof SoapMessage)) { return; } else { message = (SoapMessage) soapMessage; } if (message.get(WSAUtils.WSA_HEADERS_INBOUND) != null) { normalizedMessage.setProperty(WSAUtils.WSA_HEADERS_INBOUND, WSAUtils.getAsMap((AddressingProperties) message .get(WSAUtils.WSA_HEADERS_INBOUND))); } }
protected void processFile(File file) throws Exception { InputStream stream = new BufferedInputStream(new FileInputStream(file)); InOnly exchange = getExchangeFactory().createInOnlyExchange(); configureExchangeTarget(exchange); NormalizedMessage message = exchange.createMessage(); exchange.setInMessage(message); marshaler.readMessage(exchange, message, stream, file.getCanonicalPath()); // sending the file itself along as a message property and holding on to // the stream we opened exchange.getInMessage().setProperty(FileComponent.FILE_PROPERTY, file); this.openExchanges.put(exchange.getExchangeId(), stream); send(exchange); }
/** * Sets the body of the message as a POJO * * @param message the message on which to set the body * @param body the POJO or DOMish model to set * @throws MessagingException */ public static void setBody(NormalizedMessage message, Object body) throws MessagingException { Source content = message.getContent(); if (content instanceof JavaSource) { JavaSource source = (JavaSource) content; source.setObject(body); } else if (message instanceof NormalizedMessageImpl) { ((NormalizedMessageImpl) message).setBody(body); } else { message.setProperty(PojoMarshaler.BODY, body); } }
public void copyFromCamelToJbi(Exchange exchange, MessageExchange messageExchange) throws MessagingException { // add Exchange properties to the MessageExchange without overwriting any existing properties copyPropertiesFromCamelToJbi(exchange, messageExchange); NormalizedMessage in = messageExchange.getMessage("in"); for (Map.Entry<String, Object> entry : exchange.getIn().getHeaders().entrySet()) { in.setProperty(entry.getKey(), entry.getValue()); } if (isOutCapable(messageExchange)) { if (exchange.hasOut()) { NormalizedMessage out = messageExchange.createMessage(); copyFromCamelToJbi(exchange.getOut(), out); messageExchange.setMessage(out, "out"); } else { //JBI MEP requires a reply and the Camel exchange failed to produce one -- echoing back the request NormalizedMessage out = messageExchange.createMessage(); copyFromCamelToJbi(exchange.getIn(), out); messageExchange.setMessage(out, "out"); } } }