Package org.objectweb.celtix.ws.rm

Examples of org.objectweb.celtix.ws.rm.RMProperties


     * Encode the current RM properties  in protocol-specific headers.
     *
     * @param context the message context.
     */
    private void encode(SOAPMessageContext context) {
        RMProperties rmps = RMContextUtils.retrieveRMProperties(context, true);
        if (null == rmps) {
            // nothing to encode
            return;
        }
        SOAPMessage message = context.getMessage();
        try {
            SOAPEnvelope env = message.getSOAPPart().getEnvelope();
            SOAPHeader header = env.getHeader() != null
                                ? env.getHeader()
                                : env.addHeader();
                               
            discardRMHeaders(header);
            header.addNamespaceDeclaration(Names.WSRM_NAMESPACE_PREFIX,
                                           Names.WSRM_NAMESPACE_NAME);
            Marshaller marshaller = getJAXBContext().createMarshaller();
            marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
          
            SequenceType seq = rmps.getSequence();
            if (null != seq) {
                encodeProperty(seq,
                               Names.WSRM_SEQUENCE_QNAME,
                               SequenceType.class,
                               header,
                               marshaller);
            }
            Collection<SequenceAcknowledgement> acks = rmps.getAcks();
            if (null != acks) {
                for (SequenceAcknowledgement ack : acks) {
                    encodeProperty(ack,
                                   Names.WSRM_SEQUENCE_ACK_QNAME,
                                   SequenceAcknowledgement.class,
                                   header,
                                   marshaller);
                }
            }
            Collection<AckRequestedType> requested = rmps.getAcksRequested();
            if (null != requested) {
                for (AckRequestedType ar : requested) {
                    encodeProperty(ar,
                                   Names.WSRM_ACK_REQUESTED_QNAME,
                                   AckRequestedType.class,
View Full Code Here


     * @param the decoded MAPs
     * @exception SOAPFaultException if decoded MAPs are invalid
     */
    private void decode(SOAPMessageContext context) {
        SOAPMessage message = context.getMessage();
        RMProperties rmps = unmarshalRMProperties(message);
        RMContextUtils.storeRMProperties(context, rmps, false);
    }
View Full Code Here

     *
     * @param message the SOAP message
     * @return the RM properties
     */
    public RMProperties unmarshalRMProperties(SOAPMessage message) {
        RMProperties rmps = new RMPropertiesImpl();
       
        try {
            Collection<SequenceAcknowledgement> acks = new ArrayList<SequenceAcknowledgement>();
            Collection<AckRequestedType> requested = new ArrayList<AckRequestedType>();          
           
            SOAPEnvelope env = message.getSOAPPart().getEnvelope();
            SOAPHeader header = env.getHeader();
           
            if (header != null) {
                Unmarshaller unmarshaller =
                    getJAXBContext().createUnmarshaller();
                Iterator headerElements = header.examineAllHeaderElements();
                while (headerElements.hasNext()) {
                    SOAPHeaderElement headerElement =
                        (SOAPHeaderElement)headerElements.next();
                    Name headerName = headerElement.getElementName();
                    String localName = headerName.getLocalName();
                    if (Names.WSRM_NAMESPACE_NAME.equals(headerName.getURI())) {
                        LOG.log(Level.INFO, "decoding RM header {0}", localName);
                        if (Names.WSRM_SEQUENCE_NAME.equals(localName)) {
                            SequenceType s = decodeProperty(SequenceType.class,
                                                            headerElement,
                                                            unmarshaller);
                           
                            rmps.setSequence(s);
                        } else if (Names.WSRM_SEQUENCE_ACK_NAME.equals(localName)) {
                            SequenceAcknowledgement ack = decodeProperty(SequenceAcknowledgement.class,
                                                            headerElement,
                                                            unmarshaller);
                            acks.add(ack);                           
                        } else if (Names.WSRM_ACK_REQUESTED_NAME.equals(localName)) {
                            AckRequestedType ar = decodeProperty(AckRequestedType.class,
                                                            headerElement,
                                                            unmarshaller);
                            requested.add(ar);
                        }
                    }
                }
                if (acks.size() > 0) {
                    rmps.setAcks(acks);
                }
                if (requested.size() > 0) {
                    rmps.setAcksRequested(requested);
                }
            }
        } catch (SOAPException se) {
            LOG.log(Level.WARNING, "SOAP_HEADER_DECODE_FAILURE_MSG", se);
        } catch (JAXBException je) {
View Full Code Here

    }
   
    private SequenceType setUpSequenceType(ObjectMessageContext context,
                                           String sid,
                                           BigInteger messageNumber) {
        RMProperties rmps = control.createMock(RMProperties.class);
        if (context != null) {
            context.get(RM_PROPERTIES_OUTBOUND);
            EasyMock.expectLastCall().andReturn(rmps);
        }
        properties.add(rmps);
        SequenceType sequence = control.createMock(SequenceType.class);
        if (context != null) {
            rmps.getSequence();
            EasyMock.expectLastCall().andReturn(sequence);
        }
        if (messageNumber != null) {
            sequence.getMessageNumber();
            EasyMock.expectLastCall().andReturn(messageNumber);
View Full Code Here

        // one sequence header

        context = setupOutboundContext();
       
        RMProperties rmps = RMContextUtils.retrieveRMProperties(context, true);    
        rmps.setSequence(s1);
       
        assertTrue("expected dispatch to proceed", codec.handleMessage(context));
        verifyHeaders(context, new String[] {Names.WSRM_SEQUENCE_NAME});
        codec.close(context);

        // one acknowledgment header

        context = setupOutboundContext();
        rmps = RMContextUtils.retrieveRMProperties(context, true)
       
        Collection<SequenceAcknowledgement> acks = new ArrayList<SequenceAcknowledgement>();
        acks.add(ack1);
        rmps.setAcks(acks);
        assertTrue("expected dispatch to proceed", codec.handleMessage(context));
        verifyHeaders(context, new String[] {Names.WSRM_SEQUENCE_ACK_NAME});

        // two acknowledgment headers

        context = setupOutboundContext();
        rmps = RMContextUtils.retrieveRMProperties(context, true);
       
        acks.add(ack2);
        rmps.setAcks(acks);
        assertTrue("expected dispatch to proceed", codec.handleMessage(context));
        verifyHeaders(context, new String[] {Names.WSRM_SEQUENCE_ACK_NAME, Names.WSRM_SEQUENCE_ACK_NAME});

        // one ack requested header

        context = setupOutboundContext();
        rmps = RMContextUtils.retrieveRMProperties(context, true);
       
        Collection<AckRequestedType> requested = new ArrayList<AckRequestedType>();
        requested.add(ar1);
        rmps.setAcksRequested(requested);
        assertTrue("expected dispatch to proceed", codec.handleMessage(context));
        verifyHeaders(context, new String[] {Names.WSRM_ACK_REQUESTED_NAME});

        // two ack requested headers

        context = setupOutboundContext();
        rmps = RMContextUtils.retrieveRMProperties(context, true);
       
        requested.add(ar2);
        rmps.setAcksRequested(requested);
        assertTrue("expected dispatch to proceed", codec.handleMessage(context));
        verifyHeaders(context, new String[] {Names.WSRM_ACK_REQUESTED_NAME, Names.WSRM_ACK_REQUESTED_NAME});
    }
View Full Code Here

        sb = new SOAPBindingImpl(false);
        ObjectMessageContext objectCtx = new ObjectMessageContextImpl();
        SOAPMessageContext context = (SOAPMessageContext)sb.createBindingMessageContext(objectCtx);
        sb.read(istreamCtx, context);
        assertTrue(codec.handleMessage(context));
        RMProperties rmps = RMContextUtils.retrieveRMProperties(context, false);
        SequenceType st = rmps.getSequence();
        assertNotNull(st);
        assertEquals(st.getIdentifier().getValue(), SEQ_IDENTIFIER);
        assertEquals(st.getMessageNumber(), MSG1_MESSAGE_NUMBER);
       
        assertNull(rmps.getAcks());
        assertNull(rmps.getAcksRequested());

    }
View Full Code Here

        ObjectMessageContext objectCtx = new ObjectMessageContextImpl();
        SOAPMessageContext context = (SOAPMessageContext)sb.createBindingMessageContext(objectCtx);
        sb.read(istreamCtx, context);
       
        assertTrue(codec.handleMessage(context));
        RMProperties rmps = RMContextUtils.retrieveRMProperties(context, false);
        Collection<SequenceAcknowledgement> acks = rmps.getAcks();
        assertNotNull(acks);
        assertEquals(1, acks.size());
        SequenceAcknowledgement ack = acks.iterator().next();
        assertNotNull(ack);
        assertEquals(ack.getIdentifier().getValue(), SEQ_IDENTIFIER);
        assertEquals(2, ack.getAcknowledgementRange().size());
        assertNull(rmps.getSequence());
        assertNull(rmps.getAcksRequested());
    }
View Full Code Here

        ObjectMessageContext objectCtx = new ObjectMessageContextImpl();
        SOAPMessageContext context = (SOAPMessageContext)sb.createBindingMessageContext(objectCtx);
        sb.read(istreamCtx, context);
       
        assertTrue(codec.handleMessage(context));
        RMProperties rmps = RMContextUtils.retrieveRMProperties(context, false);
        Collection<AckRequestedType> requested = rmps.getAcksRequested();
        assertNotNull(requested);
        assertEquals(1, requested.size());
        AckRequestedType ar = requested.iterator().next();
        assertNotNull(ar);
        assertEquals(ar.getIdentifier().getValue(), SEQ_IDENTIFIER);

        SequenceType s = rmps.getSequence();
        assertNotNull(s);
        assertEquals(s.getIdentifier().getValue(), SEQ_IDENTIFIER);
        assertEquals(s.getMessageNumber(), MSG2_MESSAGE_NUMBER);

        assertNull(rmps.getAcks());
    }
View Full Code Here

     */
    protected final Resender getDefaultResender() {  
        return new Resender() {
            public void resend(ObjectMessageContext context,
                               boolean requestAcknowledge) {
                RMProperties properties =
                    RMContextUtils.retrieveRMProperties(context, true);
                SequenceType st = properties.getSequence();
                if (st != null) {
                    LOG.log(Level.INFO, "RESEND_MSG", st.getMessageNumber());
                }
                try {
                    refreshMAPs(context);
View Full Code Here

     *
     * @param context the message context
     * @param requestAcknowledge true if an AckRequested header should be included
     */
    private void refreshRMProperties(MessageContext context, boolean requestAcknowledge) {
        RMProperties properties =
            RMContextUtils.retrieveRMProperties(context, true);
        List<AckRequestedType> requests = null;
        if (requestAcknowledge) {
            requests = new ArrayList<AckRequestedType>();
            requests.add(RMUtils.getWSRMFactory().createAckRequestedType());
            Identifier id = properties.getSequence().getIdentifier();
            requests.get(0).setIdentifier(id);
        }
        properties.setAcksRequested(requests);
    }
View Full Code Here

TOP

Related Classes of org.objectweb.celtix.ws.rm.RMProperties

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.