Search in sources :

Example 71 with OperationResourceInfo

use of org.apache.cxf.jaxrs.model.OperationResourceInfo in project camel by apache.

the class CxfRsInvoker method performInvocation.

protected Object performInvocation(Exchange cxfExchange, final Object serviceObject, Method method, Object[] paramArray) throws Exception {
    Object response = null;
    if (endpoint.isPerformInvocation()) {
        response = super.performInvocation(cxfExchange, serviceObject, method, paramArray);
    }
    paramArray = insertExchange(method, paramArray, cxfExchange);
    OperationResourceInfo ori = cxfExchange.get(OperationResourceInfo.class);
    if (ori.isSubResourceLocator()) {
        // don't delegate the sub resource locator call to camel processor
        return method.invoke(serviceObject, paramArray);
    }
    Continuation continuation;
    if (!endpoint.isSynchronous() && (continuation = getContinuation(cxfExchange)) != null) {
        LOG.trace("Calling the Camel async processors.");
        return asyncInvoke(cxfExchange, serviceObject, method, paramArray, continuation, response);
    } else {
        LOG.trace("Calling the Camel sync processors.");
        return syncInvoke(cxfExchange, serviceObject, method, paramArray, response);
    }
}
Also used : Continuation(org.apache.cxf.continuations.Continuation) OperationResourceInfo(org.apache.cxf.jaxrs.model.OperationResourceInfo)

Example 72 with OperationResourceInfo

use of org.apache.cxf.jaxrs.model.OperationResourceInfo in project ddf by codice.

the class TestEndpointOperationInfoResourceComparator method setUp.

@Before
public void setUp() throws NoSuchMethodException {
    firstOperation = new OperationResourceInfo(getClass().getMethod(FIRST_OPERATION), null);
    secondOperation = new OperationResourceInfo(getClass().getMethod(SECOND_OPERATION), null);
    unknownService = new OperationResourceInfo(getClass().getMethod(UNKNOWN_SERVICE), null);
    unknownOperation = new OperationResourceInfo(getClass().getMethod(UNKNOWN_OPERATION), null);
}
Also used : OperationResourceInfo(org.apache.cxf.jaxrs.model.OperationResourceInfo) Before(org.junit.Before)

Example 73 with OperationResourceInfo

use of org.apache.cxf.jaxrs.model.OperationResourceInfo in project opencast by opencast.

the class RestPublisherTest method testResourceComparatorSameClass.

@Test
public void testResourceComparatorSameClass() {
    Message message = new MessageImpl();
    ClassResourceInfo cri1 = new ClassResourceInfo(this.getClass());
    ClassResourceInfo cri2 = new ClassResourceInfo(this.getClass());
    OperationResourceInfo oper1 = new OperationResourceInfo(this.getClass().getMethods()[0], cri1);
    OperationResourceInfo oper2 = new OperationResourceInfo(this.getClass().getMethods()[0], cri2);
    Assert.assertEquals(0, rc.compare(cri1, cri2, message));
    Assert.assertEquals(0, rc.compare(oper1, oper2, message));
}
Also used : Message(org.apache.cxf.message.Message) ClassResourceInfo(org.apache.cxf.jaxrs.model.ClassResourceInfo) OperationResourceInfo(org.apache.cxf.jaxrs.model.OperationResourceInfo) MessageImpl(org.apache.cxf.message.MessageImpl) Test(org.junit.Test)

Example 74 with OperationResourceInfo

use of org.apache.cxf.jaxrs.model.OperationResourceInfo in project opencast by opencast.

the class RestPublisherTest method testResourceComparatorSameNonMatchEqualEndpoint.

