Search in sources :

Example 1 with RMManager

use of org.apache.cxf.ws.rm.RMManager in project cxf by apache.

the class RMFeature method initializeProvider.

@Override
protected void initializeProvider(InterceptorProvider provider, Bus bus) {
    RMManager manager = bus.getExtension(RMManager.class);
    if (null != rmAssertion) {
        manager.setRMAssertion(rmAssertion);
    }
    if (null != deliveryAssurance) {
        manager.setDeliveryAssurance(deliveryAssurance);
    }
    if (null != sourcePolicy) {
        manager.setSourcePolicy(sourcePolicy);
    }
    if (null != destinationPolicy) {
        manager.setDestinationPolicy(destinationPolicy);
    }
    if (null != store) {
        manager.setStore(store);
    }
    if (null != rmNamespace) {
        manager.getConfiguration().setRMNamespace(rmNamespace);
    }
    if (null != rm10AddressingNamespace) {
        manager.getConfiguration().setRM10AddressingNamespace(rm10AddressingNamespace.getUri());
    }
    rmLogicalIn.setBus(bus);
    rmLogicalOut.setBus(bus);
    rmDelivery.setBus(bus);
    rmCaptureIn.setBus(bus);
    rmCaptureOut.setBus(bus);
    provider.getInInterceptors().add(rmLogicalIn);
    provider.getInInterceptors().add(rmInCodec);
    provider.getInInterceptors().add(rmDelivery);
    provider.getInInterceptors().add(rmCaptureIn);
    provider.getOutInterceptors().add(rmLogicalOut);
    provider.getOutInterceptors().add(rmOutCodec);
    provider.getOutInterceptors().add(rmCaptureOut);
    provider.getInFaultInterceptors().add(rmLogicalIn);
    provider.getInFaultInterceptors().add(rmInCodec);
    provider.getInFaultInterceptors().add(rmDelivery);
    provider.getOutFaultInterceptors().add(rmLogicalOut);
    provider.getOutFaultInterceptors().add(rmOutCodec);
    provider.getOutFaultInterceptors().add(rmCaptureOut);
}
Also used : RMManager(org.apache.cxf.ws.rm.RMManager)

Example 2 with RMManager

use of org.apache.cxf.ws.rm.RMManager in project cxf by apache.

the class RMSoapInInterceptor method updateServiceModelInfo.

/**
 * When invoked inbound, check if the action indicates that this is one of the
 * RM protocol messages (CreateSequence, CreateSequenceResponse, TerminateSequence)
 * and if so, replace references to the application service model with references to
 * the RM service model.
 * The addressing protocol handler must have extracted the action beforehand.
 * @see org.apache.cxf.transport.ChainInitiationObserver
 *
 * @param message the message
 */
