List of usage examples for org.springframework.remoting.support RemoteInvocation invoke
public Object invoke(Object targetObject) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
From source file:org.jdal.remoting.ReferenceInvocationExecutor.java
/** * {@inheritDoc}//from w ww . jav a2 s.c om */ public Object invoke(RemoteInvocation invocation, Object targetObject) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { Assert.notNull(invocation, "RemoteInvocation must not be null"); Assert.notNull(targetObject, "Target object must not be null"); // replace references with clients. Object[] arguments = invocation.getArguments(); for (int i = 0; i < arguments.length; i++) { if (arguments[i] instanceof RemoteReference) { arguments[i] = ((RemoteReference) arguments[i]).createRemoteClient(); } } return invocation.invoke(targetObject); }
From source file:com.haulmont.cuba.core.sys.remoting.CubaRemoteInvocationExecutor.java
@Override public Object invoke(RemoteInvocation invocation, Object targetObject) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { if (invocation instanceof CubaRemoteInvocation) { CubaRemoteInvocation cubaInvocation = (CubaRemoteInvocation) invocation; UUID sessionId = cubaInvocation.getSessionId(); if (sessionId != null) { UserSession session = userSessions.getAndRefresh(sessionId); if (session == null) { ServerConfig serverConfig = configuration.getConfig(ServerConfig.class); String sessionProviderUrl = serverConfig.getUserSessionProviderUrl(); if (StringUtils.isNotBlank(sessionProviderUrl)) { log.debug("User session {} not found, trying to get it from {}", sessionId, sessionProviderUrl); try { HttpServiceProxy proxyFactory = new HttpServiceProxy( getServerSelector(sessionProviderUrl)); proxyFactory.setServiceUrl("cuba_TrustedClientService"); proxyFactory.setServiceInterface(TrustedClientService.class); proxyFactory.afterPropertiesSet(); TrustedClientService trustedClientService = (TrustedClientService) proxyFactory .getObject(); if (trustedClientService != null) { UserSession userSession = trustedClientService .findSession(serverConfig.getTrustedClientPassword(), sessionId); if (userSession != null) { userSessions.add(userSession); } else { log.debug("User session {} not found on {}", sessionId, sessionProviderUrl); }/*from w w w . j a v a 2 s . com*/ } } catch (Exception e) { log.error("Error getting user session from {}", sessionProviderUrl, e); } } } AppContext.setSecurityContext(new SecurityContext(sessionId)); } if (cubaInvocation.getLocale() != null) { Locale requestLocale = Locale.forLanguageTag(cubaInvocation.getLocale()); if (!globalConfig.getAvailableLocales().containsValue(requestLocale)) { requestLocale = null; } UserInvocationContext.setRequestScopeInfo(sessionId, requestLocale, cubaInvocation.getTimeZone(), cubaInvocation.getAddress(), cubaInvocation.getClientInfo()); } } Object result; try { result = invocation.invoke(targetObject); } finally { AppContext.setSecurityContext(null); UserInvocationContext.clearRequestScopeInfo(); } return result; }