Search in sources :

Example 16 with Expires

use of org.apache.cxf.ws.rm.v200702.Expires in project cxf by apache.

the class ServantTest method verifyCreateSequenceExpiresSetAtBoth.

private void verifyCreateSequenceExpiresSetAtBoth(Servant servant, RMManager manager) throws SequenceFault {
    DestinationPolicyType dp = RMMANGER_FACTORY.createDestinationPolicyType();
    AcksPolicyType ap = RMMANGER_FACTORY.createAcksPolicyType();
    dp.setAcksPolicy(ap);
    dp.setSequenceExpiration(DURATION_SHORT);
    manager.setDestinationPolicy(dp);
    Expires expires = new Expires();
    expires.setValue(DURATION_VERY_SHORT);
    Message message = createTestCreateSequenceMessage(expires, null);
    CreateSequenceResponseType csr = (CreateSequenceResponseType) servant.createSequence(message);
    Expires expires2 = csr.getExpires();
    assertNotNull(expires2);
    assertEquals(DURATION_VERY_SHORT, expires2.getValue());
}
Also used : AcksPolicyType(org.apache.cxf.ws.rm.manager.AcksPolicyType) Message(org.apache.cxf.message.Message) DestinationPolicyType(org.apache.cxf.ws.rm.manager.DestinationPolicyType) Expires(org.apache.cxf.ws.rm.v200502.Expires) CreateSequenceResponseType(org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType)

Example 17 with Expires

use of org.apache.cxf.ws.rm.v200702.Expires in project cxf by apache.

the class ServantTest method verifyCreateSequenceExpiresSetAtSource.

private void verifyCreateSequenceExpiresSetAtSource(Servant servant, RMManager manager) throws SequenceFault {
    DestinationPolicyType dp = RMMANGER_FACTORY.createDestinationPolicyType();
    AcksPolicyType ap = RMMANGER_FACTORY.createAcksPolicyType();
    dp.setAcksPolicy(ap);
    manager.setDestinationPolicy(dp);
    Expires expires = new Expires();
    expires.setValue(DURATION_SHORT);
    Message message = createTestCreateSequenceMessage(expires, null);
    CreateSequenceResponseType csr = (CreateSequenceResponseType) servant.createSequence(message);
    Expires expires2 = csr.getExpires();
    assertNotNull(expires2);
    assertEquals(DURATION_SHORT, expires2.getValue());
}
Also used : AcksPolicyType(org.apache.cxf.ws.rm.manager.AcksPolicyType) Message(org.apache.cxf.message.Message) DestinationPolicyType(org.apache.cxf.ws.rm.manager.DestinationPolicyType) Expires(org.apache.cxf.ws.rm.v200502.Expires) CreateSequenceResponseType(org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType)

Example 18 with Expires

use of org.apache.cxf.ws.rm.v200702.Expires in project cxf by apache.

the class SourceSequenceTest method testSetExpires.

@Test
public void testSetExpires() {
    SourceSequence seq = new SourceSequence(id, ProtocolVariation.RM10WSA200408);
    Expires expires = factory.createExpires();
    seq.setExpires(expires);
    assertFalse(seq.isExpired());
    Duration d = DatatypeFactory.PT0S;
    expires.setValue(d);
    seq.setExpires(expires);
    try {
        Thread.sleep(1000);
    } catch (InterruptedException ex) {
        assertFalse(seq.isExpired());
    }
    d = DatatypeFactory.createDuration("PT1S");
    expires.setValue(d);
    seq.setExpires(expires);
    assertFalse(seq.isExpired());
    d = DatatypeFactory.createDuration("-PT1S");
    expires.setValue(d);
    seq.setExpires(expires);
    assertTrue(seq.isExpired());
}
Also used : Duration(javax.xml.datatype.Duration) Expires(org.apache.cxf.ws.rm.v200702.Expires) Test(org.junit.Test)

Example 19 with Expires

use of org.apache.cxf.ws.rm.v200702.Expires in project cxf by apache.

the class Proxy method createSequence.

