Package org.jboss.soa.esb.message

Examples of org.jboss.soa.esb.message.Attachment


      this.paramType = paramType;
      this.attachmentParam = attachmentParam;
    }

    public Object getParam(Message message) throws MessageDeliverException {
      Attachment attachment = message.getAttachment();
     
      String attachPartName = AnnotationUtil.getAttachmentName(attachmentParam);
      if(attachPartName != null) {
        Object param = attachment.get(attachPartName);
        if(param != null && !paramType.isInstance(param)) {
          throw new MessageDeliverException("Named Attachment part '" + attachPartName + "' exists on ESB message but is not of type '" + paramType.getName() + "'.");
        }
        return param;
      } else {     
        for(String attachPartNameOnMessage : attachment.getNames()) {
          Object param = attachment.get(attachPartNameOnMessage);
          if(param != null && paramType.isInstance(param)) {
            return param;
          }
        }
      }
View Full Code Here


    Message msg = MessageFactory.getInstance().getMessage(
        MessageType.JAVA_SERIALIZED);

    assertEquals((msg != null), true);

    Attachment at = msg.getAttachment();

    assertEquals((msg != null), true);

    at.addItem(new ExampleObject(0)); // un-named
    at.addItemAt(0, new ExampleObject(0)); // un-named;

    try
    {
      at.addItem(new Object());

      fail();
    }
    catch (IllegalArgumentException ex)
    {
    }

    assertEquals(at.getUnnamedCount(), 2);

    assertEquals(at.get("foo"), null);

    at.put("foobar", new ExampleObject(1));

    assertEquals(at.getNamedCount(), 1);

    at.addItem(new ExampleObject(1));
    at.addItem(new ExampleObject(2));

    assertEquals((at.getNames() != null), true);

    assertEquals((at.removeItemAt(0) != null), true);

    at.replaceItemAt(0, new ExampleObject(2));

    int count = at.getUnnamedCount();

                ByteArrayOutputStream s = new ByteArrayOutputStream();
                ObjectOutputStream o = new ObjectOutputStream(s);

                o.writeObject(msg);
View Full Code Here

    Message msg = MessageFactory.getInstance().getMessage(
        MessageType.JBOSS_XML);

    assertEquals((msg != null), true);

    Attachment at = msg.getAttachment();

    assertEquals((msg != null), true);

    at.addItem(new ExampleObject(0)); // un-named
    at.addItemAt(0, new ExampleObject(0)); // un-named;

    try
    {
      at.addItem(new Object());

      fail();
    }
    catch (IllegalArgumentException ex)
    {
    }

    assertEquals(at.getUnnamedCount(), 2);

    assertEquals(at.get("foo"), null);

    at.put("foobar", new ExampleObject(1));

    assertEquals(at.getNamedCount(), 1);

    at.addItem(new ExampleObject(1));
    at.addItem(new ExampleObject(2));

    assertEquals((at.getNames() != null), true);

    assertEquals((at.removeItemAt(0) != null), true);

    at.replaceItemAt(0, new ExampleObject(2));

    int count = at.getUnnamedCount();

                final String documentAsString = (String)Util.serialize(msg) ;
                log.debug("Message looks like: " + documentAsString);
                final Message nImpl = Util.deserialize(documentAsString) ;
               
View Full Code Here

public class DeserializedValuesMessageUnitTest extends TestCase
{
    public void testOldSerializedAttachmentDeserialisation()
        throws Exception
    {
        final Attachment attachment = (Attachment)deserialise("old_attachment.ser") ;
        validateOldAttachment(attachment) ;
    }
View Full Code Here

    }
   
    public void testNewSerializedAttachmentDeserialisation()
        throws Exception
    {
        final Attachment attachment = (Attachment)deserialise("new_attachment.ser") ;
        validateNewAttachment(attachment) ;
    }
View Full Code Here

    public AggregatedMessageAssembler(ConfigTree config) {
    }

    public Message process(Message message) throws ActionProcessingException {
        Attachment attachments = message.getAttachment();
        int attachmentCount = attachments.getUnnamedCount();
        StringBuffer assemblyBuffer = new StringBuffer();

        for (int i = 0; i < attachmentCount; i++) {
            try {
                Message aggrMessage = Util.deserialize((Serializable) attachments.itemAt(i));
                String payload = aggrMessage.getBody().get().toString();
               
                assemblyBuffer.append("**** Payload from Message Attachment " + i + ":\n");
                assemblyBuffer.append(payload + "\n");
            } catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.jboss.soa.esb.message.Attachment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.