当前位置: 首页>>代码示例>>Java>>正文


Java MethodInvocation类代码示例

本文整理汇总了Java中org.aopalliance.intercept.MethodInvocation的典型用法代码示例。如果您正苦于以下问题:Java MethodInvocation类的具体用法?Java MethodInvocation怎么用?Java MethodInvocation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MethodInvocation类属于org.aopalliance.intercept包,在下文中一共展示了MethodInvocation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: invoke

import org.aopalliance.intercept.MethodInvocation; //导入依赖的package包/类
@Override
public Object invoke(MethodInvocation methodInvocation) throws Throwable {

	System.out.println("Method name : "
			+ methodInvocation.getMethod().getName());

	// same with MethodBeforeAdvice
	System.out.println("InsertAroundMethod : Before method inserted!");

	try {
		// proceed to original method call
		Object result = methodInvocation.proceed();

		// same with AfterReturningAdvice
		System.out.println("InsertAroundMethod : after method inserted!");

		return result;

	} catch (IllegalArgumentException e) {
		// same with ThrowsAdvice
		System.out
				.println("InsertAroundMethod : Throw exception inserted!");
		throw e;
	}
}
 
开发者ID:Illusionist80,项目名称:SpringTutorial,代码行数:26,代码来源:InsertAroundMethod.java

示例2: getDisposalLockProxy

import org.aopalliance.intercept.MethodInvocation; //导入依赖的package包/类
/**
 * Apply a lock (preferably a read lock allowing multiple concurrent access) to the bean. Callers should replace the
 * bean input with the output.
 *
 * @param bean the bean to lock
 * @param lock the lock to apply
 * @return a proxy that locks while its methods are executed
 */
private Object getDisposalLockProxy(Object bean, final Lock lock) {
    ProxyFactory factory = new ProxyFactory(bean);
    factory.setProxyTargetClass(proxyTargetClass);
    factory.addAdvice(new MethodInterceptor() {
        public Object invoke(MethodInvocation invocation) throws Throwable {
            lock.lock();
            try {
                return invocation.proceed();
            } finally {
                lock.unlock();
            }
        }
    });
    return factory.getProxy();
}
 
开发者ID:zouzhirong,项目名称:configx,代码行数:24,代码来源:StandardBeanLifecycleDecorator.java

示例3: invoke

import org.aopalliance.intercept.MethodInvocation; //导入依赖的package包/类
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
  Service service = getService(invocation);
  RequestHeader requestHeader = getRequestHeader(invocation);

  try {
    // For each service method invocation verify that user is authenticated!
    //noinspection unchecked
    accessController.validate(requestHeader.getCredentials());
  } catch (InvalidCredentialsException ex) {
    throw new AuthenticationFailedException("Could not authenticate user: " + ex.getMessage());
  }

  if (SecurityContext.isSet()) {
    return invocation.proceed();
  }

  try (SecurityContext ignored = SecurityContext.set(service.createSecurityContext(requestHeader.getCredentials()))) {
    return invocation.proceed();
  }
}
 
开发者ID:mnemonic-no,项目名称:act-platform,代码行数:22,代码来源:AuthenticationAspect.java

示例4: invoke

import org.aopalliance.intercept.MethodInvocation; //导入依赖的package包/类
/**
 * Subclasses may need to override this if they want to perform custom
 * behaviour in around advice. However, subclasses should invoke this
 * method, which handles introduced interfaces and forwarding to the target.
 */
