Search in sources :

Example 41 with InterfaceInfo

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

the class PolicyAnnotationListener method handleEvent.

public void handleEvent(Event ev, AbstractServiceFactoryBean factory, Object... args) {
    switch(ev) {
        case INTERFACE_CREATED:
            {
                InterfaceInfo ii = (InterfaceInfo) args[0];
                Class<?> cls = (Class<?>) args[1];
                addPolicies(factory, ii, cls);
                break;
            }
        case ENDPOINT_SELECTED:
            {
                Class<?> cls = (Class<?>) args[2];
                Class<?> implCls = (Class<?>) args[3];
                Endpoint ep = (Endpoint) args[1];
                if (ep.getEndpointInfo().getInterface() != null) {
                    addPolicies(factory, ep, cls);
                    // this will allow us to support annotations in Implementations.
                    // The call has been moved here so that the ServiceInfo
                    // policy stuff is loaded before jaxws factory calls the PolicyEngineImpl
                    addEndpointImplPolicies(factory, ep, implCls);
                }
                break;
            }
        case INTERFACE_OPERATION_BOUND:
            {
                OperationInfo inf = (OperationInfo) args[0];
                Method m = (Method) args[1];
                addPolicies(factory, inf, m);
                break;
            }
        case BINDING_OPERATION_CREATED:
            BindingOperationInfo boi = (BindingOperationInfo) args[1];
            Method m = (Method) args[2];
            addPolicies(factory, boi.getOperationInfo(), m);
            break;
        default:
    }
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) Method(java.lang.reflect.Method)

Example 42 with InterfaceInfo

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

the class ProxyTest method testCreateSequence.

@SuppressWarnings("unchecked")
private void testCreateSequence(boolean isServer) throws NoSuchMethodException, RMException {
    Method m = Proxy.class.getDeclaredMethod("invoke", new Class[] { OperationInfo.class, ProtocolVariation.class, Object[].class, Map.class, Exchange.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();
    SourcePolicyType sp = control.createMock(SourcePolicyType.class);
    EasyMock.expect(manager.getSourcePolicy()).andReturn(sp).anyTimes();
    EasyMock.expect(sp.getAcksTo()).andReturn(null).anyTimes();
    Duration d = DatatypeFactory.createDuration("PT12H");
    EasyMock.expect(sp.getSequenceExpiration()).andReturn(d).anyTimes();
    EasyMock.expect(sp.isIncludeOffer()).andReturn(Boolean.TRUE).anyTimes();
    Duration dOffered = DatatypeFactory.createDuration("PT24H");
    EasyMock.expect(sp.getOfferedSequenceExpiration()).andReturn(dOffered).anyTimes();
    Source source = control.createMock(Source.class);
    EasyMock.expect(rme.getSource()).andReturn(source).anyTimes();
    Identifier offeredId = control.createMock(Identifier.class);
    EasyMock.expect(source.generateSequenceIdentifier()).andReturn(offeredId).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);
    org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType csr = null;
    if (isServer) {
        EasyMock.expect(ii.getOperation(RM10Constants.CREATE_SEQUENCE_ONEWAY_QNAME)).andReturn(oi).anyTimes();
        Endpoint ae = control.createMock(Endpoint.class);
        EasyMock.expect(rme.getApplicationEndpoint()).andReturn(ae).anyTimes();
        EasyMock.expect(ae.getExecutor()).andReturn(SynchronousExecutor.getInstance()).anyTimes();
    } else {
        EasyMock.expect(ii.getOperation(RM10Constants.CREATE_SEQUENCE_QNAME)).andReturn(oi).anyTimes();
        csr = new org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType();
    }
    ExchangeImpl exchange = new ExchangeImpl();
    EasyMock.expect(proxy.invoke(EasyMock.same(oi), EasyMock.isA(ProtocolVariation.class), EasyMock.isA(Object[].class), EasyMock.isA(Map.class), EasyMock.isA(Exchange.class))).andReturn(csr).anyTimes();
    EndpointReferenceType defaultAcksTo = control.createMock(EndpointReferenceType.class);
    AttributedURIType aut = control.createMock(AttributedURIType.class);
    EasyMock.expect(aut.getValue()).andReturn("here").anyTimes();
    EasyMock.expect(defaultAcksTo.getAddress()).andReturn(aut).anyTimes();
    RelatesToType relatesTo = control.createMock(RelatesToType.class);
    control.replay();
    Map<String, Object> context = new HashMap<>();
    if (isServer) {
        assertNull(proxy.createSequence(defaultAcksTo, relatesTo, isServer, ProtocolVariation.RM10WSA200408, exchange, context));
    } else {
        assertNotNull(proxy.createSequence(defaultAcksTo, relatesTo, isServer, ProtocolVariation.RM10WSA200408, exchange, context));
    }
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) HashMap(java.util.HashMap) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) Duration(javax.xml.datatype.Duration) Method(java.lang.reflect.Method) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) RelatesToType(org.apache.cxf.ws.addressing.RelatesToType) Identifier(org.apache.cxf.ws.rm.v200702.Identifier) Endpoint(org.apache.cxf.endpoint.Endpoint) SourcePolicyType(org.apache.cxf.ws.rm.manager.SourcePolicyType) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 43 with InterfaceInfo

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

the class ProxyTest method testTerminate.

@Test
public void testTerminate() 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);
    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.TERMINATE_SEQUENCE_QNAME)).andReturn(oi).anyTimes();
    SourceSequence ss = control.createMock(SourceSequence.class);
    Identifier id = control.createMock(Identifier.class);
    EasyMock.expect(ss.getIdentifier()).andReturn(id).anyTimes();
    EasyMock.expect(ss.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
    expectInvoke(proxy, oi, null);
    control.replay();
    proxy.terminate(ss);
}
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) Identifier(org.apache.cxf.ws.rm.v200702.Identifier) Endpoint(org.apache.cxf.endpoint.Endpoint) Method(java.lang.reflect.Method) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) Test(org.junit.Test)

