Search in sources :

Example 6 with CreateSequenceResponseType

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

the class VersionTransformer method convert.

/**
 * Convert 200502 wsrm:CreateSequenceResponseType with 200408 WS-Addressing namespace to internal form.
 *
 * @param exposed (may be <code>null</code>)
 * @return converted (<code>null</code> if exposed is <code>null</code>)
 */
public static CreateSequenceResponseType convert(org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType exposed) {
    if (exposed == null) {
        return null;
    }
    CreateSequenceResponseType internal = new CreateSequenceResponseType();
    internal.setAccept(convert(exposed.getAccept()));
    internal.setExpires(convert(exposed.getExpires()));
    internal.setIdentifier(convert(exposed.getIdentifier()));
    addAll(exposed.getAny(), internal.getAny());
    putAll(exposed.getOtherAttributes(), internal.getOtherAttributes());
    return internal;
}
Also used : CreateSequenceResponseType(org.apache.cxf.ws.rm.v200702.CreateSequenceResponseType)

Example 7 with CreateSequenceResponseType

use of org.apache.cxf.ws.rm.v200702.CreateSequenceResponseType 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 CreateSequenceResponseType

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

the class Servant method createSequenceResponse.

public void createSequenceResponse(CreateSequenceResponseType createResponse, ProtocolVariation protocol) {
    LOG.fine("Creating sequence response");
    SourceSequence seq = new SourceSequence(createResponse.getIdentifier(), protocol);
    seq.setExpires(createResponse.getExpires());
    Source source = reliableEndpoint.getSource();
    source.addSequence(seq);
    // the incoming sequence ID is either used as the requestor sequence
    // (signalled by null) or associated with a corresponding sequence
    // identifier
    source.setCurrent(clearUnattachedIdentifier(), seq);
    // if a sequence was offered and accepted, then we can add this to
    // to the local destination sequence list, otherwise we have to wait for
    // and incoming CreateSequence request
    Identifier offeredId = reliableEndpoint.getProxy().getOfferedIdentifier();
    if (null != offeredId) {
        AcceptType accept = createResponse.getAccept();
        if (accept != null) {
            Destination dest = reliableEndpoint.getDestination();
            String address = accept.getAcksTo().getAddress().getValue();
            if (!RMUtils.getAddressingConstants().getNoneURI().equals(address)) {
                DestinationSequence ds = new DestinationSequence(offeredId, accept.getAcksTo(), dest, protocol);
                dest.addSequence(ds);
            }
        }
    }
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) AcceptType(org.apache.cxf.ws.rm.v200702.AcceptType)

Example 9 with CreateSequenceResponseType

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

the class Servant method invoke.

public Object invoke(Exchange exchange, Object o) {
    LOG.fine("Invoking on RM Endpoint");
    final ProtocolVariation protocol = RMContextUtils.getProtocolVariation(exchange.getInMessage());
    OperationInfo oi = exchange.getBindingOperationInfo().getOperationInfo();
    if (null == oi) {
        LOG.fine("No operation info.");
        return null;
    }
    if (RM10Constants.INSTANCE.getCreateSequenceOperationName().equals(oi.getName()) || RM11Constants.INSTANCE.getCreateSequenceOperationName().equals(oi.getName()) || RM10Constants.INSTANCE.getCreateSequenceOnewayOperationName().equals(oi.getName()) || RM11Constants.INSTANCE.getCreateSequenceOnewayOperationName().equals(oi.getName())) {
        try {
            return Collections.singletonList(createSequence(exchange.getInMessage()));
        } catch (RuntimeException ex) {
            LOG.log(Level.WARNING, "Sequence creation rejected", ex);
            SequenceFault sf = new SequenceFaultFactory(protocol.getConstants()).createCreateSequenceRefusedFault();
            Endpoint e = exchange.getEndpoint();
            Binding b = null == e ? null : e.getBinding();
            if (null != b) {
                RMManager m = reliableEndpoint.getManager();
                LOG.fine("Manager: " + m);
                BindingFaultFactory bff = m.getBindingFaultFactory(b);
                Fault f = bff.createFault(sf, exchange.getInMessage());
                // log with warning instead sever, as this may happen for some delayed messages
                LogUtils.log(LOG, Level.WARNING, "SEQ_FAULT_MSG", bff.toString(f));
                throw f;
            }
            throw new Fault(sf);
        }
    } else if (RM10Constants.INSTANCE.getCreateSequenceResponseOnewayOperationName().equals(oi.getName()) || RM11Constants.INSTANCE.getCreateSequenceResponseOnewayOperationName().equals(oi.getName())) {
        EncoderDecoder codec = protocol.getCodec();
        CreateSequenceResponseType createResponse = codec.convertReceivedCreateSequenceResponse(getParameter(exchange.getInMessage()));
        createSequenceResponse(createResponse, protocol);
    } else if (RM10Constants.INSTANCE.getTerminateSequenceOperationName().equals(oi.getName()) || RM11Constants.INSTANCE.getTerminateSequenceOperationName().equals(oi.getName())) {
        Object tsr = terminateSequence(exchange.getInMessage());
        if (tsr != null) {
            return Collections.singletonList(tsr);
        }
    } else if (RM11Constants.INSTANCE.getCloseSequenceOperationName().equals(oi.getName())) {
        return Collections.singletonList(closeSequence(exchange.getInMessage()));
    }
    return null;
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) Binding(org.apache.cxf.binding.Binding) Fault(org.apache.cxf.interceptor.Fault) CreateSequenceResponseType(org.apache.cxf.ws.rm.v200702.CreateSequenceResponseType) Endpoint(org.apache.cxf.endpoint.Endpoint)

Example 10 with CreateSequenceResponseType

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

the class VersionTransformer method convert.

/**
 * Convert 200502 wsrm:CreateSequenceResponseType with 200508 WS-Addressing namespace to internal form.
 *
 * @param exposed (may be <code>null</code>)
 * @return converted (<code>null</code> if exposed is <code>null</code>)
 */
public static CreateSequenceResponseType convert(org.apache.cxf.ws.rm.v200502wsa15.CreateSequenceResponseType exposed) {
    if (exposed == null) {
        return null;
    }
    CreateSequenceResponseType internal = new CreateSequenceResponseType();
    internal.setAccept(convert(exposed.getAccept()));
    internal.setExpires(convert(exposed.getExpires()));
    internal.setIdentifier(convert(exposed.getIdentifier()));
    addAll(exposed.getAny(), internal.getAny());
    putAll(exposed.getOtherAttributes(), internal.getOtherAttributes());
    return internal;
}
Also used : CreateSequenceResponseType(org.apache.cxf.ws.rm.v200702.CreateSequenceResponseType)

Aggregations

Message (org.apache.cxf.message.Message)8 CreateSequenceResponseType (org.apache.cxf.ws.rm.v200702.CreateSequenceResponseType)7 DestinationPolicyType (org.apache.cxf.ws.rm.manager.DestinationPolicyType)5 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)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 Endpoint (org.apache.cxf.endpoint.Endpoint)3 OperationInfo (org.apache.cxf.service.model.OperationInfo)3 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)3 Identifier (org.apache.cxf.ws.rm.v200702.Identifier)3 Method (java.lang.reflect.Method)2 HashMap (java.util.HashMap)2 Exchange (org.apache.cxf.message.Exchange)2 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)2 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)2 InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)2 AttributedURIType (org.apache.cxf.ws.addressing.AttributedURIType)2 RelatesToType (org.apache.cxf.ws.addressing.RelatesToType)2