org.apache.cxf.service.invoker.MethodDispatcher Java Examples
The following examples show how to use
org.apache.cxf.service.invoker.MethodDispatcher.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NetworkAddressValidatingInterceptor.java From sakai with Educational Community License v2.0 | 6 votes |
protected Method getTargetMethod(Message m) { // Used the SOAP BindingOperationInfo bop = m.getExchange().get(BindingOperationInfo.class); if (bop != null) { MethodDispatcher md = (MethodDispatcher) m.getExchange().get(Service.class).get(MethodDispatcher.class.getName()); return md.getMethod(bop); } // Used for JAX-RS // This doesn't work for JAX-RS sub-resources as the lookup is only done on the original method, not the // sub-resource Method method = (Method) m.get("org.apache.cxf.resource.method"); if (method != null) { return method; } throw new AccessDeniedException("Method is not available : Unauthorized"); }
Example #2
Source File: AuthorizationHandler.java From geofence with GNU General Public License v2.0 | 6 votes |
protected Method getTargetMethod(Message m) { BindingOperationInfo bop = m.getExchange().get(BindingOperationInfo.class); if (bop != null) { MethodDispatcher md = (MethodDispatcher) m.getExchange().get(Service.class).get(MethodDispatcher.class.getName()); return md.getMethod(bop); } Method method = (Method) m.get("org.apache.cxf.resource.method"); if (method != null) { return method; } throw new AccessDeniedException("Method is not available : Unauthorized"); }
Example #3
Source File: NetworkAddressValidatingInterceptor.java From sakai with Educational Community License v2.0 | 6 votes |
protected Method getTargetMethod(Message m) { // Used the SOAP BindingOperationInfo bop = m.getExchange().get(BindingOperationInfo.class); if (bop != null) { MethodDispatcher md = (MethodDispatcher) m.getExchange().get(Service.class).get(MethodDispatcher.class.getName()); return md.getMethod(bop); } // Used for JAX-RS // This doesn't work for JAX-RS sub-resources as the lookup is only done on the original method, not the // sub-resource Method method = (Method) m.get("org.apache.cxf.resource.method"); if (method != null) { return method; } throw new AccessDeniedException("Method is not available : Unauthorized"); }
Example #4
Source File: AegisDatabinding.java From cxf with Apache License 2.0 | 6 votes |
private Method getMethod(Service s, OperationInfo op) { Method m = op.getProperty(Method.class.getName(), Method.class); if (m != null) { return m; } MethodDispatcher md = (MethodDispatcher)s.get(MethodDispatcher.class.getName()); // The ibm jdk requires the simple frontend dependency to be // present for the SimpleMethodDispatcher cast below even if // md is null (sun jdk does not). So, for the jaxrs frontend, // we can exclude the simple frontend from the aegis databinding // dependency as long as this null check is here. if (md == null) { return null; } SimpleMethodDispatcher smd = (SimpleMethodDispatcher)md; return smd.getPrimaryMethod(op); }
Example #5
Source File: MessageUtilsTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void getTargetMethodFromBindingOperationInfo() throws Exception { Method method = MessageUtilsTest.class.getMethod("getTargetMethodFromBindingOperationInfo"); Message message = new MessageImpl(); Exchange exchange = new ExchangeImpl(); message.setExchange(exchange); OperationInfo oi = new OperationInfo(); oi.setName(QName.valueOf("getTargetMethod_fromBindingOperationInfo")); BindingOperationInfo boi = new BindingOperationInfo(null, oi); ServiceImpl serviceImpl = new ServiceImpl(); MethodDispatcher md = new SimpleMethodDispatcher(); md.bind(oi, method); serviceImpl.put(MethodDispatcher.class.getName(), md); exchange.put(Service.class, serviceImpl); exchange.put(BindingOperationInfo.class, boi); Optional<Method> optMethod = MessageUtils.getTargetMethod(message); assertTrue(optMethod.isPresent()); assertEquals(method, optMethod.get()); }
Example #6
Source File: SecureAnnotationsInterceptorTest.java From cxf with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { method = TestService.class.getMethod("echo", new Class[]{}); message.put(SecurityContext.class, new TestSecurityContext()); Exchange ex = new ExchangeImpl(); message.setExchange(ex); Service service = EasyMock.createMock(Service.class); ex.put(Service.class, service); MethodDispatcher md = EasyMock.createMock(MethodDispatcher.class); EasyMock.expect(service.get(MethodDispatcher.class.getName())).andReturn(md); BindingOperationInfo boi = EasyMock.createMock(BindingOperationInfo.class); ex.put(BindingOperationInfo.class, boi); EasyMock.expect(md.getMethod(boi)).andReturn(method); EasyMock.replay(service, md); }
Example #7
Source File: OperationInfoAuthorizingInterceptorTest.java From cxf with Apache License 2.0 | 6 votes |
@Before @Override public void setUp() throws Exception { Exchange ex = setUpExchange(); Service service = EasyMock.createMock(Service.class); ex.put(Service.class, service); MethodDispatcher md = EasyMock.createMock(MethodDispatcher.class); EasyMock.expect(service.get(MethodDispatcher.class.getName())).andReturn(md).anyTimes(); BindingOperationInfo boi = EasyMock.createMock(BindingOperationInfo.class); ex.put(BindingOperationInfo.class, boi); EasyMock.expect(md.getMethod(boi)).andReturn(null); OperationInfo opinfo = EasyMock.createMock(OperationInfo.class); EasyMock.expect(opinfo.getName()).andReturn(new QName("urn:test", "echo")).anyTimes(); EasyMock.expect(boi.getOperationInfo()).andReturn(opinfo).anyTimes(); EasyMock.replay(service, md, boi, opinfo); }
Example #8
Source File: JAXWSMethodInvokerTest.java From cxf with Apache License 2.0 | 5 votes |
private JAXWSMethodInvoker prepareJAXWSMethodInvoker(Exchange ex, Object serviceObject, Method serviceMethod) throws Throwable { EasyMock.reset(factory); factory.create(ex); EasyMock.expectLastCall().andReturn(serviceObject).anyTimes(); factory.release(ex, serviceObject); EasyMock.expectLastCall().anyTimes(); EasyMock.replay(factory); BindingOperationInfo boi = new BindingOperationInfo(); ex.put(BindingOperationInfo.class, boi); Service serviceClass = EasyMock.createMock(Service.class); serviceClass.size(); EasyMock.expectLastCall().andReturn(0).anyTimes(); serviceClass.isEmpty(); EasyMock.expectLastCall().andReturn(true).anyTimes(); ex.put(Service.class, serviceClass); MethodDispatcher md = EasyMock.createMock(MethodDispatcher.class); serviceClass.get(MethodDispatcher.class.getName()); EasyMock.expectLastCall().andReturn(md).anyTimes(); md.getMethod(boi); EasyMock.expectLastCall().andReturn(serviceMethod).anyTimes(); EasyMock.replay(md); EasyMock.replay(serviceClass); // initialize the contextCache ex.getInMessage().getContextualProperty("dummy"); return new JAXWSMethodInvoker(factory); }
Example #9
Source File: ClientProxy.java From cxf with Apache License 2.0 | 5 votes |
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (client == null) { throw new IllegalStateException("The client has been closed."); } if (method.getDeclaringClass().equals(Object.class) || method.getDeclaringClass().equals(Closeable.class)) { return method.invoke(this); } else if (method.getDeclaringClass().isInstance(client)) { return method.invoke(client, args); } MethodDispatcher dispatcher = (MethodDispatcher)endpoint.getService().get(MethodDispatcher.class .getName()); BindingOperationInfo oi = dispatcher.getBindingOperation(method, endpoint); if (oi == null) { throw new Fault(new Message("NO_OPERATION_INFO", LOG, method.getName())); } Object[] params = args; if (null == params) { params = new Object[0]; } Object o = invokeSync(method, oi, params); //call a virtual method passing the object. This causes the IBM JDK //to keep the "this" pointer references and thus "this" doesn't get //finalized in the midst of an invoke operation return adjustObject(o); }
Example #10
Source File: ReflectionServiceFactoryBean.java From cxf with Apache License 2.0 | 5 votes |
@Override public synchronized Service create() { reset(); sendEvent(Event.START_CREATE); initializeServiceConfigurations(); initializeServiceModel(); initializeDefaultInterceptors(); if (invoker != null) { getService().setInvoker(getInvoker()); } else { getService().setInvoker(createInvoker()); } if (getExecutor() != null) { getService().setExecutor(getExecutor()); } if (getDataBinding() != null) { getService().setDataBinding(getDataBinding()); } getService().put(MethodDispatcher.class.getName(), getMethodDispatcher()); createEndpoints(); fillInSchemaCrossreferences(); Service serv = getService(); sendEvent(Event.END_CREATE, serv); return serv; }
Example #11
Source File: ReflectionServiceFactoryBean.java From cxf with Apache License 2.0 | 5 votes |
protected void setServiceProperties() { MethodDispatcher md = getMethodDispatcher(); getService().put(MethodDispatcher.class.getName(), md); for (Class<?> c : md.getClass().getInterfaces()) { getService().put(c.getName(), md); } if (properties != null) { getService().putAll(properties); } }
Example #12
Source File: SimpleAuthorizingInterceptorTest.java From cxf with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { method = TestService.class.getMethod("echo", new Class[]{}); Exchange ex = setUpExchange(); Service service = EasyMock.createMock(Service.class); ex.put(Service.class, service); MethodDispatcher md = EasyMock.createMock(MethodDispatcher.class); EasyMock.expect(service.get(MethodDispatcher.class.getName())).andReturn(md); BindingOperationInfo boi = EasyMock.createMock(BindingOperationInfo.class); ex.put(BindingOperationInfo.class, boi); EasyMock.expect(md.getMethod(boi)).andReturn(method); EasyMock.replay(service, md); }
Example #13
Source File: JaxWsClientProxy.java From cxf with Apache License 2.0 | 4 votes |
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (client == null) { throw new IllegalStateException("The client has been closed."); } Endpoint endpoint = getClient().getEndpoint(); String address = endpoint.getEndpointInfo().getAddress(); MethodDispatcher dispatcher = (MethodDispatcher)endpoint.getService().get( MethodDispatcher.class .getName()); Object[] params = args; if (null == params) { params = new Object[0]; } try { if (method.getDeclaringClass().equals(BindingProvider.class) || method.getDeclaringClass().equals(Object.class) || method.getDeclaringClass().equals(Closeable.class) || method.getDeclaringClass().equals(AutoCloseable.class)) { return method.invoke(this, params); } else if (method.getDeclaringClass().isInstance(client)) { return method.invoke(client, params); } } catch (InvocationTargetException e) { throw e.getCause(); } BindingOperationInfo oi = dispatcher.getBindingOperation(method, endpoint); if (oi == null) { Message msg = new Message("NO_BINDING_OPERATION_INFO", LOG, method.getName()); throw new WebServiceException(msg.toString()); } client.getRequestContext().put(Method.class.getName(), method); boolean isAsync = isAsync(method); Object result = null; try { if (isAsync) { result = invokeAsync(method, oi, params); } else { result = invokeSync(method, oi, params); } } catch (WebServiceException wex) { throw wex; } catch (Exception ex) { throw mapException(method, oi, ex); } finally { if (addressChanged(address)) { setupEndpointAddressContext(getClient().getEndpoint()); } } Map<String, Object> respContext = client.getResponseContext(); Map<String, Scope> scopes = CastUtils.cast((Map<?, ?>)respContext.get(WrappedMessageContext.SCOPES)); if (scopes != null) { for (Map.Entry<String, Scope> scope : scopes.entrySet()) { if (scope.getValue() == Scope.HANDLER) { respContext.remove(scope.getKey()); } } } return adjustObject(result); }
Example #14
Source File: ReflectionServiceFactoryBean.java From cxf with Apache License 2.0 | 4 votes |
public MethodDispatcher getMethodDispatcher() { return methodDispatcher; }
Example #15
Source File: ReflectionServiceFactoryBean.java From cxf with Apache License 2.0 | 4 votes |
protected void setMethodDispatcher(MethodDispatcher m) { methodDispatcher = m; }