public void handleMessage(Message inMessage) throws Fault { inMessage.getExchange().put("com.example.myKey", myCustomObject); }
final Message msg = new MimeMessage(session); msg.setFrom(new InternetAddress(senderAddress, senderDisplayName)); msg.addRecipient(Message.RecipientType.TO, new InternetAddress(m.getRecipient(), m.getRecipientDisplayName())); msg.setSubject(m.getSubject()); // Unformatted text version final MimeBodyPart textPart = new MimeBodyPart(); textPart.setContent(m.getText(), "text/plain"); // HTML version final MimeBodyPart htmlPart = new MimeBodyPart(); htmlPart.setContent(m.getHtml(), "text/html"); // Create the Multipart. Add BodyParts to it. final Multipart mp = new MimeMultipart("alternative"); mp.addBodyPart(textPart); mp.addBodyPart(htmlPart); // Set Multipart as the message's content msg.setContent(mp); LOGGER.log(Level.FINEST, "Sending email {0}", m); Transport.send(msg);
List<File> attachments = new ArrayList<File>(); for (Message message : temp) { Multipart multipart = (Multipart) message.getContent(); // System.out.println(multipart.getCount()); for (int i = 0; i < multipart.getCount(); i++) { BodyPart bodyPart = multipart.getBodyPart(i); if(!Part.ATTACHMENT.equalsIgnoreCase(bodyPart.getDisposition()) && !StringUtils.isNotBlank(bodyPart.getFileName())) { continue; // dealing with attachments only } InputStream is = bodyPart.getInputStream(); File f = new File("/tmp/" + bodyPart.getFileName()); FileOutputStream fos = new FileOutputStream(f); byte[] buf = new byte[4096]; int bytesRead; while((bytesRead = is.read(buf))!=-1) { fos.write(buf, 0, bytesRead); } fos.close(); attachments.add(f); } }
protected void propagateConduit(Exchange exchange, Message in) { if (exchange != null) { Message out = exchange.getOutMessage(); if (out != null) { in.put(Conduit.class, out.get(Conduit.class)); } } }
private void updateClientPolicy() { if (!clientSidePolicyCalced) { //do no spend time on building Message and Exchange (which basically //are ConcurrentHashMap instances) if the policy is already available Message m = new MessageImpl(); m.setExchange(new ExchangeImpl()); m.getExchange().put(EndpointInfo.class, this.endpointInfo); updateClientPolicy(m); } }
private void changeToOneway(Exchange exchange) { exchange.setOneWay(true); exchange.setOutMessage(null); javax.servlet.http.HttpServletResponse httpresp = (javax.servlet.http.HttpServletResponse)exchange.getInMessage(). get("HTTP.RESPONSE"); if (httpresp != null) { httpresp.setStatus(202); } }
private Message createResponseMessage(Exchange exchange) { if (exchange == null) { return null; } Message m = exchange.getOutMessage(); if (m == null && !exchange.isOneWay()) { Endpoint ep = exchange.getEndpoint(); m = new MessageImpl(); m.setExchange(exchange); m = ep.getBinding().createMessage(m); exchange.setOutMessage(m); } return m; }
protected void updateMessageForSuspend() { inMessage.getExchange().getInMessage().getInterceptorChain().suspend(); } public void redispatch() {
private boolean isResponseRedirected(Message outMessage) { Exchange exchange = outMessage.getExchange(); return exchange != null && Boolean.TRUE.equals(exchange.get(REQUEST_REDIRECTED)); }
/** * @param message the message under consideration * @return true iff the message has been marked as oneway */ protected final boolean isOneWay(Message message) { Exchange ex = message.getExchange(); return ex == null ? false : ex.isOneWay(); }
private void doDataSource(final Message message) { MessageContentsList list = (MessageContentsList)message.getContent(List.class); //reconstitute all the parts into a Mime data source if (message.getAttachments() != null && !message.getAttachments().isEmpty() && list != null && !list.isEmpty() && list.get(0) instanceof DataSource) { list.set(0, new MultiPartDataSource(message, (DataSource)list.get(0))); } }
private boolean doProcessResponse(Message message, int responseCode) { // 1. Not oneWay if (!isOneway(message.getExchange())) { return true; } // 2. Robust OneWays could have a fault return responseCode == 500 && MessageUtils.getContextualBoolean(message, Message.ROBUST_ONEWAY, false); }
protected final boolean isOutbound() { return message != null && exchange != null && (message == exchange.getOutMessage() || message == exchange.getOutFaultMessage()); }
message.setFrom(new InternetAddress("from.mail.id@gmail.com")); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("to.mail.id@gmail.com")); message.setSubject("Testing Subject"); message.setText("PFA"); multipart.addBodyPart(messageBodyPart); message.setContent(multipart);
/** * This predicate returns true if the exchange indicates * a oneway MEP. * * @param exchange The exchange in question */ private boolean isOneway(Exchange exchange) { return exchange != null && exchange.isOneWay(); }
private static BindingOperationInfo getBindingOperationInfo(Exchange exchange) { if (exchange != null && exchange.getBindingOperationInfo() != null) { return exchange.getBindingOperationInfo(); } return null; }
/** {@inheritDoc}*/ public Continuation getContinuation() { if (inMessage.getExchange().isOneWay()) { return null; } if (continuation == null) { continuation = IS_31 ? new Servlet31Continuation() : new Servlet3Continuation(); } else { continuation.startAsyncAgain(); } return continuation; }
public void handleMessage(Message outMessage) throws Fault { MyCustomObject obj = (MyCustomObject)outMessage.getExchange().get("com.example.myKey"); }
private boolean isOutbound(T message, Exchange ex) { return message == ex.getOutMessage() || message == ex.getOutFaultMessage(); }
public WrappedMessageContext(Message m, Scope defScope) { this(m, m.getExchange(), defScope); } public WrappedMessageContext(Map<String, Object> m, Exchange ex, Scope defScope) {