@Override
public Object invoke(MethodInvocation mi) throws Throwable {
	if (isMethodOnIntroducedInterface(mi)) {
		Object delegate = getIntroductionDelegateFor(mi.getThis());

		// Using the following method rather than direct reflection,
		// we get correct handling of InvocationTargetException
		// if the introduced method throws an exception.
		Object retVal = AopUtils.invokeJoinpointUsingReflection(delegate, mi.getMethod(), mi.getArguments());

		// Massage return value if possible: if the delegate returned itself,
		// we really want to return the proxy.
		if (retVal == delegate && mi instanceof ProxyMethodInvocation) {
			retVal = ((ProxyMethodInvocation) mi).getProxy();
		}
		return retVal;
	}

	return doProceed(mi);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:DelegatePerTargetObjectIntroductionInterceptor.java

示例5: validateMethodParameters

import org.aopalliance.intercept.MethodInvocation; //导入依赖的package包/类
private void validateMethodParameters(MethodInvocation invocation) throws InvalidArgumentException {
  boolean isInvalid = false;
  InvalidArgumentException ex = new InvalidArgumentException();

  for (int i = 0; i < invocation.getMethod().getParameterCount(); i++) {
    Parameter parameter = invocation.getMethod().getParameters()[i];
    // Only validate arguments which implement ValidatingRequest.
    if (ValidatingRequest.class.isAssignableFrom(parameter.getType())) {
      ValidatingRequest request = (ValidatingRequest) invocation.getArguments()[i];
      if (request == null) {
        // Don't allow null request objects.
        ex.addValidationError(InvalidArgumentException.ErrorMessage.NULL, parameter.getName(), "NULL");
        isInvalid = true;
      } else {
        isInvalid |= validateRequest(request, ex);
      }
    }
  }

  if (isInvalid) {
    // If violations exist abort invoked service call.
    throw ex;
  }
}
 
开发者ID:mnemonic-no,项目名称:act-platform,代码行数:25,代码来源:ValidationAspect.java

示例6: getBeanNameImpl

import org.aopalliance.intercept.MethodInvocation; //导入依赖的package包/类
/**
 * Do the look up by interface type.
 * 
 * @return              Returns the name of the service or <tt>null</tt> if not found
 */
private String getBeanNameImpl(MethodInvocation mi) throws BeansException
{
    if (mi instanceof ProxyMethodInvocation)
    {
        Object proxy = ((ProxyMethodInvocation) mi).getProxy();
        Map beans = beanFactory.getBeansOfType(proxy.getClass());
        Iterator iter = beans.entrySet().iterator();
        while (iter.hasNext())
        {
            Map.Entry entry = (Map.Entry) iter.next();
            String name = (String) entry.getKey();
            if (proxy == entry.getValue() && !name.equals("DescriptorService"))
            {
                return name;
            }
        }
    }
    return null;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:BeanIdentifierImpl.java

示例7: runAsSystem

import org.aopalliance.intercept.MethodInvocation; //导入依赖的package包/类
private Object runAsSystem(MethodInvocation invocation) throws Throwable
{
    Object ret = null;

    // We're creating in enhanced mode and have a matching filename or path. Switch to
    // the system user to do the operation.

    AuthenticationUtil.pushAuthentication();
    try
    {
        AuthenticationUtil.setRunAsUserSystem();
        ret = invocation.proceed();
    }
    finally
    {
        AuthenticationUtil.popAuthentication();
    }
    
    return ret;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:FilenameFilteringInterceptor.java

示例8: SubsystemProxyFactory

import org.aopalliance.intercept.MethodInvocation; //导入依赖的package包/类
/**
 * Instantiates a new managed subsystem proxy factory.
 */
public SubsystemProxyFactory()
{
    addAdvisor(new DefaultPointcutAdvisor(new MethodInterceptor()
    {
        public Object invoke(MethodInvocation mi) throws Throwable
        {
            Method method = mi.getMethod();
            try
            {
                return method.invoke(locateBean(mi), mi.getArguments());
            }
            catch (InvocationTargetException e)
            {
                // Unwrap invocation target exceptions
                throw e.getTargetException();
            }
        }
    }));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:23,代码来源:SubsystemProxyFactory.java

示例9: invoke

import org.aopalliance.intercept.MethodInvocation; //导入依赖的package包/类
public Object invoke(MethodInvocation mi) throws Throwable
{
    Class<?>[] parameterTypes = mi.getMethod().getParameterTypes();
    Object[] arguments = mi.getArguments();
    for (int i = 0; i < parameterTypes.length; i++)
    {
        if (arguments[i] instanceof ContentStreamImpl)
        {
        	ContentStreamImpl contentStream = (ContentStreamImpl) arguments[i];
            if (contentStream != null)
            {
                // ALF-18006
                if (contentStream.getMimeType() == null)
                {
                	InputStream stream = contentStream.getStream();
                    String mimeType = mimetypeService.guessMimetype(contentStream.getFileName(), stream);
                    contentStream.setMimeType(mimeType);
                }
            }
        }
    }
    return mi.proceed();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:24,代码来源:AlfrescoCmisStreamInterceptor.java

示例10: invoke

import org.aopalliance.intercept.MethodInvocation; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
    //
    Method m = invocation.getMethod();

    if (m.isAnnotationPresent(Conditioned.class)) {
        Object[] arg = invocation.getArguments();
        if (arg.length > 0 && arg[arg.length - 1] instanceof List && !((List) arg[arg.length - 1]).isEmpty() && ((List) arg[arg.length - 1]).get(0) instanceof GherkinStepCondition) {
            List<GherkinStepCondition> conditions = (List) arg[arg.length - 1];
            displayMessageAtTheBeginningOfMethod(m.getName(), conditions);
            if (!checkConditions(conditions)) {
                Context.getCurrentScenario().write(Messages.getMessage(SKIPPED_DUE_TO_CONDITIONS));
                return Void.TYPE;
            }
        }
    }

    logger.debug("NORAUI ConditionedInterceptor invoke method {}", invocation.getMethod());
    return invocation.proceed();
}
 
开发者ID:NoraUi,项目名称:NoraUi,代码行数:24,代码来源:ConditionedInterceptor.java

示例11: handle

import org.aopalliance.intercept.MethodInvocation; //导入依赖的package包/类
public void handle(Throwable exception, MethodInvocation invocation) {
	HttpServletRequest request=DoradoContext.getCurrent().getRequest();
	String contextPath=request.getContextPath();
	StringBuffer sb=new StringBuffer();
	NoneLoginException ex=(NoneLoginException)exception;
	if(ex.isSessionKickAway()){
		sb.append("dorado.MessageBox.alert(\""+Configure.getString("bdf2.ajaxSessionKickAwayMessage")+"\",function(){\n");
		sb.append("window.open(\""+contextPath+Configure.getString("bdf2.formLoginUrl")+"\",\"_top\");\n");
		sb.append("})");			
	}else{
		sb.append("dorado.MessageBox.alert(\""+Configure.getString("bdf2.ajaxSessionExpireMessage")+"\",function(){\n");
		sb.append("window.open(\""+contextPath+Configure.getString("bdf2.formLoginUrl")+"\",\"_top\");\n");
		sb.append("})");			
	}
       throw new ClientRunnableException(sb.toString());
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:17,代码来源:NoneLoginAjaxExceptionHandler.java

示例12: canCurrentUserAccessView

import org.aopalliance.intercept.MethodInvocation; //导入依赖的package包/类
/**
 * @param viewClass
 * @return true si l'utilisateur peut accéder à la vue
 */
public boolean canCurrentUserAccessView(Class<? extends View> viewClass, Authentication auth) {
	if (auth == null) {
		return false;
	}
	MethodInvocation methodInvocation = MethodInvocationUtils.createFromClass(viewClass, "enter");
	Collection<ConfigAttribute> configAttributes = methodSecurityInterceptor.obtainSecurityMetadataSource()
			.getAttributes(methodInvocation);
	/* Renvoie true si la vue n'est pas sécurisée */
	if (configAttributes.isEmpty()) {
		return true;
	}
	/* Vérifie que l'utilisateur a les droits requis */
	try {
		methodSecurityInterceptor.getAccessDecisionManager().decide(auth, methodInvocation, configAttributes);
	} catch (InsufficientAuthenticationException | AccessDeniedException e) {
		return false;
	}
	return true;
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:24,代码来源:UserController.java

示例13: invoke

import org.aopalliance.intercept.MethodInvocation; //导入依赖的package包/类
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
  final Message message = getMessageArgument(invocation.getArguments());
  if (message == null) {
    throw new IllegalStateException("Message cannot be null");
  }
  before(message);
  return invocation.proceed();
}
 
开发者ID:netshoes,项目名称:spring-cloud-sleuth-amqp,代码行数:10,代码来源:AmqpMessagingBeforeReceiveInterceptor.java

示例14: invoke

import org.aopalliance.intercept.MethodInvocation; //导入依赖的package包/类
@Override
public Object invoke(MethodInvocation mi) throws Throwable {
	try {
		return mi.proceed();
	}
	catch (RuntimeException ex) {
		// Let it throw raw if the type of the exception is on the throws clause of the method.
		if (!this.alwaysTranslate && ReflectionUtils.declaresException(mi.getMethod(), ex.getClass())) {
			throw ex;
		}
		else {
			if (this.persistenceExceptionTranslator == null) {
				this.persistenceExceptionTranslator = detectPersistenceExceptionTranslators(this.beanFactory);
			}
			throw DataAccessUtils.translateIfNecessary(ex, this.persistenceExceptionTranslator);
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:PersistenceExceptionTranslationInterceptor.java

示例15: handleConnectFailure

import org.aopalliance.intercept.MethodInvocation; //导入依赖的package包/类
/**
 * Refresh the connection and retry the MBean invocation if possible.
 * <p>If not configured to refresh on connect failure, this method
 * simply rethrows the original exception.
 * @param invocation the invocation that failed
 * @param ex the exception raised on remote invocation
 * @return the result value of the new invocation, if succeeded
 * @throws Throwable an exception raised by the new invocation,
 * if it failed as well
 * @see #setRefreshOnConnectFailure
 * @see #doInvoke
 */
protected Object handleConnectFailure(MethodInvocation invocation, Exception ex) throws Throwable {
	if (this.refreshOnConnectFailure) {
		String msg = "Could not connect to JMX server - retrying";
		if (logger.isDebugEnabled()) {
			logger.warn(msg, ex);
		}
		else if (logger.isWarnEnabled()) {
			logger.warn(msg);
		}
		prepare();
		return doInvoke(invocation);
	}
	else {
		throw ex;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:MBeanClientInterceptor.java


注:本文中的org.aopalliance.intercept.MethodInvocation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。