private void updateServiceModelInfo(SoapMessage message) throws Fault {
    AddressingProperties maps = ContextUtils.retrieveMAPs(message, false, false, false);
    AttributedURIType actionURI = null == maps ? null : maps.getAction();
    String action = null == actionURI ? null : actionURI.getValue().trim();
    LOG.fine("action: " + action);
    RMConstants consts;
    if (RM10Constants.ACTIONS.contains(action)) {
        consts = RM10Constants.INSTANCE;
    } else if (RM11Constants.ACTIONS.contains(action)) {
        consts = RM11Constants.INSTANCE;
    } else {
        return;
    }
    RMProperties rmps = RMContextUtils.retrieveRMProperties(message, false);
    rmps.exposeAs(consts.getWSRMNamespace());
    ProtocolVariation protocol = ProtocolVariation.findVariant(consts.getWSRMNamespace(), maps.getNamespaceURI());
    LOG.info("Updating service model info in exchange");
    RMManager manager = getManager(message);
    assert manager != null;
    RMEndpoint rme = null;
    try {
        rme = manager.getReliableEndpoint(message);
    } catch (RMException e) {
        throw new SoapFault(new org.apache.cxf.common.i18n.Message("CANNOT_PROCESS", LOG), e, message.getVersion().getSender());
    }
    Exchange exchange = message.getExchange();
    Endpoint ep = rme.getEndpoint(protocol);
    exchange.put(Endpoint.class, ep);
    exchange.put(Service.class, ep.getService());
    exchange.put(Binding.class, ep.getBinding());
    // Also set BindingOperationInfo as some operations (SequenceAcknowledgment) have
    // neither in nor out messages, and thus the WrappedInInterceptor cannot
    // determine the operation name.
    BindingInfo bi = ep.getEndpointInfo().getBinding();
    BindingOperationInfo boi = null;
    boolean isOneway = true;
    if (consts.getCreateSequenceAction().equals(action)) {
        if (RMContextUtils.isServerSide(message)) {
            boi = bi.getOperation(consts.getCreateSequenceOperationName());
            isOneway = false;
        } else {
            boi = bi.getOperation(consts.getCreateSequenceOnewayOperationName());
        }
    } else if (consts.getCreateSequenceResponseAction().equals(action)) {
        if (RMContextUtils.isServerSide(message)) {
            boi = bi.getOperation(consts.getCreateSequenceResponseOnewayOperationName());
        } else {
            boi = bi.getOperation(consts.getCreateSequenceOperationName());
            isOneway = false;
        }
    } else if (consts.getSequenceAckAction().equals(action)) {
        boi = bi.getOperation(consts.getSequenceAckOperationName());
    } else if (consts.getAckRequestedAction().equals(action)) {
        boi = bi.getOperation(consts.getAckRequestedOperationName());
    } else if (consts.getTerminateSequenceAction().equals(action)) {
        boi = bi.getOperation(consts.getTerminateSequenceOperationName());
    } else if (RM11Constants.INSTANCE.getTerminateSequenceResponseAction().equals(action)) {
        // TODO add server-side TSR handling
        boi = bi.getOperation(RM11Constants.INSTANCE.getTerminateSequenceOperationName());
        isOneway = false;
    } else if (consts.getCloseSequenceAction().equals(action)) {
        boi = bi.getOperation(consts.getCloseSequenceOperationName());
    } else if (RM11Constants.INSTANCE.getCloseSequenceResponseAction().equals(action)) {
        boi = bi.getOperation(RM11Constants.INSTANCE.getCloseSequenceOperationName());
        isOneway = false;
    }
    // make sure the binding information has been set
    if (boi == null) {
        LOG.fine("No BindingInfo for action " + action);
    } else {
        exchange.put(BindingOperationInfo.class, boi);
        exchange.setOneWay(isOneway);
    }
    if (!consts.getCreateSequenceResponseAction().equals(action) && !consts.getSequenceAckAction().equals(action) && !RM11Constants.INSTANCE.getTerminateSequenceResponseAction().equals(action) && !RM11Constants.INSTANCE.getCloseSequenceResponseAction().equals(action)) {
        LOG.fine("Changing requestor role from " + message.get(Message.REQUESTOR_ROLE) + " to false");
        Object originalRequestorRole = message.get(Message.REQUESTOR_ROLE);
        if (null != originalRequestorRole) {
            message.put(RMMessageConstants.ORIGINAL_REQUESTOR_ROLE, originalRequestorRole);
        }
        message.put(Message.REQUESTOR_ROLE, Boolean.FALSE);
    }
    // replace WrappedInInterceptor with BareInInterceptor if necessary
    // as RM protocol messages use parameter style BARE
    InterceptorChain chain = message.getInterceptorChain();
    ListIterator<Interceptor<? extends Message>> it = chain.getIterator();
    boolean bareIn = false;
    boolean wrappedIn = false;
    while (it.hasNext() && !wrappedIn && !bareIn) {
        PhaseInterceptor<? extends Message> pi = (PhaseInterceptor<? extends Message>) it.next();
        if (BareInInterceptor.class.getName().equals(pi.getId())) {
            bareIn = true;
        }
    }
    if (!bareIn) {
        chain.add(new BareInInterceptor());
        LOG.fine("Added BareInInterceptor to chain.");
    }
}
Also used : SoapFault(org.apache.cxf.binding.soap.SoapFault) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) SoapMessage(org.apache.cxf.binding.soap.SoapMessage) Message(org.apache.cxf.message.Message) PhaseInterceptor(org.apache.cxf.phase.PhaseInterceptor) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) RMConstants(org.apache.cxf.ws.rm.RMConstants) RMEndpoint(org.apache.cxf.ws.rm.RMEndpoint) RMException(org.apache.cxf.ws.rm.RMException) RMEndpoint(org.apache.cxf.ws.rm.RMEndpoint) Endpoint(org.apache.cxf.endpoint.Endpoint) RMManager(org.apache.cxf.ws.rm.RMManager) BindingInfo(org.apache.cxf.service.model.BindingInfo) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) AbstractRMInterceptor(org.apache.cxf.ws.rm.AbstractRMInterceptor) AbstractSoapInterceptor(org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor) BareInInterceptor(org.apache.cxf.wsdl.interceptors.BareInInterceptor) Interceptor(org.apache.cxf.interceptor.Interceptor) PhaseInterceptor(org.apache.cxf.phase.PhaseInterceptor) RMProperties(org.apache.cxf.ws.rm.RMProperties) BareInInterceptor(org.apache.cxf.wsdl.interceptors.BareInInterceptor) ProtocolVariation(org.apache.cxf.ws.rm.ProtocolVariation) Exchange(org.apache.cxf.message.Exchange) InterceptorChain(org.apache.cxf.interceptor.InterceptorChain)

Example 3 with RMManager