Example 44 with InterfaceInfo

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

the class RMEndpointTest method verifyService.

private void verifyService() {
    Service service = rme.getService(ProtocolVariation.RM10WSA200408);
    ServiceInfo si = service.getServiceInfos().get(0);
    assertNotNull("service info is null", si);
    InterfaceInfo intf = si.getInterface();
    assertEquals(8, intf.getOperations().size());
    String ns = RM10Constants.NAMESPACE_URI;
    OperationInfo oi = intf.getOperation(new QName(ns, "CreateSequence"));
    assertNotNull("No operation info.", oi);
    assertTrue("Operation is oneway.", !oi.isOneWay());
    assertTrue("Operation is unwrapped.", !oi.isUnwrapped());
    assertTrue("Operation is unwrappedCapable.", !oi.isUnwrappedCapable());
    assertNull("Unexpected unwrapped operation.", oi.getUnwrappedOperation());
    oi = intf.getOperation(new QName(ns, "TerminateSequence"));
    assertNotNull("No operation info.", oi);
    assertTrue("Operation is toway.", oi.isOneWay());
    oi = intf.getOperation(new QName(ns, "TerminateSequenceAnonymous"));
    assertNotNull("No operation info.", oi);
    assertTrue("Operation is oneway.", !oi.isOneWay());
    oi = intf.getOperation(new QName(ns, "SequenceAcknowledgement"));
    assertNotNull("No operation info.", oi);
    assertTrue("Operation is toway.", oi.isOneWay());
    oi = intf.getOperation(new QName(ns, "CloseSequence"));
    assertNotNull("No operation info.", oi);
    assertTrue("Operation is toway.", oi.isOneWay());
    oi = intf.getOperation(new QName(ns, "AckRequested"));
    assertNotNull("No operation info.", oi);
    assertTrue("Operation is toway.", oi.isOneWay());
    oi = intf.getOperation(new QName(ns, "CreateSequenceOneway"));
    assertNotNull("No operation info.", oi);
    assertTrue("Operation is toway.", oi.isOneWay());
    oi = intf.getOperation(new QName(ns, "CreateSequenceResponseOneway"));
    assertNotNull("No operation info.", oi);
    assertTrue("Operation is toway.", oi.isOneWay());
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) QName(javax.xml.namespace.QName) Service(org.apache.cxf.service.Service) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo)

Example 45 with InterfaceInfo

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

the class JavaFirstUtil method serviceInfo2JavaInf.

public static JavaInterface serviceInfo2JavaInf(ServiceInfo service) {
    JavaInterface javaInf = new JavaInterface();
    InterfaceInfo inf = service.getInterface();
    for (OperationInfo op : inf.getOperations()) {
        JavaMethod jm = new JavaMethod();
        Method m = (Method) op.getProperty(ReflectionServiceFactoryBean.METHOD);
        jm.setName(m.getName());
        int i = 0;
        for (Type type : m.getGenericParameterTypes()) {
            JavaParameter jp = new JavaParameter();
            jp.setClassName(getClassName(type));
            jp.setStyle(Style.IN);
            jp.setName("arg" + i++);
            jm.addParameter(jp);
        }
        for (Type type : m.getGenericExceptionTypes()) {
            JavaException jex = new JavaException();
            String className = getClassName(type);
            jex.setClassName(className);
            jex.setName(className);
            jm.addException(jex);
        }
        JavaReturn jreturn = new JavaReturn();
        jreturn.setClassName(getClassName(m.getGenericReturnType()));
        jreturn.setStyle(Style.OUT);
        jm.setReturn(jreturn);
        String pkg = PackageUtils.getPackageName(m.getDeclaringClass());
        javaInf.setPackageName(pkg.length() == 0 ? ToolConstants.DEFAULT_PACKAGE_NAME : pkg);
        javaInf.addMethod(jm);
        javaInf.setName(inf.getName().getLocalPart());
        jm.getParameterList();
    }
    return javaInf;
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) JavaReturn(org.apache.cxf.tools.common.model.JavaReturn) JavaInterface(org.apache.cxf.tools.common.model.JavaInterface) GenericArrayType(java.lang.reflect.GenericArrayType) ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) JavaException(org.apache.cxf.tools.common.model.JavaException) JavaMethod(org.apache.cxf.tools.common.model.JavaMethod) JavaParameter(org.apache.cxf.tools.common.model.JavaParameter) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) JavaMethod(org.apache.cxf.tools.common.model.JavaMethod) Method(java.lang.reflect.Method)

Aggregations

InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)52 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)32 OperationInfo (org.apache.cxf.service.model.OperationInfo)30 QName (javax.xml.namespace.QName)25 Test (org.junit.Test)23 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)21 Service (org.apache.cxf.service.Service)20 Endpoint (org.apache.cxf.endpoint.Endpoint)19 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)17 BindingInfo (org.apache.cxf.service.model.BindingInfo)16 Method (java.lang.reflect.Method)15 ArrayList (java.util.ArrayList)10 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)9 Bus (org.apache.cxf.Bus)8 AbstractJaxWsTest (org.apache.cxf.jaxws.AbstractJaxWsTest)7 JaxWsServiceFactoryBean (org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean)7 List (java.util.List)5 WebService (javax.jws.WebService)5 MessageInfo (org.apache.cxf.service.model.MessageInfo)5 ReflectionServiceFactoryBean (org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean)5