Search in sources :

Example 6 with Expires

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

the class VersionTransformer method convert.

/**
 * Convert 200502 Expires with 200408 WS-Addressing namespace to internal form.
 *
 * @param exposed (may be <code>null</code>)
 * @return converted (<code>null</code> if internal is <code>null</code>)
 */
public static Expires convert(org.apache.cxf.ws.rm.v200502.Expires exposed) {
    if (exposed == null) {
        return null;
    }
    Expires internal = new Expires();
    internal.setValue(exposed.getValue());
    return internal;
}
Also used : Expires(org.apache.cxf.ws.rm.v200702.Expires)

Example 7 with Expires

use of org.apache.cxf.ws.rm.v200502.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();
    EndpointReferenceType acksTo = null;
    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)

Example 8 with Expires

use of org.apache.cxf.ws.rm.v200502.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 9 with Expires

use of org.apache.cxf.ws.rm.v200502.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 10 with Expires

use of org.apache.cxf.ws.rm.v200502.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);
    assertTrue(!seq.isExpired());
    Duration d = DatatypeFactory.PT0S;
    expires.setValue(d);
    seq.setExpires(expires);
    try {
        Thread.sleep(1000);
    } catch (InterruptedException ex) {
        assertTrue(!seq.isExpired());
    }
    d = DatatypeFactory.createDuration("PT1S");
    expires.setValue(d);
    seq.setExpires(expires);
    assertTrue(!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)

Aggregations

Message (org.apache.cxf.message.Message)6 DestinationPolicyType (org.apache.cxf.ws.rm.manager.DestinationPolicyType)5 Expires (org.apache.cxf.ws.rm.v200702.Expires)5 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 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)2 CreateSequenceType (org.apache.cxf.ws.rm.v200702.CreateSequenceType)2 OfferType (org.apache.cxf.ws.rm.v200702.OfferType)2 Executor (java.util.concurrent.Executor)1 Exchange (org.apache.cxf.message.Exchange)1 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)1 MessageContentsList (org.apache.cxf.message.MessageContentsList)1 MessageImpl (org.apache.cxf.message.MessageImpl)1 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)1 InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)1 OperationInfo (org.apache.cxf.service.model.OperationInfo)1 SynchronousExecutor (org.apache.cxf.workqueue.SynchronousExecutor)1 AttributedURIType (org.apache.cxf.ws.addressing.AttributedURIType)1