use of org.apache.cxf.ws.rm.RMManager in project cxf by apache.

the class RMTxStoreConfigurationTest method testSetCustomTableExistsState2.

@Test
public void testSetCustomTableExistsState2() {
    RMTxStore.deleteDatabaseFiles("target/wsrmdb5", true);
    SpringBusFactory factory = new SpringBusFactory();
    Bus bus = factory.createBus("org/apache/cxf/ws/rm/persistence/jdbc/txstore-custom-error-bean2.xml");
    RMManager manager = bus.getExtension(RMManager.class);
    assertNotNull(manager);
    RMTxStore store = (RMTxStore) manager.getStore();
    assertTrue(store.isTableExistsError(new SQLException("Table exists", "I6000", 288)));
    assertFalse(store.isTableExistsError(new SQLException("Unknown error", "00000", -1)));
}
Also used : Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) RMManager(org.apache.cxf.ws.rm.RMManager) SQLException(java.sql.SQLException) Test(org.junit.Test)

Example 4 with RMManager

use of org.apache.cxf.ws.rm.RMManager in project cxf by apache.

the class DeliveryAssuranceOnewayTest method testOnewayExactlyOnceInOrder.

private void testOnewayExactlyOnceInOrder(Executor executor) throws Exception {
    init("org/apache/cxf/systest/ws/rm/exactlyonce-inorder.xml", executor);
    greeterBus.getOutInterceptors().add(new MessageLossSimulator());
    RMManager manager = greeterBus.getExtension(RMManager.class);
    manager.getConfiguration().setBaseRetransmissionInterval(new Long(2000));
    String[] callArgs = new String[] { "one", "two", "three", "four" };
    for (int i = 0; i < callArgs.length; i++) {
        greeter.greetMeOneWay(callArgs[i]);
    }
    awaitMessages(callArgs.length, 1000, 60000);
    List<String> actualArgs = GreeterProvider.CALL_ARGS;
    assertEquals("Wrong number of messages", callArgs.length, actualArgs.size());
    int argNum = 0;
    for (String actual : actualArgs) {
        while (argNum < callArgs.length && !actual.equals(callArgs[argNum])) {
            argNum++;
        }
        assertTrue("Message out of order", argNum < callArgs.length);
    }
}
Also used : RMManager(org.apache.cxf.ws.rm.RMManager) Endpoint(javax.xml.ws.Endpoint)

Example 5 with RMManager

use of org.apache.cxf.ws.rm.RMManager in project cxf by apache.

the class DeliveryAssuranceOnewayTest method testOnewayAtMostOnceInOrder.

private void testOnewayAtMostOnceInOrder(Executor executor) throws Exception {
    init("org/apache/cxf/systest/ws/rm/atmostonce-inorder.xml", executor);
    greeterBus.getOutInterceptors().add(new MessageLossSimulator());
    RMManager manager = greeterBus.getExtension(RMManager.class);
    manager.getConfiguration().setBaseRetransmissionInterval(new Long(2000));
    String[] callArgs = new String[] { "one", "two", "three", "four" };
    for (int i = 0; i < callArgs.length; i++) {
        greeter.greetMeOneWay(callArgs[i]);
    }
    awaitMessages(callArgs.length - 2, 1000, 60000);
    List<String> actualArgs = GreeterProvider.CALL_ARGS;
    assertTrue("Too many messages", callArgs.length >= actualArgs.size());
    int argNum = 0;
    for (String actual : actualArgs) {
        while (argNum < callArgs.length && !actual.equals(callArgs[argNum])) {
            argNum++;
        }
        assertTrue("Message out of order", argNum < callArgs.length);
    }
}
Also used : RMManager(org.apache.cxf.ws.rm.RMManager) Endpoint(javax.xml.ws.Endpoint)

Aggregations

RMManager (org.apache.cxf.ws.rm.RMManager)43 Test (org.junit.Test)26 Endpoint (javax.xml.ws.Endpoint)12 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)12 GreeterService (org.apache.cxf.greeter_control.GreeterService)10 Greeter (org.apache.cxf.greeter_control.Greeter)9 MessageFlow (org.apache.cxf.systest.ws.util.MessageFlow)8 Bus (org.apache.cxf.Bus)7 Client (org.apache.cxf.endpoint.Client)4 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)4 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)4 MBeanServer (javax.management.MBeanServer)3 ObjectName (javax.management.ObjectName)3 WebServiceException (javax.xml.ws.WebServiceException)3 InstrumentationManager (org.apache.cxf.management.InstrumentationManager)3 Message (org.apache.cxf.message.Message)3 RMProperties (org.apache.cxf.ws.rm.RMProperties)3 RMMessage (org.apache.cxf.ws.rm.persistence.RMMessage)3 SQLException (java.sql.SQLException)2 SoapFault (org.apache.cxf.binding.soap.SoapFault)2