Search in sources :

Example 46 with OperationInfo

use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.

the class AbstractMessageResponseTimeInterceptor method getOperationCounterName.

protected ObjectName getOperationCounterName(Exchange ex, ObjectName sericeCounterName) {
    BindingOperationInfo bop = ex.getBindingOperationInfo();
    OperationInfo opInfo = bop == null ? null : bop.getOperationInfo();
    if (opInfo != null) {
        ObjectName o = opInfo.getProperty("javax.management.ObjectName", ObjectName.class);
        if (o != null) {
            return o;
        }
    }
    String operationName = opInfo == null ? null : "\"" + opInfo.getName().getLocalPart() + "\"";
    if (operationName == null) {
        Object nameProperty = ex.get("org.apache.cxf.resource.operation.name");
        if (nameProperty != null) {
            operationName = "\"" + escapePatternChars(nameProperty.toString()) + "\"";
        }
    }
    StringBuilder buffer = new StringBuilder(sericeCounterName.toString());
    if (operationName != null) {
        buffer.append("," + ManagementConstants.OPERATION_NAME_PROP + "=" + operationName);
    }
    String operationCounterName = buffer.toString();
    ObjectName operationCounter = null;
    try {
        operationCounter = new ObjectName(operationCounterName);
        if (opInfo != null) {
            opInfo.setProperty("javax.management.ObjectName", operationCounter);
        }
    } catch (MalformedObjectNameException e) {
        LOG.log(Level.WARNING, "CREATE_COUNTER_OBJECTNAME_FAILED", e);
    }
    return operationCounter;
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) MalformedObjectNameException(javax.management.MalformedObjectNameException) ObjectName(javax.management.ObjectName)

Example 47 with OperationInfo

use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.

the class AbstractMessageResponseTestBase method setupOperationForMessage.

protected void setupOperationForMessage() {
    OperationInfo op = EasyMock.createMock(OperationInfo.class);
    BindingOperationInfo bop = EasyMock.createMock(BindingOperationInfo.class);
    EasyMock.expect(exchange.getBindingOperationInfo()).andReturn(bop);
    EasyMock.expect(bop.getOperationInfo()).andReturn(op);
    EasyMock.expect(op.getName()).andReturn(OPERATION_NAME);
    EasyMock.expect(op.getProperty("javax.management.ObjectName", ObjectName.class)).andReturn(null).anyTimes();
    op.setProperty(EasyMock.eq("javax.management.ObjectName"), EasyMock.anyObject(ObjectName.class));
    EasyMock.expectLastCall();
    EasyMock.replay(bop, op);
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) ObjectName(javax.management.ObjectName)

Example 48 with OperationInfo

use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.

the class ProxyTest method testInvoke.

@Test
public void testInvoke() throws Exception {
    Method m = Proxy.class.getDeclaredMethod("createClient", new Class[] { Bus.class, Endpoint.class, ProtocolVariation.class, Conduit.class, org.apache.cxf.ws.addressing.EndpointReferenceType.class });
    Proxy proxy = EasyMock.createMockBuilder(Proxy.class).addMockedMethod(m).createMock(control);
    proxy.setReliableEndpoint(rme);
    RMManager manager = control.createMock(RMManager.class);
    EasyMock.expect(rme.getManager()).andReturn(manager).anyTimes();
    Bus bus = control.createMock(Bus.class);
    EasyMock.expect(manager.getBus()).andReturn(bus).anyTimes();
    Endpoint endpoint = control.createMock(Endpoint.class);
    EasyMock.expect(rme.getEndpoint(ProtocolVariation.RM10WSA200408)).andReturn(endpoint).anyTimes();
    BindingInfo bi = control.createMock(BindingInfo.class);
    EasyMock.expect(rme.getBindingInfo(ProtocolVariation.RM10WSA200408)).andReturn(bi).anyTimes();
    Conduit conduit = control.createMock(Conduit.class);
    EasyMock.expect(rme.getConduit()).andReturn(conduit).anyTimes();
    org.apache.cxf.ws.addressing.EndpointReferenceType replyTo = control.createMock(org.apache.cxf.ws.addressing.EndpointReferenceType.class);
    EasyMock.expect(rme.getReplyTo()).andReturn(replyTo).anyTimes();
    OperationInfo oi = control.createMock(OperationInfo.class);
    BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);
    EasyMock.expect(bi.getOperation(oi)).andReturn(boi).anyTimes();
    Client client = control.createMock(Client.class);
    EasyMock.expect(client.getRequestContext()).andReturn(new HashMap<String, Object>()).anyTimes();
    EasyMock.expect(proxy.createClient(bus, endpoint, ProtocolVariation.RM10WSA200408, conduit, replyTo)).andReturn(client).anyTimes();
    Object[] args = new Object[] {};
    Map<String, Object> context = new HashMap<>();
    Object[] results = new Object[] { "a", "b", "c" };
    Exchange exchange = control.createMock(Exchange.class);
    EasyMock.expect(client.invoke(boi, args, context, exchange)).andReturn(results).anyTimes();
    control.replay();
    assertEquals("a", proxy.invoke(oi, ProtocolVariation.RM10WSA200408, args, context, exchange));
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) Bus(org.apache.cxf.Bus) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) HashMap(java.util.HashMap) Method(java.lang.reflect.Method) Exchange(org.apache.cxf.message.Exchange) Endpoint(org.apache.cxf.endpoint.Endpoint) Conduit(org.apache.cxf.transport.Conduit) BindingInfo(org.apache.cxf.service.model.BindingInfo) Client(org.apache.cxf.endpoint.Client) Test(org.junit.Test)