@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void testResourceComparatorSameNonMatchEqualEndpoint() {
    ServiceReference serviceReference = EasyMock.createNiceMock(ServiceReference.class);
    EasyMock.expect(serviceReference.getProperty(SERVICE_PATH_PROPERTY)).andReturn("/events").anyTimes();
    EasyMock.replay(serviceReference);
    BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
    EasyMock.expect(bc.getServiceReference(EasyMock.anyString())).andReturn(serviceReference).anyTimes();
    EasyMock.replay(bc);
    ComponentContext cc = EasyMock.createNiceMock(ComponentContext.class);
    EasyMock.expect(cc.getBundleContext()).andReturn(bc).anyTimes();
    EasyMock.replay(cc);
    componentContext = cc;
    Message message = new MessageImpl();
    ExchangeImpl exchange = new ExchangeImpl();
    message.setExchange(exchange);
    message.put(Message.ENDPOINT_ADDRESS, "http://localhost:8080/series");
    ClassResourceInfo cri1 = new ClassResourceInfo(this.getClass());
    ClassResourceInfo cri2 = new ClassResourceInfo(RestPublisher.class.getClass());
    OperationResourceInfo oper1 = new OperationResourceInfo(this.getClass().getMethods()[0], cri1);
    OperationResourceInfo oper2 = new OperationResourceInfo(RestPublisher.class.getClass().getMethods()[0], cri2);
    Assert.assertEquals(0, rc.compare(cri1, cri2, message));
    Assert.assertEquals(0, rc.compare(oper1, oper2, message));
}
Also used : ComponentContext(org.osgi.service.component.ComponentContext) Message(org.apache.cxf.message.Message) ClassResourceInfo(org.apache.cxf.jaxrs.model.ClassResourceInfo) OperationResourceInfo(org.apache.cxf.jaxrs.model.OperationResourceInfo) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) ServiceReference(org.osgi.framework.ServiceReference) BundleContext(org.osgi.framework.BundleContext) Test(org.junit.Test)

Example 75 with OperationResourceInfo

use of org.apache.cxf.jaxrs.model.OperationResourceInfo in project opencast by opencast.

the class RestPublisherTest method testResourceComparatorSameMatch.

@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void testResourceComparatorSameMatch() {
    ServiceReference serviceReference = EasyMock.createNiceMock(ServiceReference.class);
    EasyMock.expect(serviceReference.getProperty(SERVICE_PATH_PROPERTY)).andReturn("/events").once();
    EasyMock.expect(serviceReference.getProperty(SERVICE_PATH_PROPERTY)).andReturn("/series").once();
    EasyMock.replay(serviceReference);
    BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
    EasyMock.expect(bc.getServiceReference(EasyMock.anyString())).andReturn(serviceReference).anyTimes();
    EasyMock.replay(bc);
    ComponentContext cc = EasyMock.createNiceMock(ComponentContext.class);
    EasyMock.expect(cc.getBundleContext()).andReturn(bc).anyTimes();
    EasyMock.replay(cc);
    componentContext = cc;
    Message message = new MessageImpl();
    ExchangeImpl exchange = new ExchangeImpl();
    message.setExchange(exchange);
    message.put(Message.ENDPOINT_ADDRESS, "http://localhost:8080/series");
    ClassResourceInfo cri1 = new ClassResourceInfo(this.getClass());
    ClassResourceInfo cri2 = new ClassResourceInfo(RestPublisher.class.getClass());
    OperationResourceInfo oper1 = new OperationResourceInfo(this.getClass().getMethods()[0], cri1);
    OperationResourceInfo oper2 = new OperationResourceInfo(RestPublisher.class.getClass().getMethods()[0], cri2);
    Assert.assertEquals(1, rc.compare(cri1, cri2, message));
    Assert.assertEquals(1, rc.compare(oper1, oper2, message));
}
Also used : ComponentContext(org.osgi.service.component.ComponentContext) Message(org.apache.cxf.message.Message) ClassResourceInfo(org.apache.cxf.jaxrs.model.ClassResourceInfo) OperationResourceInfo(org.apache.cxf.jaxrs.model.OperationResourceInfo) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) ServiceReference(org.osgi.framework.ServiceReference) BundleContext(org.osgi.framework.BundleContext) Test(org.junit.Test)

Aggregations

OperationResourceInfo (org.apache.cxf.jaxrs.model.OperationResourceInfo)129 ClassResourceInfo (org.apache.cxf.jaxrs.model.ClassResourceInfo)104 Message (org.apache.cxf.message.Message)72 Test (org.junit.Test)70 Method (java.lang.reflect.Method)52 MetadataMap (org.apache.cxf.jaxrs.impl.MetadataMap)40 Customer (org.apache.cxf.jaxrs.Customer)22 Endpoint (org.apache.cxf.endpoint.Endpoint)13 MessageImpl (org.apache.cxf.message.MessageImpl)13 ByteArrayInputStream (java.io.ByteArrayInputStream)12 ArrayList (java.util.ArrayList)12 List (java.util.List)12 MultivaluedMap (javax.ws.rs.core.MultivaluedMap)11 Response (javax.ws.rs.core.Response)11 URITemplate (org.apache.cxf.jaxrs.model.URITemplate)11 Exchange (org.apache.cxf.message.Exchange)11 MediaType (javax.ws.rs.core.MediaType)10 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)10 HttpServletResponse (javax.servlet.http.HttpServletResponse)7 MethodDispatcher (org.apache.cxf.jaxrs.model.MethodDispatcher)7