public CreateSequenceResponseType createSequence(EndpointReferenceType defaultAcksTo, RelatesToType relatesTo, boolean isServer, final ProtocolVariation protocol, final Exchange exchange, Map<String, Object> context) throws RMException {
    this.sequenceContext = context;
    SourcePolicyType sp = reliableEndpoint.getManager().getSourcePolicy();
    CreateSequenceType create = new CreateSequenceType();
    String address = sp.getAcksTo();
    final EndpointReferenceType acksTo;
    if (null != address) {
        acksTo = RMUtils.createReference(address);
    } else {
        acksTo = defaultAcksTo;
    }
    create.setAcksTo(acksTo);
    Duration d = sp.getSequenceExpiration();
    if (null != d) {
        Expires expires = new Expires();
        expires.setValue(d);
        create.setExpires(expires);
    }
    if (sp.isIncludeOffer()) {
        OfferType offer = new OfferType();
        d = sp.getOfferedSequenceExpiration();
        if (null != d) {
            Expires expires = new Expires();
            expires.setValue(d);
            offer.setExpires(expires);
        }
        offer.setIdentifier(reliableEndpoint.getSource().generateSequenceIdentifier());
        offer.setEndpoint(acksTo);
        create.setOffer(offer);
        setOfferedIdentifier(offer);
    }
    InterfaceInfo ii = reliableEndpoint.getEndpoint(protocol).getEndpointInfo().getService().getInterface();
    EncoderDecoder codec = protocol.getCodec();
    RMConstants constants = codec.getConstants();
    final OperationInfo oi = isServer ? ii.getOperation(constants.getCreateSequenceOnewayOperationName()) : ii.getOperation(constants.getCreateSequenceOperationName());
    final Object send = codec.convertToSend(create);
    if (isServer) {
        LOG.fine("sending CreateSequenceRequest from server side");
        Runnable r = new Runnable() {

            public void run() {
                try {
                    invoke(oi, protocol, new Object[] { send }, null, exchange);
                } catch (RMException ex) {
                // already logged
                }
            }
        };
        Executor ex = reliableEndpoint.getApplicationEndpoint().getExecutor();
        if (ex == null) {
            ex = SynchronousExecutor.getInstance();
        }
        ex.execute(r);
        return null;
    }
    Object resp = invoke(oi, protocol, new Object[] { send }, context, exchange);
    return codec.convertReceivedCreateSequenceResponse(resp);
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) Duration(javax.xml.datatype.Duration) OfferType(org.apache.cxf.ws.rm.v200702.OfferType) Executor(java.util.concurrent.Executor) SynchronousExecutor(org.apache.cxf.workqueue.SynchronousExecutor) CreateSequenceType(org.apache.cxf.ws.rm.v200702.CreateSequenceType) SourcePolicyType(org.apache.cxf.ws.rm.manager.SourcePolicyType) Expires(org.apache.cxf.ws.rm.v200702.Expires) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo)

Aggregations

Expires (org.oasis_open.docs.ws_tx.wscoor._2006._06.Expires)9 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)7 CoordinationContext (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext)7 InvalidCreateParametersException (com.arjuna.wsc.InvalidCreateParametersException)6 CoordinationContextType (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType)6 ServiceRegistry (com.arjuna.webservices11.ServiceRegistry)5 Message (org.apache.cxf.message.Message)5 DestinationPolicyType (org.apache.cxf.ws.rm.manager.DestinationPolicyType)5 Expires (org.apache.cxf.ws.rm.v200702.Expires)5 NoActivityException (com.arjuna.mw.wsas.exceptions.NoActivityException)4 SystemException (com.arjuna.mw.wsas.exceptions.SystemException)4 InstanceIdentifier (com.arjuna.webservices11.wsarj.InstanceIdentifier)4 InvalidProtocolException (com.arjuna.wsc.InvalidProtocolException)4 AcksPolicyType (org.apache.cxf.ws.rm.manager.AcksPolicyType)4 CreateSequenceResponseType (org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType)4 Expires (org.apache.cxf.ws.rm.v200502.Expires)4 Duration (javax.xml.datatype.Duration)3 Test (org.junit.Test)3 SubordinateBACoordinator (com.arjuna.mwlabs.wscf.model.sagas.arjunacore.subordinate.SubordinateBACoordinator)2 SubordinateATCoordinator (com.arjuna.mwlabs.wscf.model.twophase.arjunacore.subordinate.SubordinateATCoordinator)2