Example 49 with OperationInfo

use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.

the class ProxyTest method testLastMessage.

@Test
public void testLastMessage() throws NoSuchMethodException, RMException {
    Method m = Proxy.class.getDeclaredMethod("invoke", new Class[] { OperationInfo.class, ProtocolVariation.class, Object[].class, Map.class, Level.class });
    Proxy proxy = EasyMock.createMockBuilder(Proxy.class).addMockedMethod(m).createMock(control);
    proxy.setReliableEndpoint(rme);
    SourceSequence ss = control.createMock(SourceSequence.class);
    EasyMock.expect(ss.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
    EasyMock.expect(ss.getTarget()).andReturn(null).anyTimes();
    control.replay();
    proxy.lastMessage(ss);
    control.verify();
    control.reset();
    org.apache.cxf.ws.addressing.EndpointReferenceType target = RMUtils.createAnonymousReference();
    EasyMock.expect(ss.getTarget()).andReturn(target).anyTimes();
    control.replay();
    proxy.lastMessage(ss);
    control.verify();
    control.reset();
    target = RMUtils.createReference("http://localhost:9000/greeterPort");
    EasyMock.expect(ss.getTarget()).andReturn(target).anyTimes();
    EasyMock.expect(ss.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
    Endpoint endpoint = control.createMock(Endpoint.class);
    EasyMock.expect(rme.getEndpoint(ProtocolVariation.RM10WSA200408)).andReturn(endpoint).anyTimes();
    EndpointInfo epi = control.createMock(EndpointInfo.class);
    EasyMock.expect(endpoint.getEndpointInfo()).andReturn(epi).anyTimes();
    ServiceInfo si = control.createMock(ServiceInfo.class);
    EasyMock.expect(epi.getService()).andReturn(si).anyTimes();
    InterfaceInfo ii = control.createMock(InterfaceInfo.class);
    EasyMock.expect(si.getInterface()).andReturn(ii).anyTimes();
    OperationInfo oi = control.createMock(OperationInfo.class);
    EasyMock.expect(ii.getOperation(RM10Constants.CLOSE_SEQUENCE_QNAME)).andReturn(oi).anyTimes();
    expectInvokeWithContext(proxy, oi, null);
    control.replay();
    proxy.lastMessage(ss);
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) Method(java.lang.reflect.Method) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) Test(org.junit.Test)

Example 50 with OperationInfo

use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.

the class ProxyTest method testAcknowledge.

@Test
public void testAcknowledge() throws NoSuchMethodException, RMException {
    Method m = Proxy.class.getDeclaredMethod("invoke", new Class[] { OperationInfo.class, ProtocolVariation.class, Object[].class, Map.class });
    Proxy proxy = EasyMock.createMockBuilder(Proxy.class).addMockedMethod(m).createMock(control);
    proxy.setReliableEndpoint(rme);
    DestinationSequence ds = control.createMock(DestinationSequence.class);
    EasyMock.expect(ds.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
    EndpointReferenceType acksToEPR = control.createMock(EndpointReferenceType.class);
    EasyMock.expect(ds.getAcksTo()).andReturn(acksToEPR).anyTimes();
    AttributedURIType acksToURI = control.createMock(AttributedURIType.class);
    EasyMock.expect(acksToEPR.getAddress()).andReturn(acksToURI).anyTimes();
    String acksToAddress = "acksTo";
    EasyMock.expect(acksToURI.getValue()).andReturn(acksToAddress).anyTimes();
    Endpoint endpoint = control.createMock(Endpoint.class);
    EasyMock.expect(rme.getEndpoint(ProtocolVariation.RM10WSA200408)).andReturn(endpoint).anyTimes();
    EndpointInfo epi = control.createMock(EndpointInfo.class);
    EasyMock.expect(endpoint.getEndpointInfo()).andReturn(epi).anyTimes();
    ServiceInfo si = control.createMock(ServiceInfo.class);
    EasyMock.expect(epi.getService()).andReturn(si).anyTimes();
    InterfaceInfo ii = control.createMock(InterfaceInfo.class);
    EasyMock.expect(si.getInterface()).andReturn(ii).anyTimes();
    OperationInfo oi = control.createMock(OperationInfo.class);
    EasyMock.expect(ii.getOperation(RM10Constants.SEQUENCE_ACK_QNAME)).andReturn(oi).anyTimes();
    expectInvoke(proxy, oi, null);
    control.replay();
    proxy.acknowledge(ds);
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) Endpoint(org.apache.cxf.endpoint.Endpoint) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) Method(java.lang.reflect.Method) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) Test(org.junit.Test)

Aggregations

OperationInfo (org.apache.cxf.service.model.OperationInfo)135 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)87 QName (javax.xml.namespace.QName)58 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)44 MessageInfo (org.apache.cxf.service.model.MessageInfo)40 Test (org.junit.Test)38 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)36 InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)31 Method (java.lang.reflect.Method)25 Endpoint (org.apache.cxf.endpoint.Endpoint)24 Service (org.apache.cxf.service.Service)22 BindingInfo (org.apache.cxf.service.model.BindingInfo)21 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)19 SoapOperationInfo (org.apache.cxf.binding.soap.model.SoapOperationInfo)17 Exchange (org.apache.cxf.message.Exchange)17 ArrayList (java.util.ArrayList)13 UnwrappedOperationInfo (org.apache.cxf.service.model.UnwrappedOperationInfo)13 BindingMessageInfo (org.apache.cxf.service.model.BindingMessageInfo)12 Fault (org.apache.cxf.interceptor.Fault)10 Message (org.apache.cxf.message.Message)10